Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default width for grid datetime columns, ref #2239 #2544

Merged
merged 3 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Backup/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ protected function _prepareColumns()
'header' => Mage::helper('backup')->__('Time'),
'index' => 'date_object',
'type' => 'datetime',
'width' => 200
]);

$this->addColumn('display_name', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ protected function _prepareColumns()
'header' => Mage::helper('customer')->__('Date Added'),
'index' => 'added_at',
'type' => 'date',
'width' => '140px',
]);

$this->addColumn('days', [
Expand Down
2 changes: 0 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Notification/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ protected function _prepareColumns()
$this->addColumn('date_added', [
'header' => Mage::helper('adminnotification')->__('Date Added'),
'index' => 'date_added',
'width' => '150px',
'type' => 'datetime'
]);

Expand Down
2 changes: 0 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Poll/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,13 @@ protected function _prepareColumns()
$this->addColumn('from_date', [
'header' => Mage::helper('catalogrule')->__('Date Start'),
'align' => 'left',
'width' => '120px',
'type' => 'date',
'index' => 'from_date',
]);

$this->addColumn('to_date', [
'header' => Mage::helper('catalogrule')->__('Date Expire'),
'align' => 'left',
'width' => '120px',
'type' => 'date',
'default' => '--',
'index' => 'to_date',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ protected function _prepareColumns()
'index' => 'created_at',
'type' => 'datetime',
'align' => 'center',
'width' => '160'
]);

$this->addColumn('used', [
Expand Down
2 changes: 0 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,13 @@ protected function _prepareColumns()
$this->addColumn('from_date', [
'header' => Mage::helper('salesrule')->__('Date Start'),
'align' => 'left',
'width' => '120px',
'type' => 'date',
'index' => 'from_date',
]);

$this->addColumn('to_date', [
'header' => Mage::helper('salesrule')->__('Date Expire'),
'align' => 'left',
'width' => '120px',
'type' => 'date',
'default' => '--',
'index' => 'to_date',
Expand Down
2 changes: 0 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,13 @@ protected function _prepareColumns()
$this->addColumn('from_date', [
'header' => Mage::helper('salesrule')->__('Date Start'),
'align' => 'left',
'width' => '120px',
'type' => 'date',
'index' => 'from_date',
]);

$this->addColumn('to_date', [
'header' => Mage::helper('salesrule')->__('Date Expire'),
'align' => 'left',
'width' => '120px',
'type' => 'date',
'default' => '--',
'index' => 'to_date',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ protected function _prepareColumns()

$this->addColumn('created_at', [
'header' =>Mage::helper('reports')->__('Submitted On'),
'width' => '140px',
'type' => 'datetime',
'index' => 'created_at'
]);
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Review/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ protected function _prepareColumns()
'header' => Mage::helper('sales')->__('Purchased On'),
'index' => 'created_at',
'type' => 'datetime',
'width' => '150px',
]);

$this->addColumn('billing_name', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Sitemap/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ protected function _prepareColumns()
'header' => Mage::helper('adminhtml')->__('Performed At'),
'type' => 'datetime',
'index' => 'performed_at',
'width' => '150px',
]);

$this->addColumn('firstname', [
Expand Down
2 changes: 0 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/System/Design/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,13 @@ protected function _prepareColumns()
$this->addColumn('date_from', [
'header' => Mage::helper('catalogrule')->__('Date From'),
'align' => 'left',
'width' => '100px',
'type' => 'date',
'index' => 'date_from',
]);

$this->addColumn('date_to', [
'header' => Mage::helper('catalogrule')->__('Date To'),
'align' => 'left',
'width' => '100px',
'type' => 'date',
'index' => 'date_to',
]);
Expand Down
15 changes: 15 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget
*/
protected $_emptyCellLabel = '';

/**
* @var array[][]
*/
protected $defaultColumnSettings = [
'date' => [
'width' => 140
],
'datetime' => [
'width' => 160
],
];

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column looks like this with 140:

screenshot_before

And it looks like this with 150:

screenshot_after

As can be seen at the value of 150, it is on a single line. I propose changing the value from 140 to 150.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 150 enought when the hour is like “22.00”? Cause there’s gonna be ine more digit.

now that @sreichel set it to 160 i think its ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

160 seems to cover all scenarios. If not we can create a new PR later. We should implement default values for other types (TBD).

* Mage_Adminhtml_Block_Widget_Grid constructor.
* @param array $attributes
Expand Down Expand Up @@ -325,6 +337,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);
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ protected function _prepareColumns()
'index' => 'created_at',
'type' => 'datetime',
'html_decorators' => ['nobr'],
'width' => 1,
]);

$this->addColumn('updated_at', [
'header' => $profile->getFieldLabel('updated_at'),
'index' => 'updated_at',
'type' => 'datetime',
'html_decorators' => ['nobr'],
'width' => 1,
]);

$methods = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected function _prepareColumns()
'header' => Mage::helper('sales')->__('Purchased On'),
'index' => 'created_at',
'type' => 'datetime',
'width' => '100px',
]);

$this->addColumn('billing_name', [
Expand Down