Skip to content

Commit

Permalink
Version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
magenizr committed Mar 25, 2022
1 parent e0b27bd commit e631e13
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 63 deletions.
51 changes: 40 additions & 11 deletions Controller/Adminhtml/Reset/Index.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,72 @@
<?php
declare(strict_types=1);

/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace Magenizr\ResetUiBookmarks\Controller\Adminhtml\Reset;

class Index extends \Magento\Backend\App\Action
{
/**
* @var \Magento\Ui\Api\Data\BookmarkInterfaceFactory
*/
protected $bookmarkFactory;

/**
* @var \Magento\Ui\Model\ResourceModel\BookmarkRepository
*/
protected $bookmarkRepository;

/**
* @var \Magento\Framework\Controller\ResultFactory
*/
protected $resultFactory;

/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $request;

/**
* Index constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Ui\Api\Data\BookmarkInterfaceFactory $bookmarkFactory
* @param \Magento\Ui\Model\ResourceModel\BookmarkRepository $bookmarkRepository
* @param \Magento\Framework\Controller\ResultFactory $resultFactory
* @param \Magento\Framework\App\RequestInterface $request
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\App\RequestInterface $request,
\Magento\Ui\Api\Data\BookmarkInterfaceFactory $bookmarkFactory,
\Magento\Ui\Model\ResourceModel\BookmarkRepository $bookmarkRepository
\Magento\Ui\Model\ResourceModel\BookmarkRepository $bookmarkRepository,
\Magento\Framework\Controller\ResultFactory $resultFactory,
\Magento\Framework\App\RequestInterface $request
) {
parent::__construct($context);
$this->request = $request;

$this->bookmarkFactory = $bookmarkFactory;
$this->bookmarkRepository = $bookmarkRepository;
$this->resultFactory = $resultFactory;
$this->request = $request;
}

/**
* Execute the controller.
*
* @return mixed
*/
public function execute()
{
$userId = $this->_auth->getUser()->getId();

$redirect = $this->resultRedirectFactory->create();
$redirect->setPath('adminhtml/system_account/index');

try {
$collection = $this->bookmarkFactory->create()->getCollection();
$collection->addFieldToFilter('user_id', ['eq' => $userId]);
Expand All @@ -55,13 +84,13 @@ public function execute()
$this->bookmarkRepository->deleteById($bookmark->getBookmarkId());
}

$this->messageManager->addSuccess(__('Your UI Bookmarks were cleared successfully.'));
$this->messageManager->addSuccessMessage(__('Your UI Bookmarks were cleared successfully.'));

return $this->_redirect('adminhtml/system_account/index');
return $redirect;
} catch (\Exception $e) {
$this->messageManager->addError(__('We were unable to submit your request. Please try again.'));
$this->messageManager->addErrorMessage(__('We were unable to submit your request. Please try again.'));

return $this->_redirect('adminhtml/system_account/index');
return $redirect;
}
}
}
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ 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.1.0" --no-update`
1. Update your composer.json `composer require "magenizr/magento2-resetuibookmarks":"1.1.1" --no-update`
2. Install dependencies and update your composer.lock `composer update --lock`

```
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing magenizr/magento2-resetuibookmarks (1.1.0): Downloading (100%)
- Installing magenizr/magento2-resetuibookmarks (1.1.1): Downloading (100%)
Writing lock file
Generating autoload files
```
Expand All @@ -38,7 +38,7 @@ php bin/magento setup:upgrade

## Installation (Manually)
1. Download the code.
2. Extract the downloaded tar.gz file. Example: `tar -xzf Magenizr_ResetUiBookmarks_1.1.0.tar.gz`.
2. Extract the downloaded tar.gz file. Example: `tar -xzf Magenizr_ResetUiBookmarks_1.1.1.tar.gz`.
3. Copy the code into `./app/code/Magenizr/ResetUiBookmarks/`.
4. Enable the module and clear static content.

Expand All @@ -65,6 +65,11 @@ This module is available for free on [GitHub](https://github.com/magenizr). If y
Follow us on [GitHub](https://github.com/magenizr), [Twitter](https://twitter.com/magenizr) and [Facebook](https://www.facebook.com/magenizr).

## History
===== 1.1.1 =====
* 2.4.x compatibility added
* Cleanup various files to follow coding standard (EQP, ECG)
* Remove framework requirement in composer.json

===== 1.1.0 =====
* Choose between the options `All Bookmarks`, `Saved Filters Only` and `Keep Saved Filters`

Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.0",
"version": "1.1.1",
"license": [
"OSL-3.0"
],
Expand All @@ -13,9 +13,6 @@
"homepage": "https://www.magenizr.com"
}
],
"require": {
"magento/framework": "^100|^101|^102|^103"
},
"repositories": [
{
"type": "composer",
Expand Down
8 changes: 3 additions & 5 deletions etc/adminhtml/routes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
<!--
/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="magenizr_resetuibookmarks" frontName="magenizr_resetuibookmarks">
<module name="Magenizr_ResetUiBookmarks" before="Magento_Backend" />
Expand Down
10 changes: 4 additions & 6 deletions etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
<!--
/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magenizr_ResetUiBookmarks" setup_version="1.1.0">
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magenizr_ResetUiBookmarks" setup_version="1.1.1">
<sequence>
<module name="Magento_Backend"/>
</sequence>
Expand Down
5 changes: 1 addition & 4 deletions registration.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php
/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down
15 changes: 8 additions & 7 deletions view/adminhtml/layout/adminhtml_system_account_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
<!--
/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Magenizr_ResetUiBookmarks::css/style.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="Magento\Backend\Block\System\Account\Edit" name="adminhtml.system.account.edit"/>
<block class="Magento\Framework\View\Element\Template" name="magenizr.resetuibookmarks.adminhtml.system.account.edit" template="Magenizr_ResetUiBookmarks::system/account/resetuibookmarks.phtml"/>
<block class="Magento\Backend\Block\System\Account\Edit"
name="adminhtml.system.account.edit"/>
<block class="Magento\Framework\View\Element\Template"
name="magenizr.resetuibookmarks.adminhtml.system.account.edit"
template="Magenizr_ResetUiBookmarks::system/account/resetuibookmarks.phtml"/>
</referenceContainer>
</body>
</page>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
<!--
/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" />
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" />
19 changes: 8 additions & 11 deletions view/adminhtml/templates/system/account/resetuibookmarks.phtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<!--
/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
Expand All @@ -13,29 +10,29 @@
<div class="divider"></div>
<fieldset class="fieldset admin__fieldset " id="magenizr_resetuibookmarks">
<legend class="admin__legend">
<span><?= $block->escapeHtml(__('Reset UI Bookmarks')) ?></span>
<span><?= $escaper->escapeHtml(__('Reset UI Bookmarks')) ?></span>
</legend><br>

<div class="admin__field">
<label class="label admin__field-label"></label>
<div class="admin__field-control control">

<form action="<?= $block->escapeUrl($block->getUrl('magenizr_resetuibookmarks/reset/index', ['_current' => true, '_use_rewrite' => true])) ?>" method="get">
<form action="<?= $escaper->escapeUrl($block->getUrl('magenizr_resetuibookmarks/reset/index', ['_current' => true, '_use_rewrite' => true])) ?>" method="get">

<button id="save" title="Save Account" type="submit" class="action-default scalable button-danger" role="button" aria-disabled="false">
<span><?= $block->escapeHtml(__('Reset UI Bookmarks')) ?></span>
<span><?= $escaper->escapeHtml(__('Reset UI Bookmarks')) ?></span>
</button>

<select id="identifier" name="identifier" title="Identifier" class="select select admin__control-select">
<option value="all"><?= $block->escapeHtml(__('All Bookmarks')) ?></option>
<option value="saved-only"><?= $block->escapeHtml(__('Saved Filters Only')) ?></option>
<option value="saved-exclude"><?= $block->escapeHtml(__('Keep Saved Filters')) ?></option>
<option value="saved-exclude"><?= $escaper->escapeHtml(__('Keep Saved Filters')) ?></option>
<option value="saved-only"><?= $escaper->escapeHtml(__('Saved Filters Only')) ?></option>
<option value="all"><?= $escaper->escapeHtml(__('All Bookmarks')) ?></option>
</select>

</form>

<span class="hint">
<?= $block->escapeHtml(__('This will reset your UI bookmarks such as state of filters, column positions, grid sorting, pagination and so on.')) ?>
<?= $escaper->escapeHtml(__('This will reset your UI bookmarks such as state of filters, column positions, grid sorting, pagination and so on.')) ?>
</span>
</div>
</div>
Expand Down
11 changes: 4 additions & 7 deletions view/adminhtml/web/css/style.less
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/**
* Magenizr ResetUiBookmarks
*
* @category Magenizr
* @package Magenizr_ResetUiBookmarks
* @copyright Copyright (c) 2018 - 2021 Magenizr (http://www.magenizr.com)
* @copyright Copyright (c) 2018 - 2022 Magenizr (https://www.magenizr.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
@divider: #e3e3e3;
@button-color: #ffffff;
@button-color: #fff;
@button-background-color: #eb5202;
@button-border-color: #eb5202;
@button-background-color-hover: #ba4000;
Expand All @@ -21,17 +18,17 @@
}

.divider {
height: 1px;
background: @divider;
height: 1px;
margin: 20px 0;
}

.button-danger {
background: @button-background-color;
border-color: @button-border-color;
color: @button-color;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
text-decoration: none;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);

&:hover, &:active, &:focus {
background: @button-background-color-hover;
Expand Down

0 comments on commit e631e13

Please sign in to comment.