From aa286ef7d77d78cde1aaedb2eca5b3c07803366b Mon Sep 17 00:00:00 2001 From: Jonathon Menz Date: Mon, 27 Jul 2015 15:08:25 -0700 Subject: [PATCH] FIX Missing thumbnails and inconsistencies Made thumbnails and columns in File list Grid Fields more consistent (fixes #4409) --- admin/css/screen.css | 3 --- admin/scss/_style.scss | 12 ------------ css/GridField.css | 2 ++ forms/HtmlEditorField.php | 10 +++++++--- forms/UploadField.php | 11 ++++++++--- scss/GridField.scss | 13 +++++++++++++ 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/admin/css/screen.css b/admin/css/screen.css index 96388b161..e51607493 100644 --- a/admin/css/screen.css +++ b/admin/css/screen.css @@ -691,9 +691,6 @@ body.cms-dialog { overflow: auto; background: url("../images/textures/bg_cms_mai .htmleditorfield-linkform .ss-uploadfield .middleColumn { width: auto; } .htmleditorfield-mediaform .ss-gridfield .gridfield-button-delete { display: none; } -.htmleditorfield-mediaform .ss-gridfield table.ss-gridfield-table tbody td:first-child { padding: 0; text-align: center; } -.htmleditorfield-mediaform .ss-gridfield table.ss-gridfield-table tbody td:first-child img { max-height: 30px; } -.htmleditorfield-mediaform .ss-gridfield table.ss-gridfield-table tr td { padding: 4px; } .htmleditorfield-mediaform .htmleditorfield-from-web .ss-uploadfield .middleColumn, .htmleditorfield-mediaform .htmleditorfield-from-cms .ss-uploadfield .middleColumn { width: auto; background: none; border: none; margin-top: 13px; } .htmleditorfield-mediaform .htmleditorfield-from-cms .ss-uploadfield h4 { float: left; margin-top: 4px; margin-bottom: 0; } .htmleditorfield-mediaform .htmleditorfield-from-cms .ss-uploadfield .middleColumn { margin-top: 16px; margin-left: 184px; min-width: 0; clear: none; } diff --git a/admin/scss/_style.scss b/admin/scss/_style.scss index 3a4f776b4..a91f9458a 100644 --- a/admin/scss/_style.scss +++ b/admin/scss/_style.scss @@ -1533,18 +1533,6 @@ body.cms-dialog { // TODO Remove from PHP instead of hiding display: none; // delete action shouldn't be allowed here } - table.ss-gridfield-table { - tbody td:first-child { - padding: 0; - text-align: center; - img { - max-height: 30px; // same thumbnail size as uploadfield rows - } - } - tr td { - padding: $grid-x/2; // more compressed space - } - } } .htmleditorfield-from-web, .htmleditorfield-from-cms { diff --git a/css/GridField.css b/css/GridField.css index c671c0695..29f61b074 100644 --- a/css/GridField.css +++ b/css/GridField.css @@ -134,3 +134,5 @@ Used in side panels and action tabs .cms table.ss-gridfield-table tr.last td { border-bottom: 0 none; } .cms table.ss-gridfield-table td:first-child { border-left: 1px solid rgba(0, 0, 0, 0.1); } .cms table.ss-gridfield-table td:last-child { border-right: 1px solid rgba(0, 0, 0, 0.1); } +.cms table.ss-gridfield-table td.col-StripThumbnail { padding: 2px 4px; width: 32px; height: 32px; } +.cms table.ss-gridfield-table td.col-StripThumbnail img { width: 32px; height: 32px; display: block; } diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index e96b73db5..fad081a74 100644 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -311,7 +311,7 @@ class HtmlEditorField_Toolbar extends RequestHandler { new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), - new GridFieldPaginator(5), + new GridFieldPaginator(7), // TODO Shouldn't allow delete here, its too confusing with a "remove from editor view" action. // Remove once we can fit the search button in the last actual title column new GridFieldDeleteAction(), @@ -323,8 +323,12 @@ class HtmlEditorField_Toolbar extends RequestHandler { $fileField->setAttribute('data-multiselect', true); $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns'); $columns->setDisplayFields(array( - 'CMSThumbnail' => false, - 'Name' => _t('File.Name'), + 'StripThumbnail' => false, + 'Title' => _t('File.Title'), + 'Created' => singleton('File')->fieldLabel('Created'), + )); + $columns->setFieldCasting(array( + 'Created' => 'SS_Datetime->Nice' )); $numericLabelTmpl = '%d' diff --git a/forms/UploadField.php b/forms/UploadField.php index 17c92eb50..41485b489 100644 --- a/forms/UploadField.php +++ b/forms/UploadField.php @@ -1566,16 +1566,21 @@ class UploadField_SelectHandler extends RequestHandler { $config->addComponent(new GridFieldFilterHeader()); $config->addComponent($colsComponent = new GridFieldDataColumns()); $colsComponent->setDisplayFields(array( - 'Title' => singleton('File')->fieldLabel('Name'), - 'Filename' => singleton('File')->fieldLabel('Filename'), + 'StripThumbnail' => '', + 'Title' => singleton('File')->fieldLabel('Title'), + 'Created' => singleton('File')->fieldLabel('Created'), 'Size' => singleton('File')->fieldLabel('Size') )); + $colsComponent->setFieldCasting(array( + 'Created' => 'SS_Datetime->Nice' + )); + $config->addComponent(new GridFieldPaginator(11)); // If relation is to be autoset, we need to make sure we only list compatible objects. $baseClass = $this->parent->getRelationAutosetClass(); // Create the data source for the list of files within the current directory. - $files = DataList::create($baseClass); + $files = DataList::create($baseClass)->exclude('ClassName', 'Folder'); if($folderID) $files = $files->filter('ParentID', $folderID); $fileField = new GridField('Files', false, $files, $config); diff --git a/scss/GridField.scss b/scss/GridField.scss index 27bcc76f5..5d42fd607 100644 --- a/scss/GridField.scss +++ b/scss/GridField.scss @@ -674,5 +674,18 @@ $gf_grid_x: 16px; td:last-child{ border-right: 1px solid $gf_colour_border; } + + // Thumbnails e.g. in File admin, UploadField and HtmlEditorField file selection + td.col-StripThumbnail { + padding: 2px 4px; + width: 32px; + height: 32px; + + img { + width: 32px; + height: 32px; + display: block; + } + } } }