From 8ba5c3435e071d4cae157aad08d74dc43472f321 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 26 Jan 2018 11:01:24 +1300 Subject: [PATCH 1/3] FIX Switch Add Existing from jQuery UI to use Bootstrap styles --- src/GridFieldAddExistingSearchButton.php | 13 +++++++------ .../GridFieldAddExistingSearchButton.ss | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/GridFieldAddExistingSearchButton.php b/src/GridFieldAddExistingSearchButton.php index 7e991cb..630a2c3 100755 --- a/src/GridFieldAddExistingSearchButton.php +++ b/src/GridFieldAddExistingSearchButton.php @@ -91,14 +91,15 @@ class GridFieldAddExistingSearchButton implements GridField_HTMLProvider, GridFi { GridFieldExtensions::include_requirements(); - $data = new ArrayData(array( + $data = ArrayData::create([ 'Title' => $this->getTitle(), - 'Link' => $grid->Link('add-existing-search') - )); + 'Classes' => 'action btn btn-primary font-icon-search add-existing-search', + 'Link' => $grid->Link('add-existing-search'), + ]); - return array( - $this->fragment => $data->renderWith('Symbiote\\GridFieldExtensions\\GridFieldAddExistingSearchButton'), - ); + return [ + $this->fragment => $data->renderWith(__CLASS__), + ]; } public function getURLHandlers($grid) diff --git a/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchButton.ss b/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchButton.ss index 3efa1ec..ddebae0 100644 --- a/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchButton.ss +++ b/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchButton.ss @@ -1,3 +1,3 @@ - - $Title - + + $Title + From 0a1656647112f7d2a6f98dec13c023d4453d7f21 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 26 Jan 2018 11:53:40 +1300 Subject: [PATCH 2/3] FIX Convert broken add-existing-search-form styles to use Bootstrap lists and pagination --- css/GridFieldExtensions.css | 34 +------ javascript/GridFieldExtensions.js | 9 ++ src/GridFieldAddExistingSearchHandler.php | 13 +-- .../GridFieldAddExistingSearchHandler.ss | 92 +++++++++++-------- 4 files changed, 76 insertions(+), 72 deletions(-) diff --git a/css/GridFieldExtensions.css b/css/GridFieldExtensions.css index f49c814..45d3ed6 100644 --- a/css/GridFieldExtensions.css +++ b/css/GridFieldExtensions.css @@ -14,7 +14,7 @@ } .add-existing-search-dialog .add-existing-search-form .field label { - padding-bottom: 4px; + padding: 4px 0; } .add-existing-search-dialog .add-existing-search-form .Actions { @@ -22,38 +22,12 @@ padding: 0; } -.add-existing-search-dialog .add-existing-search-items li a { - background: #FFF; - border: solid #CCC; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - display: block; - padding: 6px; +.add-existing-search-dialog .list-group-item { + min-height: 32px; } -.add-existing-search-dialog .add-existing-search-items li:first-child a { - border-top-left-radius: 4px; - border-top-right-radius: 4px; - border-top-width: 1px; -} - -.add-existing-search-dialog .add-existing-search-items li:last-child a { - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; -} - -.add-existing-search-dialog .add-existing-search-items li a:hover { - background: #F4F4F4; -} - -.add-existing-search-dialog .add-existing-search-pagination li { - background: #FFF; - display: block; - float: left; - margin-right: 2px; +.add-existing-search-dialog .btn-toolbar { margin-top: 12px; - padding: 6px; } /** diff --git a/javascript/GridFieldExtensions.js b/javascript/GridFieldExtensions.js index d961716..5158790 100644 --- a/javascript/GridFieldExtensions.js +++ b/javascript/GridFieldExtensions.js @@ -44,6 +44,15 @@ } }); + // Allow the list item to be clickable as well as the anchor + $('.add-existing-search-dialog .add-existing-search-items .list-group-item-action').entwine({ + onclick: function() { + if (this.children('a').length > 0) { + this.children('a').first().trigger('click'); + } + } + }); + $(".add-existing-search-dialog .add-existing-search-items a").entwine({ onclick: function() { var link = this.closest(".add-existing-search-items").data("add-link"); diff --git a/src/GridFieldAddExistingSearchHandler.php b/src/GridFieldAddExistingSearchHandler.php index 8f025fd..58de381 100644 --- a/src/GridFieldAddExistingSearchHandler.php +++ b/src/GridFieldAddExistingSearchHandler.php @@ -7,8 +7,10 @@ use SilverStripe\Control\RequestHandler; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; +use SilverStripe\Forms\GridField\GridField; use SilverStripe\ORM\DataList; use SilverStripe\ORM\PaginatedList; +use SilverStripe\ORM\Search\SearchContext; /** * Used by {@link GridFieldAddExistingSearchButton} to provide the searching @@ -49,7 +51,7 @@ class GridFieldAddExistingSearchHandler extends RequestHandler public function index() { - return $this->renderWith('Symbiote\\GridFieldExtensions\\GridFieldAddExistingSearchHandler'); + return $this->renderWith(__CLASS__); } public function add($request) @@ -73,19 +75,18 @@ class GridFieldAddExistingSearchHandler extends RequestHandler */ public function SearchForm() { - $form = new Form( + $form = Form::create( $this, 'SearchForm', $this->context->getFields(), - new FieldList( + FieldList::create( FormAction::create('doSearch', _t('GridFieldExtensions.SEARCH', 'Search')) ->setUseButtonTag(true) - ->addExtraClass('ss-ui-button') - ->setAttribute('data-icon', 'magnifier') + ->addExtraClass('btn btn-primary font-icon-search') ) ); - $form->addExtraClass('stacked add-existing-search-form'); + $form->addExtraClass('stacked add-existing-search-form form--no-dividers'); $form->setFormMethod('GET'); return $form; diff --git a/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchHandler.ss b/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchHandler.ss index eaa531a..969fc94 100644 --- a/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchHandler.ss +++ b/templates/Symbiote/GridFieldExtensions/GridFieldAddExistingSearchHandler.ss @@ -1,36 +1,56 @@ -$SearchForm - -

<% _t("RESULTS", "Results") %>

-
- <% if $Items %> -
    - <% loop $Items %> -
  • $Title
  • - <% end_loop %> -
- <% else %> -

<% _t("NOITEMS", "There are no items.") %>

- <% end_if %> - - <% if $Items.MoreThanOnePage %> -
    - <% if $Items.NotFirstPage %> -
  • «
  • - <% end_if %> - - <% loop $Items.PaginationSummary(4) %> - <% if $CurrentBool %> -
  • $PageNum
  • - <% else_if $Link %> -
  • $PageNum
  • - <% else %> -
  • - <% end_if %> - <% end_loop %> - - <% if $Items.NotLastPage %> -
  • »
  • - <%end_if %> -
- <% end_if %> -
+$SearchForm + +

<%t GridFieldExtensions.RESULTS "Results" %>

+
+ <% if $Items %> +
    + <% loop $Items %> +
  • + $Title +
  • + <% end_loop %> +
+ <% else %> +

<%t GridFieldExtensions.NOITEMS "There are no items." %>

+ <% end_if %> + + <% if $Items.MoreThanOnePage %> + + <% end_if %> +
From eb9093a3ac9e9279217cfcc7c72a995b63fc1ec5 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 26 Jan 2018 11:53:55 +1300 Subject: [PATCH 3/3] Update translations --- lang/en.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lang/en.yml diff --git a/lang/en.yml b/lang/en.yml new file mode 100644 index 0000000..5792708 --- /dev/null +++ b/lang/en.yml @@ -0,0 +1,14 @@ +en: + GridFieldExtensions: + ADD: Add + ADDEXISTING: 'Add Existing' + BACK: Back + CURRENT: (current) + NOITEMS: 'There are no items.' + Next: Next + PREVIOUS: Previous + RESULTS: Results + SEARCH: Search + SELECTTYPETOCREATE: '(Select type to create)' + Symbiote\GridFieldExtensions\GridFieldConfigurablePaginator: + SHOW: Show