mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
FEATURE: Added utility functions to make it easier to allow a GridFieldBulkManager to manage versioned objects
This commit is contained in:
parent
96617d578a
commit
4ce1cc5c24
@ -136,6 +136,32 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an action to the dropdown
|
||||
*
|
||||
* @param string $className
|
||||
* @return GridFieldBulkManager
|
||||
*/
|
||||
function addDropdownAction ( $action, $label = '' )
|
||||
{
|
||||
if(!$label) $label = $action;
|
||||
$this->config['actions'][$action] = $label;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an action from the dropdown
|
||||
*
|
||||
* @param string $className
|
||||
* @return GridFieldBulkManager
|
||||
*/
|
||||
function removeDropdownAction ( $action )
|
||||
{
|
||||
if(isset($this->config['actions'][$action]))
|
||||
unset($this->config['actions'][$action]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/* GridField_ColumnProvider */
|
||||
|
||||
@ -251,4 +277,13 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
||||
return 'GridFieldBulkManager_Request';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the manager to use actions applicable to versioned dataobjects
|
||||
*/
|
||||
public function applyVersioned() {
|
||||
$this->addDropdownAction('publish', _t('GridFieldBulkTools.PUBLISH_SELECT_LABEL', 'Publish'));
|
||||
$this->addDropdownAction('unpublish', _t('GridFieldBulkTools.UNPUBLISH_SELECT_LABEL', 'Unpublish'));
|
||||
$this->setBulkEditRequestClass('VersionedGridFieldBulkManager_Request');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user