ENHANCEMENT: Make GridFieldAddNewButton Content more specific

* Alter Grid Field "Add New" Button to take the name of the table (i.e.
"Add Member")
* Alter table names in security section to be singular so the button
text makes sense
This commit is contained in:
Naomi Guyer 2012-05-21 17:47:14 +12:00
parent 1747298786
commit 16982ba17c
4 changed files with 11 additions and 6 deletions

View File

@ -68,7 +68,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
if($record && !$record->canView()) return Security::permissionFailure($this);
$memberList = GridField::create(
'Members',
'Member',
false,
DataList::create('Member'),
$memberListConfig = GridFieldConfig_RecordEditor::create()
@ -77,7 +77,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
$groupList = GridField::create(
'Groups',
'Group',
false,
DataList::create('Group'),
GridFieldConfig_RecordEditor::create()
@ -129,7 +129,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
// Add roles editing interface
if(Permission::check('APPLY_ROLES')) {
$rolesField = GridField::create('Roles',
$rolesField = GridField::create('Role',
false,
DataList::create('PermissionRole'),
GridFieldConfig_RecordEditor::create()

View File

@ -57,6 +57,8 @@ class GridField extends FormField {
*/
protected $columnDispatch = null;
protected $name = '';
/**
* Creates a new GridField field
*
@ -67,6 +69,7 @@ class GridField extends FormField {
*/
public function __construct($name, $title = null, SS_List $dataList = null, GridFieldConfig $config = null) {
parent::__construct($name, $title, null);
$this->name = $name;
if($dataList) {
$this->setList($dataList);
@ -79,8 +82,7 @@ class GridField extends FormField {
}
$this->config->addComponent(new GridState_Component());
$this->state = new GridState($this);
$this->state = new GridState($this);
$this->addExtraClass('ss-gridfield');
}

View File

@ -15,6 +15,7 @@ class GridFieldAddNewButton implements GridField_HTMLProvider {
public function getHTMLFragments($gridField) {
$data = new ArrayData(array(
'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
'ButtonName' => _t('GridField.Add', 'Add') . ' ' . _t('GridField.' . $gridField -> name, $gridField -> name),
));
return array(
$this->targetFragment => $data->renderWith('GridFieldAddNewbutton'),

View File

@ -1 +1,3 @@
<a href="$NewLink" class="action action-detail ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all new new-link" data-icon="add"><% _t('GridField.AddNew', 'Add New') %></a>
<a href="$NewLink" class="action action-detail ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all new new-link" data-icon="add">
$ButtonName
</a>