Permalink
Browse files

MINOR Renamed GridFieldAction_Edit to GridFieldEditAction, GridFieldA…

…ction_Delete to GridFieldDeleteAction, to make it clearer that there's no parent class/concept called "GridFieldAction". There's only the GridFieldActionProvider interface, as well as the GridField_FormAction (which is a related, but different kettle of fish).
  • Loading branch information...
1 parent 3e700d7 commit ac20bfaf99c663d93175772d14b561ef6be36877 @chillu chillu committed Mar 6, 2012
@@ -109,7 +109,7 @@ This component will limit output to a fixed number of items per page add a foote
### GridFieldAction
-TODO Describe component, including GridFieldAction_Edit/GridFieldAction_Delete
+TODO Describe component, including GridFieldEditAction/GridFieldDeleteAction
### GridFieldRelationAdd
@@ -123,14 +123,14 @@ For easier setup, have a look at a sample configuration in `[api:GridFieldConfig
### GridFieldRelationDelete
Allows to detach an item from an existing has_many or many_many relationship.
-Similar to {@link GridFieldAction_Delete}, but allows to distinguish between
+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.
### GridFieldPopupForms
-TODO Describe component, including how it relates to GridFieldAction_Edit. Point to GridFieldConfig_RelationEditor for easier defaults.
+TODO Describe component, including how it relates to GridFieldEditAction. Point to GridFieldConfig_RelationEditor for easier defaults.
### GridFieldTitle
@@ -162,8 +162,8 @@ public function __construct($itemsPerPage=null) {
$this->addComponent(new GridFieldSortableHeader());
$this->addComponent(new GridFieldFilter());
$this->addComponent(new GridFieldDefaultColumns());
- $this->addComponent(new GridFieldAction_Edit());
- $this->addComponent(new GridFieldAction_Delete());
+ $this->addComponent(new GridFieldEditAction());
+ $this->addComponent(new GridFieldDeleteAction());
$this->addComponent(new GridFieldPaginator($itemsPerPage));
$this->addComponent(new GridFieldPopupForms());
}
@@ -205,7 +205,7 @@ public function __construct($itemsPerPage=null) {
$this->addComponent(new GridFieldSortableHeader());
$this->addComponent(new GridFieldFilter());
$this->addComponent(new GridFieldDefaultColumns());
- $this->addComponent(new GridFieldAction_Edit());
+ $this->addComponent(new GridFieldEditAction());
$this->addComponent(new GridFieldRelationDelete());
$this->addComponent(new GridFieldPaginator($itemsPerPage));
$this->addComponent(new GridFieldPopupForms());
@@ -1,103 +1,9 @@
<?php
/**
- * 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
- * to the grid field configuration.
- */
-class GridFieldAction_Edit implements GridField_ColumnProvider {
-
- /**
- * Add a column 'Delete'
- *
- * @param type $gridField
- * @param array $columns
- */
- public function augmentColumns($gridField, &$columns) {
- if(!in_array('Actions', $columns))
- $columns[] = 'Actions';
- }
-
- /**
- * Return any special attributes that will be used for FormField::createTag()
- *
- * @param GridField $gridField
- * @param DataObject $record
- * @param string $columnName
- * @return array
- */
- public function getColumnAttributes($gridField, $record, $columnName) {
- return array();
- }
-
- /**
- * Add the title
- *
- * @param GridField $gridField
- * @param string $columnName
- * @return array
- */
- public function getColumnMetadata($gridField, $columnName) {
- if($columnName == 'Actions') {
- return array('title' => '');
- }
- }
-
- /**
- * Which columns are handled by this component
- *
- * @param type $gridField
- * @return type
- */
- public function getColumnsHandled($gridField) {
- return array('Actions');
- }
-
- /**
- * Which GridField actions are this component handling
- *
- * @param GridField $gridField
- * @return array
- */
- public function getActions($gridField) {
- return array();
- }
-
- /**
- *
- * @param GridField $gridField
- * @param DataObject $record
- * @param string $columnName
- * @return string - the HTML for the column
- */
- public function getColumnContent($gridField, $record, $columnName) {
- $data = new ArrayData(array(
- 'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
- ));
-
- return $data->renderWith('GridFieldAction_Edit');
- }
-
- /**
- * Handle the actions and apply any changes to the GridField
- *
- * @param GridField $gridField
- * @param string $actionName
- * @param mixed $arguments
- * @param array $data - form data
- * @return void
- */
- public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
-
- }
-}
-
-/**
* 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.
*/
-class GridFieldAction_Delete implements GridField_ColumnProvider, GridField_ActionProvider {
+class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_ActionProvider {
/**
* Add a column 'Delete'
@@ -0,0 +1,94 @@
+<?php
+/**
+ * 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
+ * to the grid field configuration.
+ */
+class GridFieldEditAction implements GridField_ColumnProvider {
+
+ /**
+ * Add a column 'Delete'
+ *
+ * @param type $gridField
+ * @param array $columns
+ */
+ public function augmentColumns($gridField, &$columns) {
+ if(!in_array('Actions', $columns))
+ $columns[] = 'Actions';
+ }
+
+ /**
+ * Return any special attributes that will be used for FormField::createTag()
+ *
+ * @param GridField $gridField
+ * @param DataObject $record
+ * @param string $columnName
+ * @return array
+ */
+ public function getColumnAttributes($gridField, $record, $columnName) {
+ return array();
+ }
+
+ /**
+ * Add the title
+ *
+ * @param GridField $gridField
+ * @param string $columnName
+ * @return array
+ */
+ public function getColumnMetadata($gridField, $columnName) {
+ if($columnName == 'Actions') {
+ return array('title' => '');
+ }
+ }
+
+ /**
+ * Which columns are handled by this component
+ *
+ * @param type $gridField
+ * @return type
+ */
+ public function getColumnsHandled($gridField) {
+ return array('Actions');
+ }
+
+ /**
+ * Which GridField actions are this component handling
+ *
+ * @param GridField $gridField
+ * @return array
+ */
+ public function getActions($gridField) {
+ return array();
+ }
+
+ /**
+ *
+ * @param GridField $gridField
+ * @param DataObject $record
+ * @param string $columnName
+ * @return string - the HTML for the column
+ */
+ public function getColumnContent($gridField, $record, $columnName) {
+ $data = new ArrayData(array(
+ 'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
+ ));
+
+ return $data->renderWith('GridFieldEditAction');
+ }
+
+ /**
+ * Handle the actions and apply any changes to the GridField
+ *
+ * @param GridField $gridField
+ * @param string $actionName
+ * @param mixed $arguments
+ * @param array $data - form data
+ * @return void
+ */
+ public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
+
+ }
+}
@@ -3,7 +3,7 @@
/**
* 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 GridFieldAction_Edit}
+ * Usually added to a grid field alongside of {@link GridFieldEditAction}
* which takes care of linking the individual rows to their edit view.
*
* The URLs provided will be off the following form:
@@ -1,7 +1,7 @@
<?php
/**
* Allows to detach an item from an existing has_many or many_many relationship.
- * Similar to {@link GridFieldAction_Delete}, but allows to distinguish between
+ * 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.
@@ -113,7 +113,7 @@ function Form() {
$field = new GridField('testfield', 'testfield', $group->People());
$field->getConfig()->addComponent($gridFieldForm = new GridFieldPopupForms($this, 'Form'));
- $field->getConfig()->addComponent(new GridFieldAction_Edit());
+ $field->getConfig()->addComponent(new GridFieldEditAction());
return new Form($this, 'Form', new FieldList($field), new FieldList());
}
}

0 comments on commit ac20bfa

Please sign in to comment.