Skip to content

Commit

Permalink
Unified admin grid columns and added XML configuration (#4225)
Browse files Browse the repository at this point in the history
* Fixes price filter

* Fixes price filter (test)

* copyright

* Unified grid columns

- makes all "entity_id" grid columns searchable "from" "to"
- disallow/ignore non-numeric input on price/currency/range grid columns
- removed useless "'sortable' => true"

* Increased width

* Unified "edit" column

* Unified "action" column

* Unified "store" column

* Use config from XML

* Added test

* phpcs

* Update tests/unit/Mage/Adminhtml/Block/Widget/GridTest.php

Removed usseles line

* typo

* Unified "currency" column

* Unified "price" column

* Unified "currency" column

* Unified "currency" column

- added config helper

* Unified "number" column

- removed useless align right

* updated copyright dates

* cleanup

* Removed "from" "to" label to safe space

- add input placeholder

* Typo [skip ci]

* Re-added "from" "to" label to legacy theme

* Flush cache once if an old config is cached

* Hide placeholder in legacy theme

* Update app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php

Co-authored-by: Ng Kiat Siong <[email protected]>

* Update app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

Co-authored-by: Ng Kiat Siong <[email protected]>

---------

Co-authored-by: Ng Kiat Siong <[email protected]>
  • Loading branch information
sreichel and kiatng authored Oct 22, 2024
1 parent b5f6492 commit d34be82
Show file tree
Hide file tree
Showing 110 changed files with 495 additions and 513 deletions.
10 changes: 0 additions & 10 deletions .phpstan.dist.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,6 @@ parameters:
count: 1
path: app/code/core/Mage/Adminhtml/Block/Widget/Form.php

-
message: "#^Property Mage_Adminhtml_Block_Widget_Grid\\:\\:\\$defaultColumnSettings \\(array\\<array\\<array\\>\\>\\) does not accept default value of type array\\<string, array\\<string, int\\>\\>\\.$#"
count: 1
path: app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

-
message: "#^Parameter \\#1 \\$emptyLabel of method Mage_Directory_Model_Resource_Country_Collection\\:\\:toOptionArray\\(\\) expects string, false given\\.$#"
count: 1
Expand Down Expand Up @@ -3435,11 +3430,6 @@ parameters:
count: 1
path: app/code/core/Mage/Core/Model/Cache.php

-
message: "#^Method Mage_Core_Model_Config\\:\\:getNode\\(\\) should return Mage_Core_Model_Config_Element but returns Varien_Simplexml_Element\\|false\\.$#"
count: 1
path: app/code/core/Mage/Core/Model/Config.php

-
message: "#^Parameter \\#1 \\$options of method Mage_Core_Model_Config\\:\\:reinit\\(\\) expects array, Mage_Core_Model_Config_Options given\\.$#"
count: 1
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ protected function _prepareColumns()
'header' => Mage::helper('adminhtml')->__('User ID'),
'width' => 5,
'align' => 'left',
'sortable' => true,
'index' => 'user_id'
]);

Expand Down
3 changes: 1 addition & 2 deletions app/code/core/Mage/Adminhtml/Block/Api/User/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -43,7 +43,6 @@ protected function _prepareColumns()
'header' => Mage::helper('adminhtml')->__('ID'),
'width' => 5,
'align' => 'right',
'sortable' => true,
'index' => 'user_id'
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ protected function _prepareColumns()

$this->addColumn('entity_id', [
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => '60',
'index' => 'entity_id'
]);

Expand Down Expand Up @@ -171,10 +169,8 @@ protected function _prepareColumns()
]);

$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
'type' => 'currency',
'currency_code' => Mage_Directory_Helper_Data::getConfigCurrencyBase(),
]);

$this->addColumn('position', [
Expand All @@ -186,8 +182,6 @@ protected function _prepareColumns()
]);

$this->addColumn('action', [
'header' => Mage::helper('catalog')->__('Action'),
'width' => '50px',
'type' => 'action',
'getter' => 'getId',
'actions' => [
Expand All @@ -205,8 +199,6 @@ protected function _prepareColumns()
],
],
],
'filter' => false,
'sortable' => false,
'index' => 'stores',
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -46,7 +46,6 @@ protected function _prepareColumns()

$this->addColumnAfter('is_visible', [
'header' => Mage::helper('catalog')->__('Visible'),
'sortable' => true,
'index' => 'is_visible_on_front',
'type' => 'options',
'options' => [
Expand All @@ -58,7 +57,6 @@ protected function _prepareColumns()

$this->addColumnAfter('is_global', [
'header' => Mage::helper('catalog')->__('Scope'),
'sortable' => true,
'index' => 'is_global',
'type' => 'options',
'options' => [
Expand All @@ -71,7 +69,6 @@ protected function _prepareColumns()

$this->addColumnAfter('is_searchable', [
'header' => Mage::helper('catalog')->__('Searchable'),
'sortable' => true,
'index' => 'is_searchable',
'type' => 'options',
'options' => [
Expand All @@ -83,7 +80,6 @@ protected function _prepareColumns()

$this->addColumnAfter('is_filterable', [
'header' => Mage::helper('catalog')->__('Use in Layered Navigation'),
'sortable' => true,
'index' => 'is_filterable',
'type' => 'options',
'options' => [
Expand All @@ -96,7 +92,6 @@ protected function _prepareColumns()

$this->addColumnAfter('is_comparable', [
'header' => Mage::helper('catalog')->__('Comparable'),
'sortable' => true,
'index' => 'is_comparable',
'type' => 'options',
'options' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -49,7 +49,6 @@ protected function _prepareColumns()
$this->addColumn('set_name', [
'header' => Mage::helper('catalog')->__('Set Name'),
'align' => 'left',
'sortable' => true,
'index' => 'attribute_set_name',
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -72,11 +72,9 @@ protected function _prepareColumns()
]);

$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'index' => 'price',
'type' => 'currency',
'currency_code'
=> Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE)
=> Mage_Directory_Helper_Data::getConfigCurrencyBase(),
]);

$this->addColumn('add_date', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -128,8 +128,6 @@ protected function _prepareColumns()

$this->addColumn('entity_id', [
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => 60,
'index' => 'entity_id'
]);

Expand Down Expand Up @@ -182,10 +180,8 @@ protected function _prepareColumns()
]);

$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
'currency_code' => Mage_Directory_Helper_Data::getConfigCurrencyBase(),
]);

$this->addColumn('position', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -130,8 +130,6 @@ protected function _prepareColumns()

$this->addColumn('entity_id', [
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => 60,
'index' => 'entity_id'
]);

Expand Down Expand Up @@ -184,10 +182,8 @@ protected function _prepareColumns()
]);

$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
'currency_code' => Mage_Directory_Helper_Data::getConfigCurrencyBase(),
]);

$this->addColumn('position', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ protected function _prepareColumns()

$this->addColumn('entity_id', [
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => '60px',
'index' => 'entity_id'
]);
$this->addColumn('name', [
Expand Down Expand Up @@ -230,10 +228,8 @@ protected function _prepareColumns()
]);

$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
'currency_code' => Mage_Directory_Helper_Data::getConfigCurrencyBase(),
]);

$this->addColumn('is_saleable', [
Expand All @@ -257,7 +253,6 @@ protected function _prepareColumns()
$this->addColumn(
'action',
[
'header' => Mage::helper('catalog')->__('Action'),
'type' => 'action',
'getter' => 'getId',
'actions' => [
Expand All @@ -268,8 +263,6 @@ protected function _prepareColumns()
'onclick' => 'superProduct.createPopup(this.href);return false;'
]
],
'filter' => false,
'sortable' => false
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ protected function _prepareColumns()

$this->addColumn('entity_id', [
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => '60px',
'index' => 'entity_id'
]);
$this->addColumn('name', [
Expand All @@ -145,10 +143,8 @@ protected function _prepareColumns()
'index' => 'sku'
]);
$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
'currency_code' => Mage_Directory_Helper_Data::getConfigCurrencyBase(),
]);

$this->addColumn('qty', [
Expand All @@ -157,7 +153,6 @@ protected function _prepareColumns()
'type' => 'number',
'validate_class' => 'validate-number',
'index' => 'qty',
'width' => '1',
'editable' => true,
'filter_condition_callback' => [$this, '_addLinkModelFilterCallback']
]);
Expand All @@ -175,8 +170,6 @@ protected function _prepareColumns()
]);

$this->addColumn('action', [
'header' => Mage::helper('catalog')->__('Action'),
'width' => '50px',
'type' => 'action',
'getter' => 'getId',
'actions' => [
Expand All @@ -194,8 +187,6 @@ protected function _prepareColumns()
],
],
],
'filter' => false,
'sortable' => false,
'index' => 'stores',
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -56,7 +56,6 @@ protected function _prepareColumns()
$this->addColumn('popularity', [
'header' => Mage::helper('catalog')->__('# of Use'),
'width' => '50px',
'align' => 'right',
'index' => 'popularity',
'type' => 'number',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org)
* @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -130,8 +130,6 @@ protected function _prepareColumns()

$this->addColumn('entity_id', [
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => 60,
'index' => 'entity_id'
]);
$this->addColumn('name', [
Expand Down Expand Up @@ -183,10 +181,8 @@ protected function _prepareColumns()
]);

$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
'currency_code' => Mage_Directory_Helper_Data::getConfigCurrencyBase(),
]);

$this->addColumn('position', [
Expand Down
Loading

0 comments on commit d34be82

Please sign in to comment.