FIX Improve GridFieldViewButton to work with new Archive Admin (#8240)

* Add gridfield restore action, enable view button in action menu

* Abstract restore action and create test

* Use more appropriate canRestoreToDraft and isArchived, move translations

* Use Hierarchy to determine if a record should be restored to root

* Move restore action to versioned
This commit is contained in:
Luke Edwards 2018-07-13 10:45:13 +12:00 committed by Maxime Rainville
parent 6e00d90783
commit 599a4420bf
3 changed files with 37 additions and 2 deletions

View File

@ -97,6 +97,8 @@ en:
Save: Save
SilverStripe\Forms\GridField\GridFieldEditButton:
EDIT: Edit
SilverStripe\Forms\GridField\GridFieldViewButton:
VIEW: View
SilverStripe\Forms\GridField\GridFieldGroupDeleteAction:
UnlinkSelfFailure: 'Cannot remove yourself from this group, you will lose admin rights'
SilverStripe\Forms\GridField\GridFieldPaginator:

View File

@ -11,8 +11,41 @@ use SilverStripe\View\SSViewer;
* disabled by default and intended for use in readonly {@link GridField}
* instances.
*/
class GridFieldViewButton implements GridField_ColumnProvider
class GridFieldViewButton implements GridField_ColumnProvider, GridField_ActionMenuLink
{
/**
* @inheritdoc
*/
public function getTitle($gridField, $record, $columnName)
{
return _t(__CLASS__ . '.VIEW', "View");
}
/**
* @inheritdoc
*/
public function getGroup($gridField, $record, $columnName)
{
return GridField_ActionMenuItem::DEFAULT_GROUP;
}
/**
* @inheritdoc
*/
public function getExtraData($gridField, $record, $columnName)
{
return [
"classNames" => "font-icon-eye action-detail view-link"
];
}
/**
* @inheritdoc
*/
public function getUrl($gridField, $record, $columnName)
{
return Controller::join_links($gridField->Link('item'), $record->ID, 'view');
}
public function augmentColumns($field, &$columns)
{

View File

@ -1,3 +1,3 @@
<a class="grid-field__icon-action font-icon-right-open btn--icon-large action action-detail view-link" href="$Link">
<a class="grid-field__icon-action font-icon-right-open btn--icon-large action action-detail view-link action-menu--handled" href="$Link">
<span class="sr-only">View</span>
</a>