From cc3385b9f8855d0ee18590aae0305a26ada74ef1 Mon Sep 17 00:00:00 2001 From: David Craig Date: Tue, 16 Jun 2015 10:49:19 +1200 Subject: [PATCH] Move filters from panel to header - The filters panel has been removed in favour of a search panel in the header - Multi-select updated - Renamed to Bulk actions - Styles updated - Added placeholder text / removed redundant option - Now appears in SiteTree view too --- code/controllers/AssetAdmin.php | 26 +++-- code/controllers/CMSMain.php | 12 +-- css/screen.css | 16 +++- javascript/CMSMain.js | 95 +++++++++++++++++++ javascript/CMSPageHistoryController.js | 4 +- lang/en.yml | 16 ++-- scss/_AssetAdmin.scss | 10 +- scss/_CMSMain.scss | 57 ++++++++--- templates/Includes/AssetAdmin_Content.ss | 32 ++++--- templates/Includes/AssetAdmin_Tools.ss | 12 +-- templates/Includes/CMSMain_ListView.ss | 4 +- templates/Includes/CMSMain_TreeView.ss | 9 +- .../Includes/CMSPagesController_Content.ss | 4 +- .../CMSPagesController_ContentToolActions.ss | 25 +++-- .../CMSPagesController_ContentToolbar.ss | 8 -- .../Includes/CMSPagesController_Tools.ss | 12 +-- tests/behat/features/manage-files.feature | 12 +-- .../behat/features/search-for-a-page.feature | 53 ++++++----- 18 files changed, 271 insertions(+), 136 deletions(-) delete mode 100644 templates/Includes/CMSPagesController_ContentToolbar.ss diff --git a/code/controllers/AssetAdmin.php b/code/controllers/AssetAdmin.php index 40b4f30b..1b563383 100644 --- a/code/controllers/AssetAdmin.php +++ b/code/controllers/AssetAdmin.php @@ -308,7 +308,7 @@ JS $fields->setForm($form); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); // TODO Can't merge $FormAttributes in template at the moment - $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses()); + $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses()); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); @@ -360,21 +360,17 @@ JS foreach($context->getFilters() as $filter) $filter->setFullName(sprintf('q[%s]', $filter->getFullName())); // Customize fields - $context->addField( - new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4) - ); - $context->addField( - DateField::create( - 'q[CreatedFrom]', - _t('CMSSearch.FILTERDATEFROM', 'From') - )->setConfig('showcalendar', true) - ); - $context->addField( - DateField::create( - 'q[CreatedTo]', - _t('CMSSearch.FILTERDATETO', 'To') - )->setConfig('showcalendar', true) + $dateHeader = HeaderField::create('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4); + $dateFrom = DateField::create('q[CreatedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From')) + ->setConfig('showcalendar', true); + $dateTo = DateField::create('q[CreatedTo]',_t('CMSSearch.FILTERDATETO', 'To')) + ->setConfig('showcalendar', true); + $dateGroup = FieldGroup::create( + $dateHeader, + $dateFrom, + $dateTo ); + $context->addField($dateGroup); $appCategories = array( 'image' => _t('AssetAdmin.AppCategoryImage', 'Image'), 'audio' => _t('AssetAdmin.AppCategoryAudio', 'Audio'), diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 817bf398..c7ee5a9b 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -314,8 +314,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr */ public function SearchForm() { // Create the fields - $content = new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Content')); - $dateHeader = new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4); + $content = new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Search')); + $dateHeader = new HeaderField('q[Date]', _t('CMSSearch.PAGEFILTERDATEHEADING', 'Last edited'), 4); $dateFrom = new DateField( 'q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From') @@ -328,12 +328,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $dateTo->setConfig('showcalendar', true); $pageFilter = new DropdownField( 'q[FilterClass]', - _t('CMSMain.PAGES', 'Pages'), + _t('CMSMain.PAGES', 'Page status'), CMSSiteTreeFilter::get_all_filters() ); $pageClasses = new DropdownField( 'q[ClassName]', - _t('CMSMain.PAGETYPEOPT', 'Page Type', 'Dropdown for limiting search to a page type'), + _t('CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'), $this->getPageTypes() ); $pageClasses->setEmptyString(_t('CMSMain.PAGETYPEANYOPT','Any')); @@ -356,9 +356,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr // Create the Search and Reset action $actions = new FieldList( - FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Apply Filter')) + FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Search')) ->addExtraClass('ss-ui-action-constructive'), - Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear Filter')) + Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear')) ); // Use + + + <% end_with %> <% end_if %> -
+
$Top.Tools - $forTemplate + +
+ $forTemplate +
<% end_with %> -
\ No newline at end of file + diff --git a/templates/Includes/AssetAdmin_Tools.ss b/templates/Includes/AssetAdmin_Tools.ss index 74b8b47b..596a6530 100644 --- a/templates/Includes/AssetAdmin_Tools.ss +++ b/templates/Includes/AssetAdmin_Tools.ss @@ -1,9 +1,3 @@ - \ No newline at end of file +
+ $SearchForm +
diff --git a/templates/Includes/CMSMain_ListView.ss b/templates/Includes/CMSMain_ListView.ss index 65a18c42..4c59220f 100644 --- a/templates/Includes/CMSMain_ListView.ss +++ b/templates/Includes/CMSMain_ListView.ss @@ -1,6 +1,4 @@ -
- <% include CMSPagesController_ContentToolActions %> -
+<% include CMSPagesController_ContentToolActions %>
$AddForm diff --git a/templates/Includes/CMSMain_TreeView.ss b/templates/Includes/CMSMain_TreeView.ss index 3621dd91..b1ed362c 100644 --- a/templates/Includes/CMSMain_TreeView.ss +++ b/templates/Includes/CMSMain_TreeView.ss @@ -1,7 +1,4 @@ -
- <% include CMSPagesController_ContentToolActions %> - <% include CMSPagesController_ContentToolbar %> -
+<% include CMSPagesController_ContentToolActions View='Tree' %>
$AddForm @@ -12,9 +9,9 @@ $ExtraTreeTools
<% if $TreeIsFiltered %>
- <% _t('CMSMain.TreeFiltered', 'Filtered tree.') %> + <% _t('CMSMain.TreeFiltered', 'Search results.') %> - <% _t('CMSMain.TreeFilteredClear', 'Clear filter') %> + <% _t('CMSMain.TreeFilteredClear', 'Clear') %>
<% end_if %> diff --git a/templates/Includes/CMSPagesController_Content.ss b/templates/Includes/CMSPagesController_Content.ss index 00e76fe3..cedf137b 100644 --- a/templates/Includes/CMSPagesController_Content.ss +++ b/templates/Includes/CMSPagesController_Content.ss @@ -6,6 +6,7 @@
- $Tools -
+ $Tools
<%-- Lazy-loaded via ajax --%> diff --git a/templates/Includes/CMSPagesController_ContentToolActions.ss b/templates/Includes/CMSPagesController_ContentToolActions.ss index b3b8b6b4..ccf576e9 100644 --- a/templates/Includes/CMSPagesController_ContentToolActions.ss +++ b/templates/Includes/CMSPagesController_ContentToolActions.ss @@ -1,6 +1,19 @@ -
- <% _t('CMSMain.AddNewButton', 'Add new') %> - -
\ No newline at end of file +
+
+ <% _t('CMSMain.AddNewButton', 'Add new') %> + + <% if $View == 'Tree' %> + + <% end_if %> +
+ +
+ <% if $View == 'Tree' %> +
+ $BatchActionsForm +
+ <% end_if %> +
+
diff --git a/templates/Includes/CMSPagesController_ContentToolbar.ss b/templates/Includes/CMSPagesController_ContentToolbar.ss deleted file mode 100644 index e99bd7ff..00000000 --- a/templates/Includes/CMSPagesController_ContentToolbar.ss +++ /dev/null @@ -1,8 +0,0 @@ -
- - - $BatchActionsForm -
diff --git a/templates/Includes/CMSPagesController_Tools.ss b/templates/Includes/CMSPagesController_Tools.ss index d2b0accd..51ba1dc1 100644 --- a/templates/Includes/CMSPagesController_Tools.ss +++ b/templates/Includes/CMSPagesController_Tools.ss @@ -1,9 +1,3 @@ - \ No newline at end of file +
+ $SearchForm +
diff --git a/tests/behat/features/manage-files.feature b/tests/behat/features/manage-files.feature index 3d7001c1..b101d1a7 100644 --- a/tests/behat/features/manage-files.feature +++ b/tests/behat/features/manage-files.feature @@ -62,24 +62,24 @@ Feature: Manage files Then I should see "png," Scenario: I can filter the files list view using name - Given I expand the "Filter" CMS Panel + Given I expand the content filters And I fill in "Name" with "file1" - And I press the "Apply Filter" button + And I press the "Search" button Then the "Files" table should contain "file1" And the "Files" table should not contain "file2" Scenario: I can filter the files list view using filetype Given a "file" "assets/document.pdf" - And I expand the "Filter" CMS Panel + And I expand the content filters And I select "Image" from "File type" with javascript - And I press the "Apply Filter" button + And I press the "Search" button Then the "Files" table should contain "file1" And the "Files" table should not contain "document" Scenario: I can filter out files that don't match the date range - Given I expand the "Filter" CMS Panel + Given I expand the content filters And I fill in "From" with "2003-01-01" And I fill in "To" with "2011-01-01" - And I press the "Apply Filter" button + And I press the "Search" button And the "Files" table should contain "file2" And the "Files" table should not contain "file1" diff --git a/tests/behat/features/search-for-a-page.feature b/tests/behat/features/search-for-a-page.feature index 9416ad18..97beea17 100644 --- a/tests/behat/features/search-for-a-page.feature +++ b/tests/behat/features/search-for-a-page.feature @@ -9,18 +9,19 @@ Feature: Search for a page And a "page" "Contact Us" And I am logged in with "ADMIN" permissions And I go to "/admin/pages" - And I expand the "Filter" CMS Panel + And I expand the content filters + And I wait for 2 seconds Scenario: I can search for a page by its title - Given I fill in "Content" with "About Us" - And I press the "Apply Filter" button + Given I fill in "Search" with "About Us" + And I press the "Search" button Then I should see "About Us" in the tree But I should not see "Contact Us" in the tree Scenario: I can search for a page by its type Given a "Error Page" "My Error Page" - When I select "Error Page" from "Page Type" - And I press the "Apply Filter" button + When I select "Error Page" from "Page type" + And I press the "Search" button Then I should see "My Error Page" in the tree But I should not see "Contact Us" in the tree @@ -28,7 +29,7 @@ Feature: Search for a page Given a "page" "Recent Page" And a "page" "Old Page" was last edited "7 days ago" When I fill in "From" with "the date of 5 days ago" - And I press the "Apply Filter" button + And I press the "Search" button Then I should see "Recent Page" in the tree But I should not see "Old Page" in the tree @@ -36,7 +37,7 @@ Feature: Search for a page Given a "page" "Recent Page" And a "page" "Old Page" was last edited "7 days ago" When I fill in "To" with "the date of 5 days ago" - And I press the "Apply Filter" button + And I press the "Search" button Then I should not see "Recent Page" in the tree But I should see "Old Page" in the tree @@ -44,30 +45,33 @@ Feature: Search for a page Given a "page" "Deleted Page" And the "page" "Deleted Page" is unpublished And the "page" "Deleted Page" is deleted - When I press the "Apply Filter" button + When I press the "Search" button Then I should not see "Deleted Page" in the tree - When I select "All pages, including archived" from "Pages" - And I press the "Apply Filter" button + When I expand the content filters + And I select "All pages, including archived" from "Page status" + And I press the "Search" button Then I should see "Deleted Page" in the tree Scenario: I can include only deleted pages in my search Given a "page" "Deleted Page" And the "page" "Deleted Page" is unpublished And the "page" "Deleted Page" is deleted - When I press the "Apply Filter" button + When I press the "Search" button Then I should not see "Deleted Page" in the tree - When I select "Archived pages" from "Pages" - And I press the "Apply Filter" button + When I expand the content filters + And I select "Archived pages" from "Page status" + And I press the "Search" button Then I should see "Deleted Page" in the tree And I should not see "About Us" in the tree Scenario: I can include draft pages in my search Given a "page" "Draft Page" And the "page" "Draft Page" is not published - When I press the "Apply Filter" button + When I press the "Search" button Then I should see "Draft Page" in the tree - When I select "Draft pages" from "Pages" - And I press the "Apply Filter" button + When I expand the content filters + And I select "Draft pages" from "Page status" + And I press the "Search" button Then I should see "Draft Page" in the tree And I should not see "About Us" in the tree @@ -80,9 +84,9 @@ Feature: Search for a page Then I should see "Saved" in the "button#Form_EditForm_action_save" element When I go to "/admin/pages" - And I expand the "Filter" CMS Panel - When I select "Modified pages" from "Pages" - And I press the "Apply Filter" button + And I expand the content filters + When I select "Modified pages" from "Page status" + And I press the "Search" button Then I should see "About Us" in the tree And I should not see "Home" in the tree @@ -90,10 +94,11 @@ Feature: Search for a page Given a "page" "Live Page" And the "page" "Live Page" is published And the "page" "Live Page" is deleted - When I press the "Apply Filter" button + When I press the "Search" button Then I should not see "Live Page" in the tree - When I select "Live but removed from draft" from "Pages" - And I press the "Apply Filter" button + When I expand the content filters + And I select "Live but removed from draft" from "Page status" + And I press the "Search" button Then I should see "Live Page" in the tree And I should not see "About Us" in the tree @@ -106,8 +111,8 @@ Feature: Search for a page And the "page" "Deleted Page" is unpublished And the "page" "Deleted Page" is deleted - When I select "Published pages" from "Pages" - And I press the "Apply Filter" button + When I select "Published pages" from "Page status" + And I press the "Search" button Then I should not see "Draft Page" in the tree And I should not see "Deleted Page" in the tree But I should see "Live Page" in the tree \ No newline at end of file