FIX Convert broken add-existing-search-form styles to use Bootstrap lists and pagination

This commit is contained in:
Robbie Averill 2018-01-26 11:53:40 +13:00
parent 8ba5c3435e
commit 0a16566471
4 changed files with 76 additions and 72 deletions

View File

@ -14,7 +14,7 @@
} }
.add-existing-search-dialog .add-existing-search-form .field label { .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 { .add-existing-search-dialog .add-existing-search-form .Actions {
@ -22,38 +22,12 @@
padding: 0; padding: 0;
} }
.add-existing-search-dialog .add-existing-search-items li a { .add-existing-search-dialog .list-group-item {
background: #FFF; min-height: 32px;
border: solid #CCC;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
display: block;
padding: 6px;
} }
.add-existing-search-dialog .add-existing-search-items li:first-child a { .add-existing-search-dialog .btn-toolbar {
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;
margin-top: 12px; margin-top: 12px;
padding: 6px;
} }
/** /**

View File

@ -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({ $(".add-existing-search-dialog .add-existing-search-items a").entwine({
onclick: function() { onclick: function() {
var link = this.closest(".add-existing-search-items").data("add-link"); var link = this.closest(".add-existing-search-items").data("add-link");

View File

@ -7,8 +7,10 @@ use SilverStripe\Control\RequestHandler;
use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form; use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction; use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataList;
use SilverStripe\ORM\PaginatedList; use SilverStripe\ORM\PaginatedList;
use SilverStripe\ORM\Search\SearchContext;
/** /**
* Used by {@link GridFieldAddExistingSearchButton} to provide the searching * Used by {@link GridFieldAddExistingSearchButton} to provide the searching
@ -49,7 +51,7 @@ class GridFieldAddExistingSearchHandler extends RequestHandler
public function index() public function index()
{ {
return $this->renderWith('Symbiote\\GridFieldExtensions\\GridFieldAddExistingSearchHandler'); return $this->renderWith(__CLASS__);
} }
public function add($request) public function add($request)
@ -73,19 +75,18 @@ class GridFieldAddExistingSearchHandler extends RequestHandler
*/ */
public function SearchForm() public function SearchForm()
{ {
$form = new Form( $form = Form::create(
$this, $this,
'SearchForm', 'SearchForm',
$this->context->getFields(), $this->context->getFields(),
new FieldList( FieldList::create(
FormAction::create('doSearch', _t('GridFieldExtensions.SEARCH', 'Search')) FormAction::create('doSearch', _t('GridFieldExtensions.SEARCH', 'Search'))
->setUseButtonTag(true) ->setUseButtonTag(true)
->addExtraClass('ss-ui-button') ->addExtraClass('btn btn-primary font-icon-search')
->setAttribute('data-icon', 'magnifier')
) )
); );
$form->addExtraClass('stacked add-existing-search-form'); $form->addExtraClass('stacked add-existing-search-form form--no-dividers');
$form->setFormMethod('GET'); $form->setFormMethod('GET');
return $form; return $form;

View File

@ -1,36 +1,56 @@
$SearchForm $SearchForm
<h3><% _t("RESULTS", "Results") %></h3> <h3><%t GridFieldExtensions.RESULTS "Results" %></h3>
<div class="add-existing-search-results"> <div class="add-existing-search-results">
<% if $Items %> <% if $Items %>
<ul class="add-existing-search-items" data-add-link="$Link('add')"> <ul class="list-group add-existing-search-items" data-add-link="$Link('add')">
<% loop $Items %> <% loop $Items %>
<li class="$EvenOdd"><a href="#" data-id="$ID">$Title</a></li> <li class="$EvenOdd list-group-item list-group-item-action">
<% end_loop %> <a href="#" data-id="$ID">$Title</a>
</ul> </li>
<% else %> <% end_loop %>
<p><% _t("NOITEMS", "There are no items.") %></p> </ul>
<% end_if %> <% else %>
<p><%t GridFieldExtensions.NOITEMS "There are no items." %></p>
<% if $Items.MoreThanOnePage %> <% end_if %>
<ul class="add-existing-search-pagination">
<% if $Items.NotFirstPage %> <% if $Items.MoreThanOnePage %>
<li><a href="$Items.PrevLink">&laquo;</a></li> <ul class="pagination add-existing-search-pagination">
<% end_if %> <% if $Items.NotFirstPage %>
<li class="page-item">
<% loop $Items.PaginationSummary(4) %> <a class="page-link" href="$Items.PrevLink">
<% if $CurrentBool %> <span aria-hidden="true">&laquo;</span>
<li class="current">$PageNum</li> <span class="sr-only"><%t GridFieldExtensions.PREVIOUS "Previous" %></span>
<% else_if $Link %> </a>
<li><a href="$Link">$PageNum</a></li> </li>
<% else %> <% end_if %>
<li>&hellip;</li>
<% end_if %> <% loop $Items.PaginationSummary(2) %>
<% end_loop %> <% if $CurrentBool %>
<li class="page-item active">
<% if $Items.NotLastPage %> <a class="page-link" href="#">
<li><a href="$Items.NextLink">&raquo;</a></li> $PageNum <span class="sr-only"><%t GridFieldExtensions.CURRENT "(current)" %></span>
<%end_if %> </a>
</ul> </li>
<% end_if %> <% else_if $Link %>
</div> <li class="page-item">
<a class="page-link" href="$Link">
$PageNum
</a>
</li>
<% else %>
<li class="page-item disabled">
<a class="page-link" href="#">&hellip;</a>
</li>
<% end_if %>
<% end_loop %>
<% if $Items.NotLastPage %>
<a class="page-link" href="$Items.NextLink">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only"><%t GridFieldExtensions.Next "Next" %></span>
</a>
<%end_if %>
</ul>
<% end_if %>
</div>