Skip to content

Commit b3b4ed0

Browse files
sreichelCopilot
andauthored
Unified admin buttons (#4982)
* added tests for button classes * cypress: test for button classes * updated buttons * Update app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * naming * refactor * missing config * Update cypress/support/openmage/_utils/test.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update cypress/support/openmage/backend/system/account.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * update * refactor * Update cypress/support/openmage/backend/customer/group.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update cypress/support/openmage/_utils/test.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update cypress/support/openmage/backend/system/email.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update cypress/support/openmage/backend/catalog/sitemap.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix tests --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b439e2f commit b3b4ed0

File tree

85 files changed

+1005
-975
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1005
-975
lines changed

app/code/core/Mage/Adminhtml/Block/Api/Buttons.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ protected function _prepareLayout()
3636
->setData([
3737
'label' => Mage::helper('adminhtml')->__('Reset'),
3838
'onclick' => 'window.location.reload()',
39+
'class' => 'reset',
3940
]),
4041
);
4142

@@ -63,25 +64,37 @@ protected function _prepareLayout()
6364
return parent::_prepareLayout();
6465
}
6566

67+
/**
68+
* @return string
69+
*/
6670
public function getBackButtonHtml()
6771
{
6872
return $this->getChildHtml('backButton');
6973
}
7074

75+
/**
76+
* @return string
77+
*/
7178
public function getResetButtonHtml()
7279
{
7380
return $this->getChildHtml('resetButton');
7481
}
7582

83+
/**
84+
* @return string
85+
*/
7686
public function getSaveButtonHtml()
7787
{
7888
return $this->getChildHtml('saveButton');
7989
}
8090

91+
/**
92+
* @return string
93+
*/
8194
public function getDeleteButtonHtml()
8295
{
8396
if ((int) $this->getRequest()->getParam('rid') == 0) {
84-
return;
97+
return '';
8598
}
8699

87100
return $this->getChildHtml('deleteButton');

app/code/core/Mage/Adminhtml/Block/Cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct()
2525
$this->_addButton('flush_magento', [
2626
'label' => Mage::helper('core')->__('Flush & Apply Updates'),
2727
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getFlushSystemUrl()),
28-
'class' => 'delete',
28+
'class' => 'delete cache',
2929
]);
3030

3131
$this->_addButton('flush_system', [
@@ -34,7 +34,7 @@ public function __construct()
3434
$this->getFlushStorageUrl(),
3535
Mage::helper('core')->__('Cache storage may contain additional data. Are you sure that you want flush it?'),
3636
),
37-
'class' => 'delete',
37+
'class' => 'delete flush',
3838
]);
3939
}
4040

app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public function __construct()
2727
$this->setTemplate('catalog/category/edit/form.phtml');
2828
}
2929

30+
/**
31+
* Prepare Global Layout
32+
*
33+
* @return $this
34+
*/
3035
protected function _prepareLayout()
3136
{
3237
$category = $this->getCategory();
@@ -43,9 +48,9 @@ protected function _prepareLayout()
4348
'save_button',
4449
$this->getLayout()->createBlock('adminhtml/widget_button')
4550
->setData([
46-
'label' => Mage::helper('catalog')->__('Save Category'),
51+
'label' => Mage::helper('catalog')->__('Save'),
4752
'onclick' => "categorySubmit('" . $this->getSaveUrl() . "', true)",
48-
'class' => 'save',
53+
'class' => 'save',
4954
]),
5055
);
5156
}
@@ -56,9 +61,9 @@ protected function _prepareLayout()
5661
'delete_button',
5762
$this->getLayout()->createBlock('adminhtml/widget_button')
5863
->setData([
59-
'label' => Mage::helper('catalog')->__('Delete Category'),
64+
'label' => Mage::helper('catalog')->__('Delete'),
6065
'onclick' => "categoryDelete('" . $this->getUrl('*/*/delete', ['_current' => true]) . "', true, {$categoryId})",
61-
'class' => 'delete',
66+
'class' => 'delete',
6267
]),
6368
);
6469
}
@@ -72,13 +77,18 @@ protected function _prepareLayout()
7277
->setData([
7378
'label' => Mage::helper('catalog')->__('Reset'),
7479
'onclick' => "categoryReset('" . $this->getUrl($resetPath, ['_current' => true]) . "',true)",
80+
'class' => 'reset',
7581
]),
7682
);
7783
}
7884

7985
return parent::_prepareLayout();
8086
}
8187

88+
/**
89+
* @return string
90+
* @throws Mage_Core_Model_Store_Exception
91+
*/
8292
public function getStoreConfigurationUrl()
8393
{
8494
$storeId = (int) $this->getRequest()->getParam('store');
@@ -93,11 +103,17 @@ public function getStoreConfigurationUrl()
93103
return $this->getUrl('*/system_store', $params);
94104
}
95105

106+
/**
107+
* @return string
108+
*/
96109
public function getDeleteButtonHtml()
97110
{
98111
return $this->getChildHtml('delete_button');
99112
}
100113

114+
/**
115+
* @return string
116+
*/
101117
public function getSaveButtonHtml()
102118
{
103119
if ($this->hasStoreRootCategory()) {
@@ -107,6 +123,9 @@ public function getSaveButtonHtml()
107123
return '';
108124
}
109125

126+
/**
127+
* @return string
128+
*/
110129
public function getResetButtonHtml()
111130
{
112131
if ($this->hasStoreRootCategory()) {

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct()
3838
[
3939
'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
4040
'onclick' => 'saveAndContinueEdit()',
41-
'class' => 'save',
41+
'class' => 'save continue',
4242
],
4343
100,
4444
);

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ protected function _prepareLayout()
7373
$this->getLayout()->createBlock('adminhtml/widget_button')->setData([
7474
'label' => Mage::helper('catalog')->__('Reset'),
7575
'onclick' => 'window.location.reload()',
76+
'class' => 'reset',
7677
]),
7778
);
7879

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* @package Mage_Adminhtml
88
*/
99

10-
1110
/**
1211
* Customer edit block
1312
*
@@ -66,6 +65,7 @@ protected function _prepareLayout()
6665
->setData([
6766
'label' => Mage::helper('catalog')->__('Reset'),
6867
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/*', ['_current' => true])),
68+
'class' => 'reset',
6969
]),
7070
);
7171

@@ -88,7 +88,7 @@ protected function _prepareLayout()
8888
->setData([
8989
'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
9090
'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl()),
91-
'class' => 'save',
91+
'class' => 'save continue',
9292
]),
9393
);
9494
}
@@ -109,11 +109,11 @@ protected function _prepareLayout()
109109
$this->setChild(
110110
'duplicate_button',
111111
$this->getLayout()->createBlock('adminhtml/widget_button')
112-
->setData([
113-
'label' => Mage::helper('catalog')->__('Duplicate'),
114-
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl()),
115-
'class' => 'add',
116-
]),
112+
->setData([
113+
'label' => Mage::helper('catalog')->__('Duplicate'),
114+
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl()),
115+
'class' => 'add duplicate',
116+
]),
117117
);
118118
}
119119
}

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected function _prepareLayout()
3737
->setData([
3838
'label' => Mage::helper('catalog')->__('Reset'),
3939
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/*', ['_current' => true])),
40+
'class' => 'reset',
4041
]),
4142
);
4243

app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ public function __construct()
1818
{
1919
$this->_objectId = 'id';
2020
$this->_controller = 'catalog_search';
21-
2221
parent::__construct();
23-
24-
$this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Search'));
25-
$this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Search'));
2622
}
2723

2824
/**

app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ public function __construct()
2020
$this->_controller = 'cms_block';
2121

2222
parent::__construct();
23+
}
2324

24-
$this->_updateButton('save', 'label', Mage::helper('cms')->__('Save Block'));
25-
$this->_updateButton('delete', 'label', Mage::helper('cms')->__('Delete Block'));
26-
25+
/**
26+
* @inheritDoc
27+
*/
28+
protected function _prepareLayout()
29+
{
2730
$this->_addButton('saveandcontinue', [
2831
'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
2932
'onclick' => 'saveAndContinueEdit()',
30-
'class' => 'save',
33+
'class' => 'save continue',
3134
], -100);
3235

3336
$this->_formScripts[] = "
@@ -39,6 +42,8 @@ function saveAndContinueEdit(){
3942
editForm.submit($('edit_form').action+'back/edit/');
4043
}
4144
";
45+
46+
return parent::_prepareLayout();
4247
}
4348

4449
/**

app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,16 @@ public function __construct()
2626
parent::__construct();
2727

2828
if ($this->_isAllowedAction('save')) {
29-
$this->_updateButton('save', 'label', Mage::helper('cms')->__('Save Page'));
3029
$this->_addButton('saveandcontinue', [
3130
'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
3231
'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->_getSaveAndContinueUrl()),
33-
'class' => 'save',
32+
'class' => 'save continue',
3433
], -100);
3534
} else {
3635
$this->_removeButton('save');
3736
}
3837

39-
if ($this->_isAllowedAction('delete')) {
40-
$this->_updateButton('delete', 'label', Mage::helper('cms')->__('Delete Page'));
41-
} else {
38+
if (!$this->_isAllowedAction('delete')) {
4239
$this->_removeButton('delete');
4340
}
4441
}

0 commit comments

Comments
 (0)