API CHANGE: Renaming of gridfield components #6921

This commit is contained in:
Stig Lindqvist 2012-03-09 12:54:02 +13:00
parent 31ce29fa0b
commit 8b82dae06c
28 changed files with 108 additions and 108 deletions

View File

@ -710,7 +710,7 @@ class ModelAdmin_CollectionController extends Controller {
false,
$datalist,
$fieldConfig = GridFieldConfig_RecordEditor::create($numItemsPerPage)
->addComponent(new GridFieldExporter())->removeComponentsByType('GridFieldFilter')
->addComponent(new GridFieldExportButton())->removeComponentsByType('GridFieldFilterHeader')
)->setDisplayFields($this->getResultColumns($searchCriteria));
return $tf;

View File

@ -48,9 +48,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
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',

View File

@ -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'));

View File

@ -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',

View File

@ -355,7 +355,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
$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);

View File

@ -846,7 +846,7 @@ class UploadField_SelectHandler extends RequestHandler {
$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));

View File

@ -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 @@ class GridFieldRelationAdd implements GridField_HTMLProvider, GridField_ActionPr
$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)
);
}

View File

@ -131,9 +131,9 @@ class GridFieldConfig_Base extends GridFieldConfig {
* @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 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig {
* @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 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig {
* 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 @@ class GridFieldConfig_RelationEditor extends GridFieldConfig {
* @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());
}
}

View File

@ -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 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio
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);

View File

@ -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';
/**
*

View File

@ -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 @@ class GridFieldEditAction implements GridField_ColumnProvider {
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
));
return $data->renderWith('GridFieldEditAction');
return $data->renderWith('GridFieldEditButton');
}
/**

View File

@ -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.

View 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 @@ class GridFieldFilter implements GridField_HTMLProvider, GridField_DataManipulat
}
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 @@ class GridFieldFilter implements GridField_HTMLProvider, GridField_DataManipulat
* @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 @@ class GridFieldFilter implements GridField_HTMLProvider, GridField_DataManipulat
$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 @@ class GridFieldFilter implements GridField_HTMLProvider, GridField_DataManipulat
}
return array(
'header' => $forTemplate->renderWith('GridFieldFilter_Row'),
'header' => $forTemplate->renderWith('GridFieldFilterHeader_Row'),
);
}
}

View File

@ -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'

View File

@ -14,7 +14,7 @@
* @package sapphire
* @subpackage gridfield
*/
class GridFieldTitle implements GridField_HTMLProvider {
class GridFieldToolbarHeader implements GridField_HTMLProvider {
/**
*
@ -34,7 +34,7 @@ class GridFieldTitle implements GridField_HTMLProvider {
'header' => $gridField->customise(array(
'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
'NewEnabled' => $this->getNewEnabled()
))->renderWith('GridFieldTitle')
))->renderWith('GridFieldToolbarHeader')
);
}

View File

@ -88,15 +88,15 @@ class Group extends DataObject {
$parentidfield->setRightTitle('<span class="aligned_right_label">' . _t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles') . '</span>');
// Filter permissions
// TODO SecurityAdmin coupling, not easy to get to the form fields through GridFieldPopupForms
// TODO SecurityAdmin coupling, not easy to get to the form fields through GridFieldDetailForm
$permissionsField->setHiddenPermissions(SecurityAdmin::$hidden_permissions);
if($this->ID) {
$config = new GridFieldConfig_RelationEditor();
$config->addComponents(new GridFieldExporter());
$config->getComponentByType('GridFieldRelationAdd')
$config->addComponents(new GridFieldExportButton());
$config->getComponentByType('GridFieldAddExistingAutocompleter')
->setResultsFormat('$Title ($Email)')->setSearchFields(array('FirstName', 'Surname', 'Email'));
$config->getComponentByType('GridFieldPopupForms')->setValidator(new Member_Validator());
$config->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
$memberList = Object::create('GridField', 'Members',false, $this->Members(), $config)->addExtraClass('members_grid');
// @todo Implement permission checking on GridField
//$memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));

View File

@ -29,9 +29,9 @@ class GridFieldTest extends SapphireTest {
$obj = new GridField('testfield', 'testfield');
$expectedComponents = new ArrayList(array(
new GridFieldTitle(),
new GridFieldToolbarHeader(),
new GridFieldSortableHeader,
new GridFieldFilter,
new GridFieldFilterHeader,
new GridFieldDefaultColumns,
new GridFieldPaginator,
new GridState_Component,

View File

@ -1,5 +1,5 @@
<?php
class GridFieldRelationAddTest extends FunctionalTest {
class GridFieldAddExistingAutocompleterTest extends FunctionalTest {
static $fixture_file = 'sapphire/tests/forms/gridfield/GridFieldTest.yml';
@ -9,13 +9,13 @@ class GridFieldRelationAddTest extends FunctionalTest {
$team1 = $this->objFromFixture('GridFieldTest_Team', 'team1');
$team2 = $this->objFromFixture('GridFieldTest_Team', 'team2');
$response = $this->get('GridFieldRelationAddTest_Controller');
$response = $this->get('GridFieldAddExistingAutocompleterTest_Controller');
$this->assertFalse($response->isError());
$parser = new CSSContentParser($response->getBody());
$btns = $parser->getBySelector('.ss-gridfield #action_gridfield_relationfind');
$response = $this->post(
'GridFieldRelationAddTest_Controller/Form/field/testfield/search/Team 2',
'GridFieldAddExistingAutocompleterTest_Controller/Form/field/testfield/search/Team 2',
array(
(string)$btns[0]['name'] => 1
)
@ -26,7 +26,7 @@ class GridFieldRelationAddTest extends FunctionalTest {
$this->assertEquals(array($team2->ID => 'Team 2'), $result);
$response = $this->post(
'GridFieldRelationAddTest_Controller/Form/field/testfield/search/Unknown',
'GridFieldAddExistingAutocompleterTest_Controller/Form/field/testfield/search/Unknown',
array(
(string)$btns[0]['name'] => 1
)
@ -41,7 +41,7 @@ class GridFieldRelationAddTest extends FunctionalTest {
$team1 = $this->objFromFixture('GridFieldTest_Team', 'team1');
$team2 = $this->objFromFixture('GridFieldTest_Team', 'team2');
$response = $this->get('GridFieldRelationAddTest_Controller');
$response = $this->get('GridFieldAddExistingAutocompleterTest_Controller');
$this->assertFalse($response->isError());
$parser = new CSSContentParser($response->getBody());
$items = $parser->getBySelector('.ss-gridfield .ss-gridfield-items .ss-gridfield-item');
@ -50,7 +50,7 @@ class GridFieldRelationAddTest extends FunctionalTest {
$btns = $parser->getBySelector('.ss-gridfield #action_gridfield_relationadd');
$response = $this->post(
'GridFieldRelationAddTest_Controller/Form/field/testfield',
'GridFieldAddExistingAutocompleterTest_Controller/Form/field/testfield',
array(
'relationID' => $team2->ID,
(string)$btns[0]['name'] => 1
@ -67,14 +67,14 @@ class GridFieldRelationAddTest extends FunctionalTest {
}
class GridFieldRelationAddTest_Controller extends Controller implements TestOnly {
class GridFieldAddExistingAutocompleterTest_Controller extends Controller implements TestOnly {
protected $template = 'BlankPage';
function Form() {
$player = DataObject::get('GridFieldTest_Player')->find('Email', 'player1@test.com');
$config = GridFieldConfig::create()->addComponents(
$relationComponent = new GridFieldRelationAdd('Name'),
$relationComponent = new GridFieldAddExistingAutocompleter('Name'),
new GridFieldDefaultColumns()
);
$field = new GridField('testfield', 'testfield', $player->Teams(), $config);

View File

@ -1,22 +1,22 @@
<?php
class GridFieldPopupFormsTest extends FunctionalTest {
static $fixture_file = 'GridFieldPopupFormsTest.yml';
class GridFieldDetailFormTest extends FunctionalTest {
static $fixture_file = 'GridFieldDetailFormTest.yml';
protected $extraDataObjects = array(
'GridFieldPopupFormsTest_Person',
'GridFieldPopupFormsTest_PeopleGroup'
'GridFieldDetailFormTest_Person',
'GridFieldDetailFormTest_PeopleGroup'
);
function testAddForm() {
$this->logInWithPermission('ADMIN');
$group = DataList::create('GridFieldPopupFormsTest_PeopleGroup')
$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
->filter('Name', 'My Group')
->First();
$count = $group->People()->Count();
$response = $this->get('GridFieldPopupFormsTest_Controller');
$response = $this->get('GridFieldDetailFormTest_Controller');
$this->assertFalse($response->isError());
$parser = new CSSContentParser($response->getBody());
$addlinkitem = $parser->getBySelector('.ss-gridfield .new-link');
@ -39,7 +39,7 @@ class GridFieldPopupFormsTest extends FunctionalTest {
);
$this->assertFalse($response->isError());
$group = DataList::create('GridFieldPopupFormsTest_PeopleGroup')
$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
->filter('Name', 'My Group')
->First();
$this->assertEquals($count + 1, $group->People()->Count());
@ -47,13 +47,13 @@ class GridFieldPopupFormsTest extends FunctionalTest {
function testEditForm() {
$this->logInWithPermission('ADMIN');
$group = DataList::create('GridFieldPopupFormsTest_PeopleGroup')
$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
->filter('Name', 'My Group')
->First();
$firstperson = $group->People()->First();
$this->assertTrue($firstperson->Surname != 'Baggins');
$response = $this->get('GridFieldPopupFormsTest_Controller');
$response = $this->get('GridFieldDetailFormTest_Controller');
$this->assertFalse($response->isError());
$parser = new CSSContentParser($response->getBody());
$editlinkitem = $parser->getBySelector('.ss-gridfield-items .first .edit-link');
@ -76,7 +76,7 @@ class GridFieldPopupFormsTest extends FunctionalTest {
);
$this->assertFalse($response->isError());
$group = DataList::create('GridFieldPopupFormsTest_PeopleGroup')
$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
->filter('Name', 'My Group')
->First();
$firstperson = $group->People()->First();
@ -84,38 +84,38 @@ class GridFieldPopupFormsTest extends FunctionalTest {
}
}
class GridFieldPopupFormsTest_Person extends DataObject implements TestOnly {
class GridFieldDetailFormTest_Person extends DataObject implements TestOnly {
static $db = array(
'FirstName' => 'Varchar',
'Surname' => 'Varchar'
);
static $has_one = array(
'Group' => 'GridFieldPopupFormsTest_PeopleGroup'
'Group' => 'GridFieldDetailFormTest_PeopleGroup'
);
}
class GridFieldPopupFormsTest_PeopleGroup extends DataObject implements TestOnly {
class GridFieldDetailFormTest_PeopleGroup extends DataObject implements TestOnly {
static $db = array(
'Name' => 'Varchar'
);
static $has_many = array(
'People' => 'GridFieldPopupFormsTest_Person'
'People' => 'GridFieldDetailFormTest_Person'
);
}
class GridFieldPopupFormsTest_Controller extends Controller implements TestOnly {
class GridFieldDetailFormTest_Controller extends Controller implements TestOnly {
protected $template = 'BlankPage';
function Form() {
$group = DataList::create('GridFieldPopupFormsTest_PeopleGroup')
$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
->filter('Name', 'My Group')
->First();
$field = new GridField('testfield', 'testfield', $group->People());
$field->getConfig()->addComponent($gridFieldForm = new GridFieldPopupForms($this, 'Form'));
$field->getConfig()->addComponent(new GridFieldEditAction());
$field->getConfig()->addComponent($gridFieldForm = new GridFieldDetailForm($this, 'Form'));
$field->getConfig()->addComponent(new GridFieldEditButton());
return new Form($this, 'Form', new FieldList($field), new FieldList());
}
}

View File

@ -0,0 +1,12 @@
GridFieldDetailFormTest_Person:
joe:
FirstName: Joe
Surname: Bloggs
jane:
FirstName: Jane
Surname: Doe
GridFieldDetailFormTest_PeopleGroup:
group:
Name: My Group
People: =>GridFieldDetailFormTest_Person.joe,=>GridFieldDetailFormTest_Person.jane

View File

@ -1,6 +1,6 @@
<?php
class GridFieldEditActionTest extends SapphireTest {
class GridFieldEditButtonTest extends SapphireTest {
/** @var ArrayList */
protected $list;
@ -20,7 +20,7 @@ class GridFieldEditActionTest extends SapphireTest {
public function setUp() {
parent::setUp();
$this->list = new DataList('GridFieldAction_Edit_Team');
$config = GridFieldConfig::create()->addComponent(new GridFieldEditAction());
$config = GridFieldConfig::create()->addComponent(new GridFieldEditButton());
$this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
$this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
}

View File

@ -1,12 +0,0 @@
GridFieldPopupFormsTest_Person:
joe:
FirstName: Joe
Surname: Bloggs
jane:
FirstName: Jane
Surname: Doe
GridFieldPopupFormsTest_PeopleGroup:
group:
Name: My Group
People: =>GridFieldPopupFormsTest_Person.joe,=>GridFieldPopupFormsTest_Person.jane

View File

@ -1,12 +1,12 @@
<?php
class GridFieldTitleTest extends SapphireTest {
class GridFieldToolbarHeaderTest extends SapphireTest {
public function testGridTitleAddNewEnabled() {
$this->logInWithPermission('ADMIN');
//construct a fake form field to render out the grid field within it
$config = new GridFieldConfig();
$config->addComponent($titleField = new GridFieldTitle());
$config->addComponent($titleField = new GridFieldToolbarHeader());
$actions = new FieldList();
$grid = new GridField('TestField', 'Test Field', new DataList('Company'),$config);
$fields = new FieldList($rootTab = new TabSet("Root",$tabMain = new Tab('Main',$grid)));
@ -21,7 +21,7 @@ class GridFieldTitleTest extends SapphireTest {
$this->logInWithPermission('ADMIN');
//construct a fake form field to render out the grid field within it
$config = new GridFieldConfig();
$config->addComponent($titleField = new GridFieldTitle());
$config->addComponent($titleField = new GridFieldToolbarHeader());
$actions = new FieldList();
$grid = new GridField('TestField', 'Test Field', new DataList('Company'),$config);
$fields = new FieldList($rootTab = new TabSet("Root",$tabMain = new Tab('Main',$grid)));
@ -35,7 +35,7 @@ class GridFieldTitleTest extends SapphireTest {
public function testGridTitleAddNewWithoutPermission() {
if(Member::currentUser()) { Member::currentUser()->logOut(); }
$config = new GridFieldConfig();
$config->addComponent($titleField = new GridFieldTitle());
$config->addComponent($titleField = new GridFieldToolbarHeader());
$grid = new GridField('TestField', 'Test Field', new DataList('Company'),$config);
$fields = new FieldList(new TabSet("Root",$tabMain = new Tab('Main',$grid)));
$form = new Form(Controller::curr(), "TestForm", $fields, new FieldList());