diff --git a/admin/code/ModelAdmin.php b/admin/code/ModelAdmin.php index c30c496d7..9f6d143a0 100644 --- a/admin/code/ModelAdmin.php +++ b/admin/code/ModelAdmin.php @@ -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; diff --git a/admin/code/SecurityAdmin.php b/admin/code/SecurityAdmin.php index a3c8886da..6f44b6a89 100755 --- a/admin/code/SecurityAdmin.php +++ b/admin/code/SecurityAdmin.php @@ -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', diff --git a/admin/tests/SecurityAdminTest.php b/admin/tests/SecurityAdminTest.php index d9470c032..961597954 100644 --- a/admin/tests/SecurityAdminTest.php +++ b/admin/tests/SecurityAdminTest.php @@ -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')); diff --git a/control/Director.php b/control/Director.php index 403b01bc1..5d00b4c45 100644 --- a/control/Director.php +++ b/control/Director.php @@ -802,19 +802,31 @@ class Director implements TemplateGlobalProvider { /** * This function will return true if the site is in a development environment. * For information about environment types, see {@link Director::set_environment_type()}. + * @param $dontTouchDB If true, the database checks are not performed, which allows certain DB checks + * to not fail before the DB is ready. If false (default), DB checks are included. */ - static function isDev() { + static function isDev($dontTouchDB = false) { // This variable is used to supress repetitions of the isDev security message below. static $firstTimeCheckingGetVar = true; + + $result = false; + + if(isset($_SESSION['isDev']) && $_SESSION['isDev']) $result = true; + if(self::$environment_type && self::$environment_type == 'dev') $result = true; + + if(!empty(Director::$dev_servers)) { + Deprecation::notice('3.0', 'Director::$dev_servers doesn\'t work anymore'); + } // Use ?isDev=1 to get development access on the live server - if(isset($_GET['isDev'])) { + if(!$dontTouchDB && !$result && isset($_GET['isDev'])) { if(Security::database_is_ready()) { if($firstTimeCheckingGetVar && !Permission::check('ADMIN')){ BasicAuth::requireLogin("SilverStripe developer access. Use your CMS login", "ADMIN"); } $_SESSION['isDev'] = $_GET['isDev']; - if($firstTimeCheckingGetVar) $firstTimeCheckingGetVar = false; + $firstTimeCheckingGetVar = false; + $result = $_GET['isDev']; } else { if($firstTimeCheckingGetVar && DB::connection_attempted()) { echo "

addComponent(new GridFieldFilter()); + $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. @@ -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 @@ -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. @@ -293,7 +293,7 @@ Here is an example in full. The actual implementation of the view and edit form * - /field//item/ * - /field//item//edit */ - class GridFieldPopupForms implements GridField_URLHandler { + class GridFieldDetailForm implements GridField_URLHandler { public function getURLHandlers($gridField) { return array( 'item/$ID' => 'handleItem', diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index a372676b8..a18f8ebb6 100644 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -355,8 +355,8 @@ class HtmlEditorField_Toolbar extends RequestHandler { $fileFieldConfig = GridFieldConfig::create(); $fileFieldConfig->addComponent(new GridFieldSortableHeader()); - $fileFieldConfig->addComponent(new GridFieldFilter()); - $fileFieldConfig->addComponent(new GridFieldDefaultColumns()); + $fileFieldConfig->addComponent(new GridFieldFilterHeader()); + $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 8043b18d8..80249b083 100644 --- a/forms/UploadField.php +++ b/forms/UploadField.php @@ -846,8 +846,8 @@ class UploadField_SelectHandler extends RequestHandler { $folder = $this->getFolder(); $config = GridFieldConfig::create(); $config->addComponent(new GridFieldSortableHeader()); - $config->addComponent(new GridFieldFilter()); - $config->addComponent(new GridFieldDefaultColumns()); + $config->addComponent(new GridFieldFilterHeader()); + $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/GridFieldRelationAdd.php b/forms/gridfield/GridFieldAddExistingAutocompleter.php similarity index 95% rename from forms/gridfield/GridFieldRelationAdd.php rename to forms/gridfield/GridFieldAddExistingAutocompleter.php index d6e4bf2f2..04f81e832 100755 --- a/forms/gridfield/GridFieldRelationAdd.php +++ b/forms/gridfield/GridFieldAddExistingAutocompleter.php @@ -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) ); } 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 ce9a3304e..76ad37a6b 100755 --- a/forms/gridfield/GridFieldConfig.php +++ b/forms/gridfield/GridFieldConfig.php @@ -131,10 +131,10 @@ 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 GridFieldDefaultColumns()); + $this->addComponent(new GridFieldFilterHeader()); + $this->addComponent(new GridFieldDataColumns()); $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 GridFieldDefaultColumns()); - $this->addComponent(new GridFieldEditAction()); + $this->addComponent(new GridFieldFilterHeader()); + $this->addComponent(new GridFieldDataColumns()); + $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. * * GridFieldConfig_RelationEditor::create() - * ->getComponentByType('GridFieldRelationAdd')->setSearchFields('MyField'); + * ->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields('MyField'); * */ 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 GridFieldDefaultColumns()); - $this->addComponent(new GridFieldEditAction()); - $this->addComponent(new GridFieldRelationDelete()); + $this->addComponent(new GridFieldFilterHeader()); + $this->addComponent(new GridFieldDataColumns()); + $this->addComponent(new GridFieldEditButton()); + $this->addComponent(new GridFieldDeleteAction(true)); $this->addComponent(new GridFieldPaginator($itemsPerPage)); - $this->addComponent(new GridFieldPopupForms()); + $this->addComponent(new GridFieldDetailForm()); } } 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/forms/gridfield/GridFieldDeleteAction.php b/forms/gridfield/GridFieldDeleteAction.php index f2837fed4..2685fcfe2 100644 --- a/forms/gridfield/GridFieldDeleteAction.php +++ b/forms/gridfield/GridFieldDeleteAction.php @@ -1,10 +1,28 @@ removeRelation = $unlinkRelation; + } + /** * Add a column 'Delete' * @@ -58,7 +76,7 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio * @return array */ public function getActions($gridField) { - return array('deleterecord'); + return array('deleterecord', 'unlinkrelation'); } /** @@ -69,19 +87,20 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio * @return string - the HTML for the column */ public function getColumnContent($gridField, $record, $columnName) { - if(!$record->canDelete()) { - return; + if($this->removeRelation) { + $field = Object::create('GridField_FormAction', $gridField, 'UnlinkRelation'.$record->ID, false, "unlinkrelation", array('RecordID' => $record->ID)) + ->addExtraClass('gridfield-button-unlink') + ->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink")) + ->setAttribute('data-icon', 'chain--minus'); + } else { + if(!$record->canDelete()) { + return; + } + $field = Object::create('GridField_FormAction', $gridField, 'DeleteRecord'.$record->ID, false, "deleterecord", array('RecordID' => $record->ID)) + ->addExtraClass('gridfield-button-delete') + ->setAttribute('title', _t('GridAction.Delete', "Delete")) + ->setAttribute('data-icon', 'decline'); } - $field = Object::create('GridField_FormAction', - $gridField, - 'DeleteRecord'.$record->ID, - false, - "deleterecord", - array('RecordID' => $record->ID) - ) - ->addExtraClass('gridfield-button-delete') - ->setAttribute('title', _t('GridAction.Delete', "delete")) - ->setAttribute('data-icon', 'decline'); return $field->Field(); } @@ -95,15 +114,15 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio * @return void */ 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. - $item = $gridField->getList()->byID($id); - if(!$item->canDelete()) { + if($actionName == 'deleterecord' || $actionName == 'unlinkrelation') { + $item = $gridField->getList()->byID($arguments['RecordID']); + if(!$item) { + return; + } + if($actionName == 'deleterecord' && !$item->canDelete()) { throw new ValidationException(_t('GridFieldAction_Delete.DeletePermissionsFailure',"No delete permissions"),0); } - if(!$item) return; - $item->delete(); - } + $gridField->getList()->remove($item); + } } } \ No newline at end of file diff --git a/forms/gridfield/GridFieldPopupForms.php b/forms/gridfield/GridFieldDetailForm.php similarity index 98% rename from forms/gridfield/GridFieldPopupForms.php rename to forms/gridfield/GridFieldDetailForm.php index cdd500f46..6b9a1a3df 100755 --- a/forms/gridfield/GridFieldPopupForms.php +++ b/forms/gridfield/GridFieldDetailForm.php @@ -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: * - /field//item/ * - /field//item//edit */ -class GridFieldPopupForms implements GridField_URLHandler { +class GridFieldDetailForm implements GridField_URLHandler { /** * @var String */ - protected $template = 'GridFieldPopupForms'; + protected $template = 'GridFieldDetailForm'; /** * diff --git a/forms/gridfield/GridFieldEditAction.php b/forms/gridfield/GridFieldEditButton.php similarity index 92% rename from forms/gridfield/GridFieldEditAction.php rename to forms/gridfield/GridFieldEditButton.php index 0425f4f51..32bf2943d 100644 --- a/forms/gridfield/GridFieldEditAction.php +++ b/forms/gridfield/GridFieldEditButton.php @@ -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'); } /** diff --git a/forms/gridfield/GridFieldExporter.php b/forms/gridfield/GridFieldExportButton.php similarity index 96% rename from forms/gridfield/GridFieldExporter.php rename to forms/gridfield/GridFieldExportButton.php index 1229ceb24..f853041ce 100644 --- a/forms/gridfield/GridFieldExporter.php +++ b/forms/gridfield/GridFieldExportButton.php @@ -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. diff --git a/forms/gridfield/GridFieldFilter.php b/forms/gridfield/GridFieldFilterHeader.php similarity index 82% rename from forms/gridfield/GridFieldFilter.php rename to forms/gridfield/GridFieldFilterHeader.php index 86bc381f8..4990efe60 100644 --- a/forms/gridfield/GridFieldFilter.php +++ b/forms/gridfield/GridFieldFilterHeader.php @@ -1,13 +1,13 @@ 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'), ); } } diff --git a/forms/gridfield/GridFieldRelationDelete.php b/forms/gridfield/GridFieldRelationDelete.php deleted file mode 100644 index ed81542bb..000000000 --- a/forms/gridfield/GridFieldRelationDelete.php +++ /dev/null @@ -1,106 +0,0 @@ - ''); - } - } - - /** - * 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('unlinkrelation'); - } - - /** - * - * @param GridField $gridField - * @param DataObject $record - * @param string $columnName - * @return string - the HTML for the column - */ - public function getColumnContent($gridField, $record, $columnName) { - $field = Object::create('GridField_FormAction', - $gridField, - 'UnlinkRelation'.$record->ID, - false, - "unlinkrelation", - array('RecordID' => $record->ID) - ) - ->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink")) - ->setAttribute('data-icon', 'chain--minus') - ->addExtraClass('gridfield-button-unlink'); - return $field->Field(); - } - - /** - * 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) { - $id = $arguments['RecordID']; - $item = $gridField->getList()->byID($id); - if(!$item) return; - if($actionName == 'unlinkrelation') { - $gridField->getList()->remove($item); - } - } -} diff --git a/forms/gridfield/GridFieldTitle.php b/forms/gridfield/GridFieldToolbarHeader.php similarity index 93% rename from forms/gridfield/GridFieldTitle.php rename to forms/gridfield/GridFieldToolbarHeader.php index 31bceb52d..e8b140e28 100644 --- a/forms/gridfield/GridFieldTitle.php +++ b/forms/gridfield/GridFieldToolbarHeader.php @@ -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') ); } diff --git a/model/MySQLDatabase.php b/model/MySQLDatabase.php index a5ea5a596..b8965ee64 100644 --- a/model/MySQLDatabase.php +++ b/model/MySQLDatabase.php @@ -109,13 +109,13 @@ class MySQLDatabase extends SS_Database { return; } - if(isset($_REQUEST['showqueries'])) { + if(isset($_REQUEST['showqueries']) && Director::isDev(true)) { $starttime = microtime(true); } $handle = $this->dbConn->query($sql); - if(isset($_REQUEST['showqueries'])) { + if(isset($_REQUEST['showqueries']) && Director::isDev(true)) { $endtime = round(microtime(true) - $starttime,4); Debug::message("\n$sql\n{$endtime}ms\n", false); } diff --git a/security/Group.php b/security/Group.php index 411c50aea..bd692d0ad 100755 --- a/security/Group.php +++ b/security/Group.php @@ -88,15 +88,15 @@ class Group extends DataObject { $parentidfield->setRightTitle('' . _t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles') . ''); // 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')); diff --git a/templates/GridFieldPopupForms.ss b/templates/GridFieldDetailForm.ss similarity index 100% rename from templates/GridFieldPopupForms.ss rename to templates/GridFieldDetailForm.ss diff --git a/templates/Includes/GridFieldRelationAdd.ss b/templates/Includes/GridFieldAddExistingAutocompleter.ss similarity index 100% rename from templates/Includes/GridFieldRelationAdd.ss rename to templates/Includes/GridFieldAddExistingAutocompleter.ss diff --git a/templates/Includes/GridFieldEditAction.ss b/templates/Includes/GridFieldEditButton.ss similarity index 100% rename from templates/Includes/GridFieldEditAction.ss rename to templates/Includes/GridFieldEditButton.ss diff --git a/templates/Includes/GridFieldFilter_Row.ss b/templates/Includes/GridFieldFilterHeader_Row.ss similarity index 100% rename from templates/Includes/GridFieldFilter_Row.ss rename to templates/Includes/GridFieldFilterHeader_Row.ss diff --git a/templates/Includes/GridFieldTitle.ss b/templates/Includes/GridFieldToolbarHeader.ss similarity index 100% rename from templates/Includes/GridFieldTitle.ss rename to templates/Includes/GridFieldToolbarHeader.ss diff --git a/tests/forms/GridFieldTest.php b/tests/forms/GridFieldTest.php index 5617bda17..8012554d6 100644 --- a/tests/forms/GridFieldTest.php +++ b/tests/forms/GridFieldTest.php @@ -29,10 +29,10 @@ class GridFieldTest extends SapphireTest { $obj = new GridField('testfield', 'testfield'); $expectedComponents = new ArrayList(array( - new GridFieldTitle(), + new GridFieldToolbarHeader(), new GridFieldSortableHeader, - new GridFieldFilter, - new GridFieldDefaultColumns, + new GridFieldFilterHeader, + 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/GridFieldRelationAddTest.php b/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php similarity index 78% rename from tests/forms/gridfield/GridFieldRelationAddTest.php rename to tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php index 82d6fbc7e..76d91b63e 100644 --- a/tests/forms/gridfield/GridFieldRelationAddTest.php +++ b/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php @@ -1,5 +1,5 @@ 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,15 +67,15 @@ 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'), - new GridFieldDefaultColumns() + $relationComponent = new GridFieldAddExistingAutocompleter('Name'), + new GridFieldDataColumns() ); $field = new GridField('testfield', 'testfield', $player->Teams(), $config); return new Form($this, 'Form', new FieldList($field), new FieldList()); diff --git a/tests/forms/gridfield/GridFieldDeleteActionTest.php b/tests/forms/gridfield/GridFieldDeleteActionTest.php index 750123207..3c09d7b6a 100644 --- a/tests/forms/gridfield/GridFieldDeleteActionTest.php +++ b/tests/forms/gridfield/GridFieldDeleteActionTest.php @@ -60,6 +60,23 @@ class GridFieldDeleteActionTest extends SapphireTest { $this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request); $this->assertEquals(2, $this->list->count(), 'User should be able to delete records with ADMIN permission.'); } + + public function testDeleteActionRemoveRelation() { + $this->logInWithPermission('ADMIN'); + + $config = GridFieldConfig::create()->addComponent(new GridFieldDeleteAction(true)); + + $gridField = new GridField('testfield', 'testfield', $this->list, $config); + $form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList()); + + $stateID = 'testGridStateActionField'; + Session::set($stateID, array('grid'=>'', 'actionName'=>'deleterecord','args'=>array('RecordID'=>1))); + $request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID='.$stateID=>true)); + + $this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request); + $this->assertEquals(2, $this->list->count(), 'User should be able to delete records with ADMIN permission.'); + + } } class GridFieldAction_Delete_Team extends DataObject implements TestOnly { diff --git a/tests/forms/gridfield/GridFieldPopupFormsTest.php b/tests/forms/gridfield/GridFieldDetailFormTest.php similarity index 78% rename from tests/forms/gridfield/GridFieldPopupFormsTest.php rename to tests/forms/gridfield/GridFieldDetailFormTest.php index 178a6b335..5bb4e89d8 100644 --- a/tests/forms/gridfield/GridFieldPopupFormsTest.php +++ b/tests/forms/gridfield/GridFieldDetailFormTest.php @@ -1,23 +1,23 @@ 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'); @@ -40,7 +40,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()); @@ -48,13 +48,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'); @@ -77,7 +77,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(); @@ -87,18 +87,18 @@ class GridFieldPopupFormsTest extends FunctionalTest { function testNestedEditForm() { $this->logInWithPermission('ADMIN'); - $group = $this->objFromFixture('GridFieldPopupFormsTest_PeopleGroup', 'group'); + $group = $this->objFromFixture('GridFieldDetailFormTest_PeopleGroup', 'group'); $person = $group->People()->First(); $category = $person->Categories()->First(); // Get first form (GridField managing PeopleGroup) - $response = $this->get('GridFieldPopupFormsTest_GroupController'); + $response = $this->get('GridFieldDetailFormTest_GroupController'); $this->assertFalse($response->isError()); $parser = new CSSContentParser($response->getBody()); $groupEditLink = $parser->getByXpath('//tr[contains(@class, "ss-gridfield-item") and contains(@data-id, "' . $group->ID . '")]//a'); $this->assertEquals( - 'GridFieldPopupFormsTest_GroupController/Form/field/testfield/item/1/edit', + 'GridFieldDetailFormTest_GroupController/Form/field/testfield/item/1/edit', (string)$groupEditLink[0]['href'] ); @@ -108,7 +108,7 @@ class GridFieldPopupFormsTest extends FunctionalTest { $parser = new CSSContentParser($response->getBody()); $personEditLink = $parser->getByXpath('//fieldset[@id="Form_ItemEditForm_People"]//tr[contains(@class, "ss-gridfield-item") and contains(@data-id, "' . $person->ID . '")]//a'); $this->assertEquals( - 'GridFieldPopupFormsTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/1/edit', + 'GridFieldDetailFormTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/1/edit', (string)$personEditLink[0]['href'] ); @@ -120,24 +120,24 @@ class GridFieldPopupFormsTest extends FunctionalTest { // Get fourth level form (Category detail view) $this->assertEquals( - 'GridFieldPopupFormsTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/1/ItemEditForm/field/Categories/item/1/edit', + 'GridFieldDetailFormTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/1/ItemEditForm/field/Categories/item/1/edit', (string)$categoryEditLink[0]['href'] ); } } -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' ); static $many_many = array( - 'Categories' => 'GridFieldPopupFormsTest_Category' + 'Categories' => 'GridFieldDetailFormTest_Category' ); function getCMSFields() { @@ -153,13 +153,13 @@ class GridFieldPopupFormsTest_Person extends DataObject implements TestOnly { } } -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' ); function getCMSFields() { @@ -175,13 +175,13 @@ class GridFieldPopupFormsTest_PeopleGroup extends DataObject implements TestOnly } } -class GridFieldPopupFormsTest_Category extends DataObject implements TestOnly { +class GridFieldDetailFormTest_Category extends DataObject implements TestOnly { static $db = array( 'Name' => 'Varchar' ); static $belongs_many_many = array( - 'People' => 'GridFieldPopupFormsTest_Person' + 'People' => 'GridFieldDetailFormTest_Person' ); function getCMSFields() { @@ -197,26 +197,26 @@ class GridFieldPopupFormsTest_Category extends DataObject implements TestOnly { } } -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()); } } -class GridFieldPopupFormsTest_GroupController extends Controller implements TestOnly { +class GridFieldDetailFormTest_GroupController extends Controller implements TestOnly { protected $template = 'BlankPage'; function Form() { - $field = new GridField('testfield', 'testfield', DataList::create('GridFieldPopupFormsTest_PeopleGroup')); + $field = new GridField('testfield', 'testfield', DataList::create('GridFieldDetailFormTest_PeopleGroup')); $field->getConfig()->addComponent($gridFieldForm = new GridFieldPopupForms($this, 'Form')); $field->getConfig()->addComponent(new GridFieldEditAction()); return new Form($this, 'Form', new FieldList($field), new FieldList()); diff --git a/tests/forms/gridfield/GridFieldDetailFormTest.yml b/tests/forms/gridfield/GridFieldDetailFormTest.yml new file mode 100644 index 000000000..9c9b0749d --- /dev/null +++ b/tests/forms/gridfield/GridFieldDetailFormTest.yml @@ -0,0 +1,17 @@ +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 + +GridFieldDetailFormTest_Category: + category1: + Name: Category 1 + People: =>GridFieldDetailFormTest_Person.joe,=>GridFieldDetailFormTest_Person.jane \ No newline at end of file diff --git a/tests/forms/gridfield/GridFieldEditActionTest.php b/tests/forms/gridfield/GridFieldEditButtonTest.php similarity index 96% rename from tests/forms/gridfield/GridFieldEditActionTest.php rename to tests/forms/gridfield/GridFieldEditButtonTest.php index 07ef784b4..13b3b045b 100644 --- a/tests/forms/gridfield/GridFieldEditActionTest.php +++ b/tests/forms/gridfield/GridFieldEditButtonTest.php @@ -1,6 +1,6 @@ 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()); } diff --git a/tests/forms/gridfield/GridFieldPopupFormsTest.yml b/tests/forms/gridfield/GridFieldPopupFormsTest.yml deleted file mode 100644 index 30bc00f2f..000000000 --- a/tests/forms/gridfield/GridFieldPopupFormsTest.yml +++ /dev/null @@ -1,17 +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 - -GridFieldPopupFormsTest_Category: - category1: - Name: Category 1 - People: =>GridFieldPopupFormsTest_Person.joe,=>GridFieldPopupFormsTest_Person.jane \ No newline at end of file diff --git a/tests/forms/gridfield/GridFieldTitleTest.php b/tests/forms/gridfield/GridFieldToolbarHeaderTest.php similarity index 87% rename from tests/forms/gridfield/GridFieldTitleTest.php rename to tests/forms/gridfield/GridFieldToolbarHeaderTest.php index 11ab670d2..2f67df433 100644 --- a/tests/forms/gridfield/GridFieldTitleTest.php +++ b/tests/forms/gridfield/GridFieldToolbarHeaderTest.php @@ -1,12 +1,12 @@ 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());