mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
1747298786
commit
16982ba17c
@ -68,7 +68,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
if($record && !$record->canView()) return Security::permissionFailure($this);
|
if($record && !$record->canView()) return Security::permissionFailure($this);
|
||||||
|
|
||||||
$memberList = GridField::create(
|
$memberList = GridField::create(
|
||||||
'Members',
|
'Member',
|
||||||
false,
|
false,
|
||||||
DataList::create('Member'),
|
DataList::create('Member'),
|
||||||
$memberListConfig = GridFieldConfig_RecordEditor::create()
|
$memberListConfig = GridFieldConfig_RecordEditor::create()
|
||||||
@ -77,7 +77,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
|
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
|
||||||
|
|
||||||
$groupList = GridField::create(
|
$groupList = GridField::create(
|
||||||
'Groups',
|
'Group',
|
||||||
false,
|
false,
|
||||||
DataList::create('Group'),
|
DataList::create('Group'),
|
||||||
GridFieldConfig_RecordEditor::create()
|
GridFieldConfig_RecordEditor::create()
|
||||||
@ -129,7 +129,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
// Add roles editing interface
|
// Add roles editing interface
|
||||||
if(Permission::check('APPLY_ROLES')) {
|
if(Permission::check('APPLY_ROLES')) {
|
||||||
$rolesField = GridField::create('Roles',
|
$rolesField = GridField::create('Role',
|
||||||
false,
|
false,
|
||||||
DataList::create('PermissionRole'),
|
DataList::create('PermissionRole'),
|
||||||
GridFieldConfig_RecordEditor::create()
|
GridFieldConfig_RecordEditor::create()
|
||||||
|
@ -57,6 +57,8 @@ class GridField extends FormField {
|
|||||||
*/
|
*/
|
||||||
protected $columnDispatch = null;
|
protected $columnDispatch = null;
|
||||||
|
|
||||||
|
protected $name = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new GridField field
|
* 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) {
|
public function __construct($name, $title = null, SS_List $dataList = null, GridFieldConfig $config = null) {
|
||||||
parent::__construct($name, $title, null);
|
parent::__construct($name, $title, null);
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
if($dataList) {
|
if($dataList) {
|
||||||
$this->setList($dataList);
|
$this->setList($dataList);
|
||||||
@ -81,7 +84,6 @@ class GridField extends FormField {
|
|||||||
$this->config->addComponent(new GridState_Component());
|
$this->config->addComponent(new GridState_Component());
|
||||||
$this->state = new GridState($this);
|
$this->state = new GridState($this);
|
||||||
|
|
||||||
|
|
||||||
$this->addExtraClass('ss-gridfield');
|
$this->addExtraClass('ss-gridfield');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ class GridFieldAddNewButton implements GridField_HTMLProvider {
|
|||||||
public function getHTMLFragments($gridField) {
|
public function getHTMLFragments($gridField) {
|
||||||
$data = new ArrayData(array(
|
$data = new ArrayData(array(
|
||||||
'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
|
'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
|
||||||
|
'ButtonName' => _t('GridField.Add', 'Add') . ' ' . _t('GridField.' . $gridField -> name, $gridField -> name),
|
||||||
));
|
));
|
||||||
return array(
|
return array(
|
||||||
$this->targetFragment => $data->renderWith('GridFieldAddNewbutton'),
|
$this->targetFragment => $data->renderWith('GridFieldAddNewbutton'),
|
||||||
|
@ -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>
|
Loading…
Reference in New Issue
Block a user