mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Added targetFragment argument to GridFieldAddExistingAutocompleter, so that its location can be changed. Updated CSS and HTML to allow for this.
This commit is contained in:
parent
d795a55bdb
commit
12618e2027
@ -2,6 +2,8 @@
|
||||
.cms .ss-gridfield > div { margin-bottom: 35px; }
|
||||
.cms .ss-gridfield[data-selectable] tr.ui-selected, .cms .ss-gridfield[data-selectable] tr.ui-selecting { background: #FFFAD6 !important; }
|
||||
.cms .ss-gridfield[data-selectable] td { cursor: pointer; }
|
||||
.cms .ss-gridfield .add-existing-autocompleter { width: 500px; }
|
||||
.cms .ss-gridfield .add-existing-autocompleter input.relation-search { width: 380px; }
|
||||
.cms table.ss-gridfield-table { display: table; box-shadow: none; padding: 0; border-collapse: separate; border-bottom: 0 none; width: 100%; }
|
||||
.cms table.ss-gridfield-table thead { color: #1d2224; background: transparent; }
|
||||
.cms table.ss-gridfield-table thead tr.filter-header .fieldgroup { max-width: 512px; }
|
||||
|
@ -16,6 +16,11 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
*/
|
||||
protected $itemClass = 'GridFieldAddExistingAutocompleter';
|
||||
|
||||
/**
|
||||
* The HTML fragment to write this component into
|
||||
*/
|
||||
protected $targetFragment;
|
||||
|
||||
/**
|
||||
* Which columns that should be used for doing a "StartsWith" search.
|
||||
* If multiple fields are provided, the filtering is performed non-exclusive.
|
||||
@ -40,7 +45,8 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
*
|
||||
* @param array $searchFields Which fields on the object in the list should be searched
|
||||
*/
|
||||
public function __construct($searchFields = null) {
|
||||
public function __construct($targetFragment = 'before', $searchFields = null) {
|
||||
$this->targetFragment = $targetFragment;
|
||||
$this->searchFields = (array)$searchFields;
|
||||
}
|
||||
|
||||
@ -67,7 +73,7 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
|
||||
$findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
|
||||
$findAction->setAttribute('data-icon', 'relationfind');
|
||||
$addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Exisiting"), 'addto', 'addto');
|
||||
$addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
|
||||
$addAction->setAttribute('data-icon', 'chain--plus');
|
||||
|
||||
// If an object is not found, disable the action
|
||||
@ -78,7 +84,10 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
$forTemplate->Fields->push($searchField);
|
||||
$forTemplate->Fields->push($findAction);
|
||||
$forTemplate->Fields->push($addAction);
|
||||
return array('before' => $forTemplate->renderWith($this->itemClass));
|
||||
|
||||
return array(
|
||||
$this->targetFragment => $forTemplate->renderWith($this->itemClass)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,15 @@ $gf_grid_x: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.ss-gridfield {
|
||||
.add-existing-autocompleter {
|
||||
input.relation-search {
|
||||
width: 380px;
|
||||
}
|
||||
width: 500px;
|
||||
}
|
||||
}
|
||||
|
||||
table.ss-gridfield-table {
|
||||
display: table;
|
||||
box-shadow: none;
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div><% control Fields %>
|
||||
<div class="add-existing-autocompleter"><% control Fields %>
|
||||
<span>$Field</span>
|
||||
<% end_control %>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user