Permalink
Browse files

API CHANGE: Renaming of gridfield components #6921

  • Loading branch information...
1 parent 31ce29f commit 8b82dae06c45a70683da8c5dfafa7e6fbbdebf8b @stojg stojg committed Mar 8, 2012
Showing with 108 additions and 108 deletions.
  1. +1 −1 admin/code/ModelAdmin.php
  2. +2 −2 admin/code/SecurityAdmin.php
  3. +2 −2 admin/tests/SecurityAdminTest.php
  4. +15 −15 docs/en/topics/grid-field.md
  5. +1 −1 forms/HtmlEditorField.php
  6. +1 −1 forms/UploadField.php
  7. +4 −4 forms/gridfield/{GridFieldRelationAdd.php → GridFieldAddExistingAutocompleter.php}
  8. +13 −13 forms/gridfield/GridFieldConfig.php
  9. +2 −2 forms/gridfield/GridFieldDeleteAction.php
  10. +3 −3 forms/gridfield/{GridFieldPopupForms.php → GridFieldDetailForm.php}
  11. +3 −3 forms/gridfield/{GridFieldEditAction.php → GridFieldEditButton.php}
  12. +1 −1 forms/gridfield/{GridFieldExporter.php → GridFieldExportButton.php}
  13. +6 −6 forms/gridfield/{GridFieldFilter.php → GridFieldFilterHeader.php}
  14. +2 −2 forms/gridfield/{GridFieldRelationDelete.php → GridFieldRemoveButton.php}
  15. +2 −2 forms/gridfield/{GridFieldTitle.php → GridFieldToolbarHeader.php}
  16. +4 −4 security/Group.php
  17. 0 templates/{GridFieldPopupForms.ss → GridFieldDetailForm.ss}
  18. 0 templates/Includes/{GridFieldRelationAdd.ss → GridFieldAddExistingAutocompleter.ss}
  19. 0 templates/Includes/{GridFieldEditAction.ss → GridFieldEditButton.ss}
  20. 0 templates/Includes/{GridFieldFilter_Row.ss → GridFieldFilterHeader_Row.ss}
  21. 0 templates/Includes/{GridFieldTitle.ss → GridFieldToolbarHeader.ss}
  22. +2 −2 tests/forms/GridFieldTest.php
  23. +8 −8 tests/forms/gridfield/{GridFieldRelationAddTest.php → GridFieldAddExistingAutocompleterTest.php}
  24. +18 −18 tests/forms/gridfield/{GridFieldPopupFormsTest.php → GridFieldDetailFormTest.php}
  25. +12 −0 tests/forms/gridfield/GridFieldDetailFormTest.yml
  26. +2 −2 tests/forms/gridfield/{GridFieldEditActionTest.php → GridFieldEditButtonTest.php}
  27. +0 −12 tests/forms/gridfield/GridFieldPopupFormsTest.yml
  28. +4 −4 tests/forms/gridfield/{GridFieldTitleTest.php → GridFieldToolbarHeaderTest.php}
@@ -710,7 +710,7 @@ function getResultsTable($searchCriteria) {
false,
$datalist,
$fieldConfig = GridFieldConfig_RecordEditor::create($numItemsPerPage)
- ->addComponent(new GridFieldExporter())->removeComponentsByType('GridFieldFilter')
+ ->addComponent(new GridFieldExportButton())->removeComponentsByType('GridFieldFilterHeader')
)->setDisplayFields($this->getResultColumns($searchCriteria));
return $tf;
@@ -48,9 +48,9 @@ public function getEditForm($id = null, $fields = null) {
false,
DataList::create('Member'),
$memberListConfig = GridFieldConfig_RecordEditor::create()
- ->addComponent(new GridFieldExporter())
+ ->addComponent(new GridFieldExportButton())
)->addExtraClass("members_grid");
- $memberListConfig->getComponentByType('GridFieldPopupForms')->setValidator(new Member_Validator());
+ $memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
$groupList = Object::create('GridField',
'Groups',
@@ -9,7 +9,7 @@ class SecurityAdminTest extends FunctionalTest {
protected $extraDataObjects = array('LeftAndMainTest_Object');
- // TODO Fix export feature (moved from MemberTableField to GridFieldExporter)
+ // TODO Fix export feature (moved from MemberTableField to GridFieldExportButton)
// function testGroupExport() {
// $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
@@ -27,7 +27,7 @@ class SecurityAdminTest extends FunctionalTest {
// $this->assertRegExp('/"","","admin@example.com"/', $lines[1], "Member values are correctly exported");
// }
- // TODO Fix export feature (moved from MemberTableField to GridFieldExporter)
+ // TODO Fix export feature (moved from MemberTableField to GridFieldExportButton)
// function testEmptyGroupExport() {
// $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
@@ -30,7 +30,7 @@ This example creates exactly the same kind of grid as the previous example, but
:::php
$config = GridFieldConfig::create();
// Provide a header row with filter controls
- $config->addComponent(new GridFieldFilter());
+ $config->addComponent(new GridFieldFilterHeader());
// Provide a default set of columns based on $summary_fields
$config->addComponent(new GridFieldDefaultColumns());
// Provide a header row with sort controls
@@ -99,7 +99,7 @@ You can also specify formatting replacements, to replace column contents with HT
This component will add a header to the grid with sort buttons. It will detect which columns are sortable and only provide sort controls on those columns.
-### GridFieldFilter
+### GridFieldFilterHeader
This component will add a header row with a text field filter for each column, letting you filter the results with text searches. It will detect which columns are filterable and only provide sort controls on those columns.
@@ -109,34 +109,34 @@ This component will limit output to a fixed number of items per page add a foote
### GridFieldAction
-TODO Describe component, including GridFieldEditAction/GridFieldDeleteAction
+TODO Describe component, including GridFieldEditButton/GridFieldDeleteAction
-### GridFieldRelationAdd
+### GridFieldAddExistingAutocompleter
This class is is responsible for adding objects to another object's has_many and many_many relation,
as defined by the `[api:RelationList]` passed to the GridField constructor.
Objects can be searched through an input field (partially matching one or more fields).
Selecting from the results will add the object to the relation.
-Often used alongside `[api:GridFieldRelationDelete]` for detaching existing records from a relatinship.
+Often used alongside `[api:GridFieldRemoveButton]` for detaching existing records from a relatinship.
For easier setup, have a look at a sample configuration in `[api:GridFieldConfig_RelationEditor]`.
-### GridFieldRelationDelete
+### GridFieldRemoveButton
Allows to detach an item from an existing has_many or many_many relationship.
Similar to {@link GridFieldDeleteAction}, but allows to distinguish between
a "delete" and "detach" action in the UI - and to use both in parallel, if required.
Requires the GridField to be populated with a `[api:RelationList]` rather than a plain DataList.
-Often used alongside `[api:GridFieldRelationAdd]` to add existing records to the relationship.
+Often used alongside `[api:GridFieldAddExistingAutocompleter]` to add existing records to the relationship.
-### GridFieldPopupForms
+### GridFieldDetailForm
-TODO Describe component, including how it relates to GridFieldEditAction. Point to GridFieldConfig_RelationEditor for easier defaults.
+TODO Describe component, including how it relates to GridFieldEditButton. Point to GridFieldConfig_RelationEditor for easier defaults.
-### GridFieldTitle
+### GridFieldToolbarHeader
TODO
-### GridFieldExporter
+### GridFieldExportButton
TODO
@@ -152,16 +152,16 @@ It's common for a component to implement several of these interfaces in order to
* `GridField_ActionProvider`, to define the sortasc and sortdesc actions that add sort column and direction to the state.
* `GridField_DataManipulator`, to alter the sorting of the data list based on the sort column and direction values in the state.
- ### GridFieldRelationAdd
+ ### GridFieldAddExistingAutocompleter
-A GridFieldRelationAdd is responsible for adding objects to another object's `has_many` and `many_many` relation,
+A GridFieldAddExistingAutocompleter is responsible for adding objects to another object's `has_many` and `many_many` relation,
as defined by the `[api:RelationList]` passed to the GridField constructor.
Objects can be searched through an input field (partially matching one or more fields).
Selecting from the results will add the object to the relation.
:::php
$group = DataObject::get_one('Group');
- $config = GridFieldConfig::create()->addComponent(new GridFieldRelationAdd(array('FirstName', 'Surname', 'Email'));
+ $config = GridFieldConfig::create()->addComponent(new GridFieldAddExistingAutocompleter(array('FirstName', 'Surname', 'Email'));
$gridField = new GridField('Members', 'Members', $group->Members(), $config);
## Component interfaces
@@ -293,7 +293,7 @@ Here is an example in full. The actual implementation of the view and edit form
* - <FormURL>/field/<GridFieldName>/item/<RecordID>
* - <FormURL>/field/<GridFieldName>/item/<RecordID>/edit
*/
- class GridFieldPopupForms implements GridField_URLHandler {
+ class GridFieldDetailForm implements GridField_URLHandler {
public function getURLHandlers($gridField) {
return array(
'item/$ID' => 'handleItem',
@@ -355,7 +355,7 @@ function MediaForm() {
$fileFieldConfig = GridFieldConfig::create();
$fileFieldConfig->addComponent(new GridFieldSortableHeader());
- $fileFieldConfig->addComponent(new GridFieldFilter());
+ $fileFieldConfig->addComponent(new GridFieldFilterHeader());
$fileFieldConfig->addComponent(new GridFieldDefaultColumns());
$fileFieldConfig->addComponent(new GridFieldPaginator(5));
$fileField = new GridField('Files', false, null, $fileFieldConfig);
@@ -846,7 +846,7 @@ protected function getListField() {
$folder = $this->getFolder();
$config = GridFieldConfig::create();
$config->addComponent(new GridFieldSortableHeader());
- $config->addComponent(new GridFieldFilter());
+ $config->addComponent(new GridFieldFilterHeader());
$config->addComponent(new GridFieldDefaultColumns());
$config->addComponent(new GridFieldPaginator(10));
@@ -4,17 +4,17 @@
* as defined by the {@link RelationList} passed to the GridField constructor.
* Objects can be searched through an input field (partially matching one or more fields).
* Selecting from the results will add the object to the relation.
- * Often used alongside {@link GridFieldRelationDelete} for detaching existing records from a relatinship.
+ * Often used alongside {@link GridFieldRemoveButton} for detaching existing records from a relatinship.
* For easier setup, have a look at a sample configuration in {@link GridFieldConfig_RelationEditor}.
*/
-class GridFieldRelationAdd implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator, GridField_URLHandler {
+class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator, GridField_URLHandler {
/**
* Which template to use for rendering
*
* @var string $itemClass
*/
- protected $itemClass = 'GridFieldRelationAdd';
+ protected $itemClass = 'GridFieldAddExistingAutocompleter';
/**
* Which columns that should be used for doing a "StartsWith" search.
@@ -161,7 +161,7 @@ public function doSearch($gridField, $request) {
$searchFields = ($this->getSearchFields()) ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
if(!$searchFields) {
throw new LogicException(
- sprintf('GridFieldRelationAdd: No searchable fields could be found for class "%s"', $dataClass)
+ sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"', $dataClass)
);
}
@@ -131,9 +131,9 @@ public static function create($itemsPerPage=null){
* @param int $itemsPerPage - How many items per page should show up
*/
public function __construct($itemsPerPage=null) {
- $this->addComponent(new GridFieldTitle());
+ $this->addComponent(new GridFieldToolbarHeader());
$this->addComponent(new GridFieldSortableHeader());
- $this->addComponent(new GridFieldFilter());
+ $this->addComponent(new GridFieldFilterHeader());
$this->addComponent(new GridFieldDefaultColumns());
$this->addComponent(new GridFieldPaginator($itemsPerPage));
}
@@ -158,14 +158,14 @@ public static function create($itemsPerPage=null){
* @param int $itemsPerPage - How many items per page should show up
*/
public function __construct($itemsPerPage=null) {
- $this->addComponent(new GridFieldTitle());
+ $this->addComponent(new GridFieldToolbarHeader());
$this->addComponent(new GridFieldSortableHeader());
- $this->addComponent(new GridFieldFilter());
+ $this->addComponent(new GridFieldFilterHeader());
$this->addComponent(new GridFieldDefaultColumns());
- $this->addComponent(new GridFieldEditAction());
+ $this->addComponent(new GridFieldEditButton());
$this->addComponent(new GridFieldDeleteAction());
$this->addComponent(new GridFieldPaginator($itemsPerPage));
- $this->addComponent(new GridFieldPopupForms());
+ $this->addComponent(new GridFieldDetailForm());
}
}
@@ -181,7 +181,7 @@ public function __construct($itemsPerPage=null) {
* for example to change the field to search.
* <code>
* GridFieldConfig_RelationEditor::create()
- * ->getComponentByType('GridFieldRelationAdd')->setSearchFields('MyField');
+ * ->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields('MyField');
* </code>
*/
class GridFieldConfig_RelationEditor extends GridFieldConfig {
@@ -200,14 +200,14 @@ public static function create($itemsPerPage=null){
* @param int $itemsPerPage - How many items per page should show up
*/
public function __construct($itemsPerPage=null) {
- $this->addComponent(new GridFieldTitle());
- $this->addComponent(new GridFieldRelationAdd());
+ $this->addComponent(new GridFieldToolbarHeader());
+ $this->addComponent(new GridFieldAddExistingAutocompleter());
$this->addComponent(new GridFieldSortableHeader());
- $this->addComponent(new GridFieldFilter());
+ $this->addComponent(new GridFieldFilterHeader());
$this->addComponent(new GridFieldDefaultColumns());
- $this->addComponent(new GridFieldEditAction());
- $this->addComponent(new GridFieldRelationDelete());
+ $this->addComponent(new GridFieldEditButton());
+ $this->addComponent(new GridFieldRemoveButton());
$this->addComponent(new GridFieldPaginator($itemsPerPage));
- $this->addComponent(new GridFieldPopupForms());
+ $this->addComponent(new GridFieldDetailForm());
}
}
@@ -1,7 +1,7 @@
<?php
/**
* This class is an GridField Component that add Delete action for Objects in the GridField.
- * See {@link GridFieldRelationDelete} for detaching an item from the current relationship instead.
+ * See {@link GridFieldRemoveButton} for detaching an item from the current relationship instead.
*/
class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_ActionProvider {
@@ -97,7 +97,7 @@ public function getColumnContent($gridField, $record, $columnName) {
public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
if($actionName == 'deleterecord') {
$id = $arguments['RecordID'];
- // Always deletes a record. Use GridFieldRelationDelete to detach it from the current relationship.
+ // Always deletes a record. Use GridFieldRemoveButton to detach it from the current relationship.
$item = $gridField->getList()->byID($id);
if(!$item->canDelete()) {
throw new ValidationException(_t('GridFieldAction_Delete.DeletePermissionsFailure',"No delete permissions"),0);
@@ -3,21 +3,21 @@
/**
* Provides view and edit forms at GridField-specific URLs.
* These can be placed into pop-ups by an appropriate front-end.
- * Usually added to a grid field alongside of {@link GridFieldEditAction}
+ * Usually added to a grid field alongside of {@link GridFieldEditButton}
* which takes care of linking the individual rows to their edit view.
*
* The URLs provided will be off the following form:
* - <FormURL>/field/<GridFieldName>/item/<RecordID>
* - <FormURL>/field/<GridFieldName>/item/<RecordID>/edit
*/
-class GridFieldPopupForms implements GridField_URLHandler {
+class GridFieldDetailForm implements GridField_URLHandler {
/**
* @var String
*/
- protected $template = 'GridFieldPopupForms';
+ protected $template = 'GridFieldDetailForm';
/**
*
@@ -3,10 +3,10 @@
* Provides the entry point to editing a single record presented by the grid.
* Doesn't show an edit view on its own or modifies the record, but rather relies on routing conventions
* established in {@link getColumnContent()}. The default routing applies to
- * the {@link GridFieldPopupForms} component, which has to be added separately
+ * the {@link GridFieldDetailForm} component, which has to be added separately
* to the grid field configuration.
*/
-class GridFieldEditAction implements GridField_ColumnProvider {
+class GridFieldEditButton implements GridField_ColumnProvider {
/**
* Add a column 'Delete'
@@ -79,7 +79,7 @@ public function getColumnContent($gridField, $record, $columnName) {
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
));
- return $data->renderWith('GridFieldEditAction');
+ return $data->renderWith('GridFieldEditButton');
}
/**
@@ -10,7 +10,7 @@
* WARNING: This is experimental and its API is subject to change. Feel free to use it as long as you are happy of
* refactoring your code in the future.
*/
-class GridFieldExporter implements GridField_HTMLProvider, GridField_ActionProvider, GridField_URLHandler {
+class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionProvider, GridField_URLHandler {
/**
* @var array Map of a property name on the exported objects, with values being the column title in the CSV file.
@@ -1,13 +1,13 @@
<?php
/**
- * GridFieldFilter alters the gridfield with some filtering fields in the header of each column
+ * GridFieldFilterHeader alters the gridfield with some filtering fields in the header of each column
*
* @see GridField
*
* @package sapphire
* @subpackage fields-relational
*/
-class GridFieldFilter implements GridField_HTMLProvider, GridField_DataManipulator, GridField_ActionProvider {
+class GridFieldFilterHeader implements GridField_HTMLProvider, GridField_DataManipulator, GridField_ActionProvider {
/**
*
@@ -19,7 +19,7 @@ public function getActions($gridField) {
}
function handleAction(GridField $gridField, $actionName, $arguments, $data) {
- $state = $gridField->State->GridFieldFilter;
+ $state = $gridField->State->GridFieldFilterHeader;
if($actionName === 'filter') {
if(isset($data['filter'])){
foreach($data['filter'] as $key => $filter ){
@@ -39,7 +39,7 @@ function handleAction(GridField $gridField, $actionName, $arguments, $data) {
* @return SS_List
*/
public function getManipulatedData(GridField $gridField, SS_List $dataList) {
- $state = $gridField->State->GridFieldFilter;
+ $state = $gridField->State->GridFieldFilterHeader;
if(!isset($state->Columns)) {
return $dataList;
}
@@ -58,7 +58,7 @@ public function getHTMLFragments($gridField) {
$forTemplate->Fields = new ArrayList;
$columns = $gridField->getColumns();
- $filterArguments = $gridField->State->GridFieldFilter->Columns->toArray();
+ $filterArguments = $gridField->State->GridFieldFilterHeader->Columns->toArray();
$currentColumn = 0;
foreach($columns as $columnField) {
@@ -92,7 +92,7 @@ public function getHTMLFragments($gridField) {
}
return array(
- 'header' => $forTemplate->renderWith('GridFieldFilter_Row'),
+ 'header' => $forTemplate->renderWith('GridFieldFilterHeader_Row'),
);
}
}
@@ -4,10 +4,10 @@
* Similar to {@link GridFieldDeleteAction}, but allows to distinguish between
* a "delete" and "detach" action in the UI - and to use both in parallel, if required.
* Requires the GridField to be populated with a {@link RelationList} rather than a plain {@link DataList}.
- * Often used alongside {@link GridFieldRelationAdd} to add existing records to the relationship.
+ * Often used alongside {@link GridFieldAddExistingAutocompleter} to add existing records to the relationship.
* For easier setup, have a look at a sample configuration in {@link GridFieldConfig_RelationEditor}.
*/
-class GridFieldRelationDelete implements GridField_ColumnProvider, GridField_ActionProvider {
+class GridFieldRemoveButton implements GridField_ColumnProvider, GridField_ActionProvider {
/**
* Add a column 'UnlinkRelation'
@@ -14,7 +14,7 @@
* @package sapphire
* @subpackage gridfield
*/
-class GridFieldTitle implements GridField_HTMLProvider {
+class GridFieldToolbarHeader implements GridField_HTMLProvider {
/**
*
@@ -34,7 +34,7 @@ public function getHTMLFragments( $gridField) {
'header' => $gridField->customise(array(
'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
'NewEnabled' => $this->getNewEnabled()
- ))->renderWith('GridFieldTitle')
+ ))->renderWith('GridFieldToolbarHeader')
);
}
Oops, something went wrong.

0 comments on commit 8b82dae

Please sign in to comment.