API bulk action names are case sensitive FIX #75

This commit is contained in:
Thierry François 2014-09-06 14:13:38 +03:00
parent 1010c9be6f
commit f4f0ac096e
3 changed files with 12 additions and 14 deletions

View File

@ -20,8 +20,8 @@ class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
* @var array * @var array
*/ */
private static $url_handlers = array( private static $url_handlers = array(
'bulkedit/update' => 'update', 'bulkEdit/update' => 'update',
'bulkedit' => 'edit' 'bulkEdit' => 'edit'
); );
@ -46,7 +46,7 @@ class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
->setAttribute('id', 'bulkEditingUpdateBtn') ->setAttribute('id', 'bulkEditingUpdateBtn')
->addExtraClass('ss-ui-action-constructive cms-panel-link') ->addExtraClass('ss-ui-action-constructive cms-panel-link')
->setAttribute('data-icon', 'accept') ->setAttribute('data-icon', 'accept')
->setAttribute('data-url', $this->gridField->Link('bulkaction/bulkedit/update')) ->setAttribute('data-url', $this->gridField->Link('bulkaction/bulkEdit/update'))
->setUseButtonTag(true) ->setUseButtonTag(true)
->setAttribute('src', '')//changes type to image so isn't hooked by default actions handlers ->setAttribute('src', '')//changes type to image so isn't hooked by default actions handlers
); );

View File

@ -6,13 +6,13 @@
* @package GridFieldBulkEditingTools * @package GridFieldBulkEditingTools
* @subpackage BulkManager * @subpackage BulkManager
*/ */
class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler class GridFieldBulkActionUnLinkHandler extends GridFieldBulkActionHandler
{ {
/** /**
* RequestHandler allowed actions * RequestHandler allowed actions
* @var array * @var array
*/ */
private static $allowed_actions = array('unlink'); private static $allowed_actions = array('unLink');
/** /**
@ -20,7 +20,7 @@ class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler
* @var array * @var array
*/ */
private static $url_handlers = array( private static $url_handlers = array(
'unlink' => 'unlink' 'unLink' => 'unLink'
); );
@ -30,7 +30,7 @@ class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler
* @param SS_HTTPRequest $request * @param SS_HTTPRequest $request
* @return SS_HTTPResponse List of affected records ID * @return SS_HTTPResponse List of affected records ID
*/ */
public function unlink(SS_HTTPRequest $request) public function unLink(SS_HTTPRequest $request)
{ {
$ids = $this->getRecordIDList(); $ids = $this->getRecordIDList();
$this->gridField->list->removeMany($ids); $this->gridField->list->removeMany($ids);

View File

@ -47,7 +47,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
if ( $defaultActions ) if ( $defaultActions )
{ {
$this->config['actions'] = array( $this->config['actions'] = array(
'bulkedit' => array( 'bulkEdit' => array(
'label' => _t('GRIDFIELD_BULK_MANAGER.EDIT_SELECT_LABEL', 'Edit'), 'label' => _t('GRIDFIELD_BULK_MANAGER.EDIT_SELECT_LABEL', 'Edit'),
'handler' => 'GridFieldBulkActionEditHandler', 'handler' => 'GridFieldBulkActionEditHandler',
'config' => array( 'config' => array(
@ -56,9 +56,9 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
'isDestructive' => false 'isDestructive' => false
) )
), ),
'unlink' => array( 'unLink' => array(
'label' => _t('GRIDFIELD_BULK_MANAGER.UNLINK_SELECT_LABEL', 'UnLink'), 'label' => _t('GRIDFIELD_BULK_MANAGER.UNLINK_SELECT_LABEL', 'UnLink'),
'handler' => 'GridFieldBulkActionUnlinkHandler', 'handler' => 'GridFieldBulkActionUnLinkHandler',
'config' => array( 'config' => array(
'isAjax' => true, 'isAjax' => true,
'icon' => 'chain--minus', 'icon' => 'chain--minus',
@ -203,11 +203,9 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
{ {
if ( array_key_exists($name, $this->config['actions']) ) if ( array_key_exists($name, $this->config['actions']) )
{ {
user_error("Bulk action $name already exists.", E_USER_ERROR); user_error("Bulk action '$name' already exists.", E_USER_ERROR);
} }
$name = strtolower($name);
if ( !$label ) if ( !$label )
{ {
$label = ucfirst($name); $label = ucfirst($name);
@ -255,7 +253,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
{ {
if ( !array_key_exists($name, $this->config['actions']) ) if ( !array_key_exists($name, $this->config['actions']) )
{ {
user_error("Bulk action $name doesn't exists.", E_USER_ERROR); user_error("Bulk action '$name' doesn't exists.", E_USER_ERROR);
} }
unset( $this->config['actions'][$name] ); unset( $this->config['actions'][$name] );