Skip to content

Commit 4a043b3

Browse files
Merge pull request #3384 from magento-qwerty/2.1.16-bugfixes-261018
Fixed issues: - MAGETWO-92724: Incorrect group actions behavior - MAGETWO-92180: Fixed incorrect behavior of attribute sets
2 parents c2b158f + e308f3a commit 4a043b3

File tree

4 files changed

+74
-4
lines changed
  • app/code/Magento
    • Catalog/view/adminhtml/templates/catalog/product/attribute/set
    • Customer
  • dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml

4 files changed

+74
-4
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/set/main.phtml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@
187187
for( j in config[i].children ) {
188188
if(config[i].children[j].id) {
189189
newNode = new Ext.tree.TreeNode(config[i].children[j]);
190+
191+
if (typeof newNode.ui.onTextChange === 'function') {
192+
newNode.ui.onTextChange = function (_3, _4, _5) {
193+
if (this.rendered) {
194+
this.textNode.innerText = _4;
195+
}
196+
}
197+
}
198+
190199
node.appendChild(newNode);
191200
newNode.addListener('click', editSet.unregister);
192201
}
@@ -199,6 +208,14 @@
199208
editSet = function() {
200209
return {
201210
register : function(node) {
211+
if (typeof node.ui.onTextChange === 'function') {
212+
node.ui.onTextChange = function (_3, _4, _5) {
213+
if (this.rendered) {
214+
this.textNode.innerText = _4;
215+
}
216+
}
217+
}
218+
202219
editSet.currentNode = node;
203220
},
204221

@@ -271,6 +288,15 @@
271288
allowDrop : true,
272289
allowDrag : true
273290
});
291+
292+
if (typeof newNode.ui.onTextChange === 'function') {
293+
newNode.ui.onTextChange = function (_3, _4, _5) {
294+
if (this.rendered) {
295+
this.textNode.innerText = _4;
296+
}
297+
}
298+
}
299+
274300
TreePanels.root.appendChild(newNode);
275301
newNode.addListener('beforemove', editSet.groupBeforeMove);
276302
newNode.addListener('beforeinsert', editSet.groupBeforeInsert);

app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public function __construct(
5757
* Update Save and Delete buttons. Remove Delete button if group can't be deleted.
5858
*
5959
* @return void
60+
* @throws \Magento\Framework\Exception\LocalizedException
61+
* @throws \Magento\Framework\Exception\NoSuchEntityException
6062
*/
6163
protected function _construct()
6264
{
@@ -68,6 +70,23 @@ protected function _construct()
6870

6971
$this->buttonList->update('save', 'label', __('Save Customer Group'));
7072
$this->buttonList->update('delete', 'label', __('Delete Customer Group'));
73+
$this->buttonList->update(
74+
'delete',
75+
'onclick',
76+
sprintf(
77+
"deleteConfirm('%s','%s', %s)",
78+
'Are you sure?',
79+
$this->getDeleteUrl(),
80+
json_encode(
81+
[
82+
'action' => '',
83+
'data' => [
84+
'form_key' => $this->getFormKey()
85+
]
86+
]
87+
)
88+
)
89+
);
7190

7291
$groupId = $this->coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
7392
if (!$groupId || $this->groupManagement->isReadonly($groupId)) {

app/code/Magento/Customer/Controller/Adminhtml/Group/Delete.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@
77
namespace Magento\Customer\Controller\Adminhtml\Group;
88

99
use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\Exception\NotFoundException;
1011

1112
class Delete extends \Magento\Customer\Controller\Adminhtml\Group
1213
{
1314
/**
1415
* Delete customer group.
1516
*
1617
* @return \Magento\Backend\Model\View\Result\Redirect
18+
* @throws NotFoundException
1719
*/
1820
public function execute()
1921
{
22+
if (!$this->getRequest()->isPost()) {
23+
throw new NotFoundException(__('Page not found'));
24+
}
25+
2026
$id = $this->getRequest()->getParam('id');
2127
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
2228
$resultRedirect = $this->resultRedirectFactory->create();

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\Message\MessageInterface;
99
use Magento\TestFramework\Helper\Bootstrap;
10+
use Magento\Framework\Data\Form\FormKey;
1011

1112
/**
1213
* @magentoAppArea adminhtml
@@ -80,6 +81,10 @@ public function testNewActionWithCustomerGroupDataInSession()
8081
*/
8182
public function testDeleteActionNoGroupId()
8283
{
84+
/** @var FormKey $formKey */
85+
$formKey = $this->_objectManager->get(FormKey::class);
86+
$this->getRequest()->setMethod('POST');
87+
$this->getRequest()->setParam('form_key', $formKey->getFormKey());
8388
$this->dispatch('backend/customer/group/delete');
8489
$this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL));
8590
}
@@ -90,9 +95,16 @@ public function testDeleteActionNoGroupId()
9095
public function testDeleteActionExistingGroup()
9196
{
9297
$groupId = $this->findGroupIdWithCode(self::CUSTOMER_GROUP_CODE);
93-
$this->getRequest()->setParam('id', $groupId);
98+
/** @var FormKey $formKey */
99+
$formKey = $this->_objectManager->get(FormKey::class);
100+
$this->getRequest()->setMethod('POST');
101+
$this->getRequest()->setParams(
102+
[
103+
'id' => $groupId,
104+
'form_key' => $formKey->getFormKey()
105+
]
106+
);
94107
$this->dispatch('backend/customer/group/delete');
95-
96108
/**
97109
* Check that success message is set
98110
*/
@@ -108,9 +120,16 @@ public function testDeleteActionExistingGroup()
108120
*/
109121
public function testDeleteActionNonExistingGroupId()
110122
{
111-
$this->getRequest()->setParam('id', 10000);
123+
/** @var FormKey $formKey */
124+
$formKey = $this->_objectManager->get(FormKey::class);
125+
$this->getRequest()->setMethod('POST');
126+
$this->getRequest()->setParams(
127+
[
128+
'id' => 10000,
129+
'form_key' => $formKey->getFormKey()
130+
]
131+
);
112132
$this->dispatch('backend/customer/group/delete');
113-
114133
/**
115134
* Check that error message is set
116135
*/

0 commit comments

Comments
 (0)