diff --git a/Block/System/Account/ResetUiBookmarks.php b/Block/System/Account/ResetUiBookmarks.php new file mode 100644 index 0000000..b9a4af0 --- /dev/null +++ b/Block/System/Account/ResetUiBookmarks.php @@ -0,0 +1,58 @@ +bookmarkFactory = $bookmarkFactory; + } + + /** + * Return a list of namespaces from table ui_bookmarks + * + * @return array + */ + public function getNamespaceList() + { + $data = []; + $items = $this->bookmarkFactory->create() + ->getCollection() + ->addFieldToSelect('namespace') + ->addOrder('namespace', \Magento\Framework\DB\Select::SQL_DESC) + ->getItems(); + + if (!empty($items)) { + foreach ($items as $item) { + $data[$item->getData('namespace')] = ucwords(str_replace('_', ' ', $item->getData('namespace'))); + } + } + + return $data; + } +} diff --git a/Controller/Adminhtml/Reset/Index.php b/Controller/Adminhtml/Reset/Index.php index ce0add9..9a9ae64 100644 --- a/Controller/Adminhtml/Reset/Index.php +++ b/Controller/Adminhtml/Reset/Index.php @@ -42,13 +42,14 @@ class Index extends \Magento\Backend\App\Action * @param \Magento\User\Model\UserFactory $userFactory */ public function __construct( - \Magento\Backend\App\Action\Context $context, - \Magento\Ui\Api\Data\BookmarkInterfaceFactory $bookmarkFactory, + \Magento\Backend\App\Action\Context $context, + \Magento\Ui\Api\Data\BookmarkInterfaceFactory $bookmarkFactory, \Magento\Ui\Model\ResourceModel\BookmarkRepository $bookmarkRepository, - \Magento\Framework\Controller\ResultFactory $resultFactory, - \Magento\Framework\App\RequestInterface $request, - \Magento\User\Model\UserFactory $userFactory - ) { + \Magento\Framework\Controller\ResultFactory $resultFactory, + \Magento\Framework\App\RequestInterface $request, + \Magento\User\Model\UserFactory $userFactory + ) + { parent::__construct($context); $this->bookmarkFactory = $bookmarkFactory; @@ -69,7 +70,7 @@ public function execute() $params = $this->request->getParam('magenizr_resetuibookmarks'); $userId = $this->_auth->getUser()->getId(); - + if (!empty($params['userId'])) { $system = false; @@ -94,7 +95,16 @@ public function execute() $collection->addFieldToFilter('identifier', ['like' => '_%']); break; case 'saved-exclude': - $collection->addFieldToFilter('identifier', ['in' => ['current','default']]); + $collection->addFieldToFilter('identifier', ['in' => ['current', 'default']]); + break; + } + + switch ($params['namespace']) { + case 'all': + $collection->addFieldToFilter('namespace', ['like' => '%']); + break; + default: + $collection->addFieldToFilter('namespace', ['eq' => $params['namespace']]); break; } @@ -109,7 +119,7 @@ public function execute() $message = __('The UI Bookmarks for user (%1) have been cleared successfully.', $user->getEmail()); if ($system) { - $message = __('Your UI Bookmarks were cleared successfully.'); + $message = __('Your UI Bookmarks have been cleared successfully.'); } } diff --git a/Plugin/Block/Adminhtml/User/Edit/Tab/ResetUiBookmarks.php b/Plugin/Block/Adminhtml/User/Edit/Tab/ResetUiBookmarks.php index d7ef31b..6258606 100644 --- a/Plugin/Block/Adminhtml/User/Edit/Tab/ResetUiBookmarks.php +++ b/Plugin/Block/Adminhtml/User/Edit/Tab/ResetUiBookmarks.php @@ -1,10 +1,17 @@ addFieldset('magenizr_resetuibookmarks', ['legend' => __('Bookmarks')]); $fieldset->addField( diff --git a/README.md b/README.md index 0e3e8d3..38622aa 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Reset Ui Bookmarks Reset UI Bookmarks becomes an invaluable tool while working daily in the admin panel, especially on Magento® instances with a large catalogue. The regular use of grid filters, applied sorting ( e.g `Sales > Orders or Catalog > Product` ) or other options provided by third party integrations can cause server time-outs ( depending on the filter combinations ) and make the grid tables unusable. With Reset UI Bookmarks any admin user can reset their filters back to default without having an agency support team involved. -![Magenizr ResetUiBookmarks - Backend](https://images2.imgbox.com/a3/7b/Nzdq7r9y_o.png) -![Magenizr ResetUiBookmarks - Backend](https://images2.imgbox.com/74/23/EprsvLRC_o.png) +![Magenizr ResetUiBookmarks - Backend](https://images2.imgbox.com/13/c1/IWMHIdfk_o.png) +![Magenizr ResetUiBookmarks - Backend](https://images2.imgbox.com/16/f6/Ed7BKH2o_o.png) ## Business Value Usually a technical person ( e.g developer ) is required to reset those filters back to default. This can be annoying for a client and create unnecessarily noise for a developer team. Here are the advantages of Reset UI Bookmarks. @@ -17,7 +17,7 @@ Usually a technical person ( e.g developer ) is required to reset those filters ## Installation (Composer) -1. Update your composer.json `composer require "magenizr/magento2-resetuibookmarks":"1.2.2" --no-update` +1. Update your composer.json `composer require "magenizr/magento2-resetuibookmarks":"1.3.0" --no-update` 2. Install dependencies and update your composer.lock `composer update magenizr/magento2-resetuibookmarks --lock` ``` @@ -25,7 +25,7 @@ Usually a technical person ( e.g developer ) is required to reset those filters Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - - Installing magenizr/magento2-resetuibookmarks (1.2.2): Downloading (100%) + - Installing magenizr/magento2-resetuibookmarks (1.3.0): Downloading (100%) Writing lock file Generating autoload files ``` @@ -38,13 +38,13 @@ php bin/magento module:enable Magenizr_ResetUiBookmarks ## Installation (Composer 2) -1. Update your composer.json `composer require "magenizr/magento2-resetuibookmarks":"1.2.2" --no-update` +1. Update your composer.json `composer require "magenizr/magento2-resetuibookmarks":"1.3.0" --no-update` 2. Use `composer update magenizr/magento2-resetuibookmarks --no-install` to update your composer.lock file. ``` Updating dependencies Lock file operations: 1 install, 1 update, 0 removals - - Locking magenizr/magento2-resetuibookmarks (1.2.2) + - Locking magenizr/magento2-resetuibookmarks (1.3.0) ``` 3. And then `composer install` to install the package. @@ -53,7 +53,7 @@ Lock file operations: 1 install, 1 update, 0 removals Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Package operations: 1 install, 0 update, 0 removals - - Installing magenizr/magento2-resetuibookmarks (1.2.2): Extracting archive + - Installing magenizr/magento2-resetuibookmarks (1.3.0): Extracting archive ``` 4. Enable the module and clear static content. @@ -64,7 +64,7 @@ php bin/magento module:enable Magenizr_ResetUiBookmarks ## Installation (Manually) 1. Download the code. -2. Extract the downloaded tar.gz file. Example: `tar -xzf Magenizr_ResetUiBookmarks_1.2.2.tar.gz`. +2. Extract the downloaded tar.gz file. Example: `tar -xzf Magenizr_ResetUiBookmarks_1.3.0.tar.gz`. 3. Copy the code into `./app/code/Magenizr/ResetUiBookmarks/`. 4. Enable the module and clear static content. @@ -77,20 +77,24 @@ php bin/magento setup:upgrade * A red button `Reset UI Bookmarks` within your `Account Settings` page as well as on `System > Permissions > All Users > {User} > User Info`. * Once a admin user hits the button `Reset UI Bookmarks`, it will clear the history of state of filters, column positions or applied sorting which are stored in the MySQL table `ui_bookmark`. * Choose between the options `All Bookmarks`, `Saved Filters Only` and `Keep Saved Filters` +* Select a specific namespace such as `Product Listing` or `Customer Listing`. The dropdown is generated based on namespaces stored in the `ui_bookmark` table. ## Usage Simply hit the button `Reset UI Bookmarks` to clear the bookmarks and wait for the confirmation `Your UI bookmarks were cleared successfully`. After that all filters and grid settings are set back to default. More details are available in the attached user guide. ## Support -If you experience any issues, don't hesitate to open an issue on [Github](https://github.com/magenizr/Magenizr_Debugger/issues). For a custom build, don't hesitate to contact us on [Magento Marketplace](https://marketplace.magento.com/partner/magenizr). +If you experience any issues, don't hesitate to open an issue on [Github](https://github.com/magenizr/Magenizr_Debugger/issues). For a custom build, don't hesitate to contact us via [https://account.magenizr.com](https://account.magenizr.com). ## Purchase -This module is available for free on [GitHub](https://github.com/magenizr). If you purchase the module on [Magenizr Shop](https://shop.magenizr.com) or [Magento Marketplace](https://marketplace.magento.com/partner/magenizr) we offer 60 days free support, 90 days warranty and 12 month free updates. +This module is available for free on [GitHub](https://github.com/magenizr). If you purchase this module on [https://account.magenizr.com](https://account.magenizr.com) offer support and regular updates. ## Contact Follow us on [GitHub](https://github.com/magenizr), [Twitter](https://twitter.com/magenizr) and [Facebook](https://www.facebook.com/magenizr). ## History +===== 1.3.0 ===== +* Namespace added so that you can clear bookmarks for a specific grid table + ===== 1.2.2 ===== * 2.4.6 compatibility check * Code cleanup diff --git a/composer.json b/composer.json index 0074169..f7bd157 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magenizr/magento2-resetuibookmarks", "description": "This Magento 2 module allows you to reset your UI bookmarks such as state of filters, column positions, grid sorting, pagination and so on.", "type": "magento2-module", - "version": "1.2.2", + "version": "1.3.0", "license": [ "OSL-3.0" ], diff --git a/view/adminhtml/layout/adminhtml_system_account_index.xml b/view/adminhtml/layout/adminhtml_system_account_index.xml index 693f72d..d5fb8b6 100644 --- a/view/adminhtml/layout/adminhtml_system_account_index.xml +++ b/view/adminhtml/layout/adminhtml_system_account_index.xml @@ -14,9 +14,9 @@