Permalink
Browse files

API CHANGE: Added targetFragment argument to GridFieldAddExistingAuto…

…completer, so that its location can be changed. Updated CSS and HTML to allow for this.
  • Loading branch information...
1 parent d795a55 commit 12618e20279f7b6b2769709f3efed65907da186c @sminnee sminnee committed Mar 9, 2012
View
@@ -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; }
@@ -15,7 +15,12 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
* @var string $itemClass
*/
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 @@ public function getHTMLFragments($gridField) {
$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 @@ public function getHTMLFragments($gridField) {
$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)
+ );
}
/**
View
@@ -53,6 +53,15 @@ $gf_grid_x: 16px;
}
}
}
+
+ .ss-gridfield {
+ .add-existing-autocompleter {
+ input.relation-search {
+ width: 380px;
+ }
+ width: 500px;
+ }
+ }
table.ss-gridfield-table {
display: table;
@@ -1,4 +1,4 @@
-<div><% control Fields %>
+<div class="add-existing-autocompleter"><% control Fields %>
<span>$Field</span>
<% end_control %>
</div>

0 comments on commit 12618e2

Please sign in to comment.