From 6a413f2c88cfa7196def87a5d550c914f77bd410 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 3 Sep 2022 05:02:43 +0200 Subject: [PATCH 1/3] Set default width for admin grid datetime columns, ref #2239 --- app/code/core/Mage/Adminhtml/Block/Backup/Grid.php | 1 - .../Mage/Adminhtml/Block/Customer/Online/Grid.php | 2 -- .../core/Mage/Adminhtml/Block/Notification/Grid.php | 1 - app/code/core/Mage/Adminhtml/Block/Poll/Grid.php | 2 -- .../Block/Promo/Quote/Edit/Tab/Coupons/Grid.php | 1 - .../Block/Report/Refresh/Statistics/Grid.php | 1 - .../Block/Report/Tag/Customer/Detail/Grid.php | 1 - app/code/core/Mage/Adminhtml/Block/Review/Grid.php | 1 - .../core/Mage/Adminhtml/Block/Sales/Order/Grid.php | 1 - .../Mage/Adminhtml/Block/Sales/Transactions/Grid.php | 1 - app/code/core/Mage/Adminhtml/Block/Sitemap/Grid.php | 1 - .../System/Convert/Profile/Edit/Tab/History.php | 1 - app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | 12 ++++++++++++ .../core/Mage/Index/Block/Adminhtml/Process/Grid.php | 1 - .../Sales/Block/Adminhtml/Billing/Agreement/Grid.php | 2 -- .../Sales/Block/Adminhtml/Recurring/Profile/Grid.php | 2 -- .../Adminhtml/Recurring/Profile/View/Tab/Orders.php | 1 - 17 files changed, 12 insertions(+), 20 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php b/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php index b7d83e50964..46cda7afe02 100644 --- a/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php @@ -78,7 +78,6 @@ protected function _prepareColumns() 'header' => Mage::helper('backup')->__('Time'), 'index' => 'date_object', 'type' => 'datetime', - 'width' => 200 ]); $this->addColumn('display_name', [ diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php b/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php index 1d8f247ac6c..a908ec6de5b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php @@ -111,7 +111,6 @@ protected function _prepareColumns() $this->addColumn('session_start_time', [ 'header' => Mage::helper('customer')->__('Session Start Time'), 'align' => 'left', - 'width' => '200px', 'type' => 'datetime', 'default' => Mage::helper('customer')->__('n/a'), 'index' =>'first_visit_at' @@ -120,7 +119,6 @@ protected function _prepareColumns() $this->addColumn('last_activity', [ 'header' => Mage::helper('customer')->__('Last Activity'), 'align' => 'left', - 'width' => '200px', 'type' => 'datetime', 'default' => Mage::helper('customer')->__('n/a'), 'index' => 'last_visit_at' diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Grid.php b/app/code/core/Mage/Adminhtml/Block/Notification/Grid.php index 4692caa2a98..f1b4a2fdde4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Notification/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Notification/Grid.php @@ -66,7 +66,6 @@ protected function _prepareColumns() $this->addColumn('date_added', [ 'header' => Mage::helper('adminnotification')->__('Date Added'), 'index' => 'date_added', - 'width' => '150px', 'type' => 'datetime' ]); diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php b/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php index 457aa6a5f68..f6ea5fff031 100644 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php @@ -85,7 +85,6 @@ protected function _prepareColumns() $this->addColumn('date_posted', [ 'header' => Mage::helper('poll')->__('Date Posted'), 'align' => 'left', - 'width' => '120px', 'type' => 'datetime', 'index' => 'date_posted', 'format' => Mage::app()->getLocale()->getDateFormat() @@ -94,7 +93,6 @@ protected function _prepareColumns() $this->addColumn('date_closed', [ 'header' => Mage::helper('poll')->__('Date Closed'), 'align' => 'left', - 'width' => '120px', 'type' => 'datetime', 'default' => '--', 'index' => 'date_closed', diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php index 05c378c8a46..6af2b1204af 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php @@ -72,7 +72,6 @@ protected function _prepareColumns() 'index' => 'created_at', 'type' => 'datetime', 'align' => 'center', - 'width' => '160' ]); $this->addColumn('used', [ diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php index 63b6e0699cd..9d727d97ed7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php @@ -132,7 +132,6 @@ protected function _prepareColumns() 'header' => Mage::helper('reports')->__('Updated At'), 'index' => 'updated_at', 'type' => 'datetime', - 'width' => 200, 'default' => Mage::helper('reports')->__('undefined'), 'sortable' => false ]); diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php index a31192dda93..4a7156a806d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php @@ -81,7 +81,6 @@ protected function _prepareColumns() $this->addColumn('created_at', [ 'header' =>Mage::helper('reports')->__('Submitted On'), - 'width' => '140px', 'type' => 'datetime', 'index' => 'created_at' ]); diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Grid.php b/app/code/core/Mage/Adminhtml/Block/Review/Grid.php index 7dac93b6d4a..737ac6f1882 100644 --- a/app/code/core/Mage/Adminhtml/Block/Review/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Review/Grid.php @@ -81,7 +81,6 @@ protected function _prepareColumns() 'header' => Mage::helper('review')->__('Created On'), 'align' => 'left', 'type' => 'datetime', - 'width' => '100px', 'filter_index' => 'rt.created_at', 'index' => 'review_created_at', ]); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php index 4dfc0573a1d..44f1327e26c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php @@ -80,7 +80,6 @@ protected function _prepareColumns() 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', - 'width' => '150px', ]); $this->addColumn('billing_name', [ diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php index 24444931120..df5c57358d0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php @@ -120,7 +120,6 @@ protected function _prepareColumns() $this->addColumn('created_at', [ 'header' => Mage::helper('sales')->__('Created At'), 'index' => 'created_at', - 'width' => 1, 'type' => 'datetime', 'align' => 'center', 'default' => $this->__('N/A'), diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid.php index aebc842c34f..12e478f3426 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid.php @@ -69,7 +69,6 @@ protected function _prepareColumns() $this->addColumn('sitemap_time', [ 'header' => Mage::helper('sitemap')->__('Last Time Generated'), - 'width' => '150px', 'index' => 'sitemap_time', 'type' => 'datetime', ]); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/History.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/History.php index b66482420ae..bf72d7a0903 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/History.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/History.php @@ -68,7 +68,6 @@ protected function _prepareColumns() 'header' => Mage::helper('adminhtml')->__('Performed At'), 'type' => 'datetime', 'index' => 'performed_at', - 'width' => '150px', ]); $this->addColumn('firstname', [ diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index 73d6ab6e4b1..0adbe9205b9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -211,6 +211,15 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget */ protected $_emptyCellLabel = ''; + /** + * @var array[][] + */ + protected $defaultColumnSettings = [ + 'datetime' => [ + 'width' => 160 + ] + ]; + /** * Mage_Adminhtml_Block_Widget_Grid constructor. * @param array $attributes @@ -325,6 +334,9 @@ public function getCollection() public function addColumn($columnId, $column) { if (is_array($column)) { + if (isset($column['type'], $this->defaultColumnSettings[$column['type']])) { + $column += $this->defaultColumnSettings[$column['type']]; + } $this->_columns[$columnId] = $this->getLayout()->createBlock('adminhtml/widget_grid_column') ->setData($column) ->setGrid($this); diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php b/app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php index 7e917d5fbaa..5a0358d759d 100644 --- a/app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php +++ b/app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php @@ -144,7 +144,6 @@ protected function _prepareColumns() $this->addColumn('ended_at', [ 'header' => Mage::helper('index')->__('Updated At'), 'type' => 'datetime', - 'width' => '180', 'align' => 'left', 'index' => 'ended_at', 'frame_callback' => [$this, 'decorateDate'] diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php index 7645c7f9696..ee75b2eea2d 100644 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php +++ b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php @@ -139,7 +139,6 @@ protected function _prepareColumns() $this->addColumn('created_at', [ 'header' => Mage::helper('sales')->__('Created At'), 'index' => 'agreement_created_at', - 'width' => 1, 'type' => 'datetime', 'align' => 'center', 'default' => $this->__('N/A'), @@ -149,7 +148,6 @@ protected function _prepareColumns() $this->addColumn('updated_at', [ 'header' => Mage::helper('sales')->__('Updated At'), 'index' => 'agreement_updated_at', - 'width' => 1, 'type' => 'datetime', 'align' => 'center', 'default' => $this->__('N/A'), diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php index f3e9795bdc0..5f7c0e04c5e 100644 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php +++ b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php @@ -91,7 +91,6 @@ protected function _prepareColumns() 'index' => 'created_at', 'type' => 'datetime', 'html_decorators' => ['nobr'], - 'width' => 1, ]); $this->addColumn('updated_at', [ @@ -99,7 +98,6 @@ protected function _prepareColumns() 'index' => 'updated_at', 'type' => 'datetime', 'html_decorators' => ['nobr'], - 'width' => 1, ]); $methods = []; diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php index a44c4d238b0..07d7ea2747d 100644 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php +++ b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php @@ -83,7 +83,6 @@ protected function _prepareColumns() 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', - 'width' => '100px', ]); $this->addColumn('billing_name', [ From 8451f6fa925e7356c8009edc094180a9c9791978 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 3 Sep 2022 06:00:26 +0200 Subject: [PATCH 2/3] Set default width for admin grid date --- .../Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php | 1 - app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php | 2 -- app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php | 2 -- .../core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php | 2 -- app/code/core/Mage/Adminhtml/Block/System/Design/Grid.php | 2 -- app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | 7 +++++-- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php index 6439768505a..3c7eb4c5140 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php @@ -91,7 +91,6 @@ protected function _prepareColumns() 'header' => Mage::helper('customer')->__('Date Added'), 'index' => 'added_at', 'type' => 'date', - 'width' => '140px', ]); $this->addColumn('days', [ diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php index 44c307287e1..84ccd5b1d66 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php @@ -81,7 +81,6 @@ protected function _prepareColumns() $this->addColumn('from_date', [ 'header' => Mage::helper('catalogrule')->__('Date Start'), 'align' => 'left', - 'width' => '120px', 'type' => 'date', 'index' => 'from_date', ]); @@ -89,7 +88,6 @@ protected function _prepareColumns() $this->addColumn('to_date', [ 'header' => Mage::helper('catalogrule')->__('Date Expire'), 'align' => 'left', - 'width' => '120px', 'type' => 'date', 'default' => '--', 'index' => 'to_date', diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php index 4798ec045ab..8465da40a5f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php @@ -89,7 +89,6 @@ protected function _prepareColumns() $this->addColumn('from_date', [ 'header' => Mage::helper('salesrule')->__('Date Start'), 'align' => 'left', - 'width' => '120px', 'type' => 'date', 'index' => 'from_date', ]); @@ -97,7 +96,6 @@ protected function _prepareColumns() $this->addColumn('to_date', [ 'header' => Mage::helper('salesrule')->__('Date Expire'), 'align' => 'left', - 'width' => '120px', 'type' => 'date', 'default' => '--', 'index' => 'to_date', diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php b/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php index ebc5940cb4c..544d9516646 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php @@ -137,7 +137,6 @@ protected function _prepareColumns() $this->addColumn('from_date', [ 'header' => Mage::helper('salesrule')->__('Date Start'), 'align' => 'left', - 'width' => '120px', 'type' => 'date', 'index' => 'from_date', ]); @@ -145,7 +144,6 @@ protected function _prepareColumns() $this->addColumn('to_date', [ 'header' => Mage::helper('salesrule')->__('Date Expire'), 'align' => 'left', - 'width' => '120px', 'type' => 'date', 'default' => '--', 'index' => 'to_date', diff --git a/app/code/core/Mage/Adminhtml/Block/System/Design/Grid.php b/app/code/core/Mage/Adminhtml/Block/System/Design/Grid.php index 9281183db94..5f76274eaac 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Design/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Design/Grid.php @@ -80,7 +80,6 @@ protected function _prepareColumns() $this->addColumn('date_from', [ 'header' => Mage::helper('catalogrule')->__('Date From'), 'align' => 'left', - 'width' => '100px', 'type' => 'date', 'index' => 'date_from', ]); @@ -88,7 +87,6 @@ protected function _prepareColumns() $this->addColumn('date_to', [ 'header' => Mage::helper('catalogrule')->__('Date To'), 'align' => 'left', - 'width' => '100px', 'type' => 'date', 'index' => 'date_to', ]); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index 0adbe9205b9..a975081c507 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -215,9 +215,12 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget * @var array[][] */ protected $defaultColumnSettings = [ + 'date' => [ + 'width' => 140 + ], 'datetime' => [ - 'width' => 160 - ] + 'width' => 140 + ], ]; /** From 5f283a57edd4083be79b4c1c00f85b59231e5b9f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 6 Sep 2022 01:06:26 +0200 Subject: [PATCH 3/3] Made datetime columns bit wider --- app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index a975081c507..fc2c585243a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -219,7 +219,7 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget 'width' => 140 ], 'datetime' => [ - 'width' => 140 + 'width' => 160 ], ];