From 09d6fa7bb3915d6caa8426c494e73d499ca08287 Mon Sep 17 00:00:00 2001 From: Stig Lindqvist Date: Fri, 9 Mar 2012 14:07:40 +1300 Subject: [PATCH] API CHANGE Renamed GridFieldDefaultColumns to GridFieldDataColumns #6921 --- docs/en/topics/grid-field.md | 10 +++++----- forms/HtmlEditorField.php | 2 +- forms/UploadField.php | 2 +- forms/gridfield/GridField.php | 2 +- forms/gridfield/GridFieldComponent.php | 2 +- forms/gridfield/GridFieldConfig.php | 6 +++--- ...ieldDefaultColumns.php => GridFieldDataColumns.php} | 2 +- tests/forms/GridFieldTest.php | 8 ++++---- .../GridFieldAddExistingAutocompleterTest.php | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) rename forms/gridfield/{GridFieldDefaultColumns.php => GridFieldDataColumns.php} (97%) diff --git a/docs/en/topics/grid-field.md b/docs/en/topics/grid-field.md index eab4eb7dc..a74939be7 100644 --- a/docs/en/topics/grid-field.md +++ b/docs/en/topics/grid-field.md @@ -32,7 +32,7 @@ This example creates exactly the same kind of grid as the previous example, but // Provide a header row with filter controls $config->addComponent(new GridFieldFilterHeader()); // Provide a default set of columns based on $summary_fields - $config->addComponent(new GridFieldDefaultColumns()); + $config->addComponent(new GridFieldDataColumns()); // Provide a header row with sort controls $config->addComponent(new GridFieldSortableHeader()); // Paginate results to 25 items per page, and show a footer with pagination controls @@ -44,7 +44,7 @@ If we wanted to make a simpler grid without pagination or filtering, we could do :::php $config = GridFieldConfig::create(); // Provide a default set of columns based on $summary_fields - $config->addComponent(new GridFieldDefaultColumns()); + $config->addComponent(new GridFieldDataColumns()); // Provide a header row with sort controls $config->addComponent(new GridFieldPaginator(25)); $field = new GridField("Members", "Members of this group", $this->group->Members(), $config); @@ -57,11 +57,11 @@ A `GridFieldConfig` is made up of a new of `GridFieldComponent` objects, which a `GridFieldComponent` is a family of interfaces. SilverStripe Framework comes with the following components that you can use out of the box. -### GridFieldDefaultColumns +### GridFieldDataColumns This is the one component that, in most cases, you must include. It provides the default columns, sourcing them from the underlying DataObject's `$summary_fields` if no specific configuration is provided. -Without GridFieldDefaultColumns added to a GridField, it would have no columns whatsoever. Although this isn't particularly useful most of the time, we have allowed for this for two reasons: +Without GridFieldDataColumns added to a GridField, it would have no columns whatsoever. Although this isn't particularly useful most of the time, we have allowed for this for two reasons: * You may have a grid whose fields are generated purely by another non-standard component. * It keeps the core of the GridField lean, focused solely on providing APIs to the components. @@ -233,7 +233,7 @@ By default, a grid contains no columns. All the columns displayed in a grid wil For example, you may create a grid field with several components providing columns: - * `GridFieldDefaultColumns` could provide basic data columns. + * `GridFieldDataColumns` could provide basic data columns. * An editor component could provide a column containing action buttons on the right. * A multiselect component clould provide a column showing a checkbox on the left. diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index 54c0a57dc..a18f8ebb6 100644 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -356,7 +356,7 @@ class HtmlEditorField_Toolbar extends RequestHandler { $fileFieldConfig = GridFieldConfig::create(); $fileFieldConfig->addComponent(new GridFieldSortableHeader()); $fileFieldConfig->addComponent(new GridFieldFilterHeader()); - $fileFieldConfig->addComponent(new GridFieldDefaultColumns()); + $fileFieldConfig->addComponent(new GridFieldDataColumns()); $fileFieldConfig->addComponent(new GridFieldPaginator(5)); $fileField = new GridField('Files', false, null, $fileFieldConfig); $fileField->setList($this->getFiles($parentID)); diff --git a/forms/UploadField.php b/forms/UploadField.php index 6a74dabb5..80249b083 100644 --- a/forms/UploadField.php +++ b/forms/UploadField.php @@ -847,7 +847,7 @@ class UploadField_SelectHandler extends RequestHandler { $config = GridFieldConfig::create(); $config->addComponent(new GridFieldSortableHeader()); $config->addComponent(new GridFieldFilterHeader()); - $config->addComponent(new GridFieldDefaultColumns()); + $config->addComponent(new GridFieldDataColumns()); $config->addComponent(new GridFieldPaginator(10)); $field = new GridField('Files', false, $folder->stageChildren(), $config); diff --git a/forms/gridfield/GridField.php b/forms/gridfield/GridField.php index f58e37108..ac1fbbd39 100755 --- a/forms/gridfield/GridField.php +++ b/forms/gridfield/GridField.php @@ -404,7 +404,7 @@ class GridField extends FormField { array( "class" => implode(' ', $classes), 'data-id' => $record->ID, - // TODO Allow per-row customization similar to GridFieldDefaultColumns + // TODO Allow per-row customization similar to GridFieldDataColumns 'data-class' => $record->ClassName, ), $rowContent diff --git a/forms/gridfield/GridFieldComponent.php b/forms/gridfield/GridFieldComponent.php index 988ed1083..cf6c58bdd 100644 --- a/forms/gridfield/GridFieldComponent.php +++ b/forms/gridfield/GridFieldComponent.php @@ -36,7 +36,7 @@ interface GridField_ColumnProvider extends GridFieldComponent { /** * Modify the list of columns displayed in the table. - * See {@link GridField->getDisplayFields()} and {@link GridFieldDefaultColumns}. + * See {@link GridField->getDisplayFields()} and {@link GridFieldDataColumns}. * * @param GridField * @param Array List reference of all column names. diff --git a/forms/gridfield/GridFieldConfig.php b/forms/gridfield/GridFieldConfig.php index 0cc589a0a..76ad37a6b 100755 --- a/forms/gridfield/GridFieldConfig.php +++ b/forms/gridfield/GridFieldConfig.php @@ -134,7 +134,7 @@ class GridFieldConfig_Base extends GridFieldConfig { $this->addComponent(new GridFieldToolbarHeader()); $this->addComponent(new GridFieldSortableHeader()); $this->addComponent(new GridFieldFilterHeader()); - $this->addComponent(new GridFieldDefaultColumns()); + $this->addComponent(new GridFieldDataColumns()); $this->addComponent(new GridFieldPaginator($itemsPerPage)); } } @@ -161,7 +161,7 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig { $this->addComponent(new GridFieldToolbarHeader()); $this->addComponent(new GridFieldSortableHeader()); $this->addComponent(new GridFieldFilterHeader()); - $this->addComponent(new GridFieldDefaultColumns()); + $this->addComponent(new GridFieldDataColumns()); $this->addComponent(new GridFieldEditButton()); $this->addComponent(new GridFieldDeleteAction()); $this->addComponent(new GridFieldPaginator($itemsPerPage)); @@ -204,7 +204,7 @@ class GridFieldConfig_RelationEditor extends GridFieldConfig { $this->addComponent(new GridFieldAddExistingAutocompleter()); $this->addComponent(new GridFieldSortableHeader()); $this->addComponent(new GridFieldFilterHeader()); - $this->addComponent(new GridFieldDefaultColumns()); + $this->addComponent(new GridFieldDataColumns()); $this->addComponent(new GridFieldEditButton()); $this->addComponent(new GridFieldDeleteAction(true)); $this->addComponent(new GridFieldPaginator($itemsPerPage)); diff --git a/forms/gridfield/GridFieldDefaultColumns.php b/forms/gridfield/GridFieldDataColumns.php similarity index 97% rename from forms/gridfield/GridFieldDefaultColumns.php rename to forms/gridfield/GridFieldDataColumns.php index 1c058a615..1d2c88cdd 100644 --- a/forms/gridfield/GridFieldDefaultColumns.php +++ b/forms/gridfield/GridFieldDataColumns.php @@ -6,7 +6,7 @@ * @package sapphire * @subpackage fields-relational */ -class GridFieldDefaultColumns implements GridField_ColumnProvider { +class GridFieldDataColumns implements GridField_ColumnProvider { public function augmentColumns($gridField, &$columns) { $baseColumns = array_keys($gridField->getDisplayFields()); diff --git a/tests/forms/GridFieldTest.php b/tests/forms/GridFieldTest.php index ba3361f06..8012554d6 100644 --- a/tests/forms/GridFieldTest.php +++ b/tests/forms/GridFieldTest.php @@ -32,7 +32,7 @@ class GridFieldTest extends SapphireTest { new GridFieldToolbarHeader(), new GridFieldSortableHeader, new GridFieldFilterHeader, - new GridFieldDefaultColumns, + new GridFieldDataColumns, new GridFieldPaginator, new GridState_Component, )); @@ -48,13 +48,13 @@ class GridFieldTest extends SapphireTest { $config = GridFieldConfig::create(); $config->addComponent(new GridFieldSortableHeader()); - $config->addComponent(new GridFieldDefaultColumns()); + $config->addComponent(new GridFieldDataColumns()); $obj = new GridField('testfield', 'testfield', ArrayList::create(array()),$config); $expectedComponents = new ArrayList(array( 0 => new GridFieldSortableHeader, - 1 => new GridFieldDefaultColumns, + 1 => new GridFieldDataColumns, 2 => new GridState_Component, )); @@ -430,7 +430,7 @@ class GridFieldTest extends SapphireTest { )); $config = new GridFieldConfig(); - $config->addComponent(new GridFieldDefaultColumns()); + $config->addComponent(new GridFieldDataColumns()); $obj = new GridField('testfield', 'testfield', $list, $config); $form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList()); $content = new CSSContentParser($obj->FieldHolder()); diff --git a/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php b/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php index 102660271..76d91b63e 100644 --- a/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php +++ b/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php @@ -75,7 +75,7 @@ class GridFieldAddExistingAutocompleterTest_Controller extends Controller implem $player = DataObject::get('GridFieldTest_Player')->find('Email', 'player1@test.com'); $config = GridFieldConfig::create()->addComponents( $relationComponent = new GridFieldAddExistingAutocompleter('Name'), - new GridFieldDefaultColumns() + new GridFieldDataColumns() ); $field = new GridField('testfield', 'testfield', $player->Teams(), $config); return new Form($this, 'Form', new FieldList($field), new FieldList());