Implement editAll + bulkManager requirement check

This commit is contained in:
colymba 2014-04-06 19:55:25 +03:00 committed by Thierry Francois
parent 20350d3f35
commit 699fa6712d
3 changed files with 45 additions and 31 deletions

View File

@ -150,11 +150,15 @@
return; return;
} }
if ( $btn.hasClass('ss-ui-action-destructive') ) //if ( $btn.hasClass('ss-ui-action-destructive') )
if ( config[action]['isDestructive'] )
{ {
if( !confirm(ss.i18n._t('GridFieldBulkManager.CONFIRM_DESTRUCTIVE_ACTION')) ) if( !confirm(ss.i18n._t('GridFieldBulkManager.CONFIRM_DESTRUCTIVE_ACTION')) )
{ {
e.preventDefault(); if ( callbackFunction && callbackContext )
{
callbackFunction.call(callbackContext, false);
}
return false; return false;
} }
} }

View File

@ -265,31 +265,36 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
return array(); return array();
} }
// check BulkManager exists
$bulkManager = $gridField->getConfig()->getComponentsByType('GridFieldBulkManager');
// upload management buttons // upload management buttons
$finishButton = FormAction::create('Finish', _t('GridFieldBulkTools.FINISH_BTN_LABEL', 'Finish')) $finishButton = FormAction::create('Finish', _t('GridFieldBulkTools.FINISH_BTN_LABEL', 'Finish'))
->addExtraClass('bulkUploadFinishButton') ->addExtraClass('bulkUploadFinishButton')
->setAttribute('data-icon', 'accept') ->setAttribute('data-icon', 'accept')
->setUseButtonTag(true); ->setUseButtonTag(true);
$cancelButton = FormAction::create('Cancel', _t('GridFieldBulkTools.CANCEL_BTN_LABEL', 'Cancel'))
->addExtraClass('bulkUploadCancelButton ss-ui-action-destructive')
->setAttribute('data-icon', 'decline')
->setAttribute('data-url', $gridField->Link('bulkupload/cancel'))
->setUseButtonTag(true);
$clearErrorButton = FormAction::create('ClearError', _t('GridFieldBulkTools.CLEAR_ERROR_BTN_LABEL', 'Clear errors')) $clearErrorButton = FormAction::create('ClearError', _t('GridFieldBulkTools.CLEAR_ERROR_BTN_LABEL', 'Clear errors'))
->addExtraClass('bulkUploadClearErrorButton') ->addExtraClass('bulkUploadClearErrorButton')
->setAttribute('data-icon', 'arrow-circle-double') ->setAttribute('data-icon', 'arrow-circle-double')
->setUseButtonTag(true); ->setUseButtonTag(true);
if ( $gridField->getConfig()->getComponentsByType('GridFieldBulkManager') ) if ( !$bulkManager )
{ {
$cancelButton = FormAction::create('Cancel', _t('GridFieldBulkTools.CANCEL_BTN_LABEL', 'Cancel'))
->addExtraClass('bulkUploadCancelButton ss-ui-action-destructive')
->setAttribute('data-icon', 'decline')
->setAttribute('data-url', $gridField->Link('bulkupload/cancel'))
->setUseButtonTag(true);
$editAllButton = FormAction::create('EditAll', _t('GridFieldBulkTools.EDIT_ALL_BTN_LABEL', 'Edit all')) $editAllButton = FormAction::create('EditAll', _t('GridFieldBulkTools.EDIT_ALL_BTN_LABEL', 'Edit all'))
->addExtraClass('bulkUploadEditButton') ->addExtraClass('bulkUploadEditButton')
->setAttribute('data-icon', 'pencil') ->setAttribute('data-icon', 'pencil')
->setAttribute('data-url', $gridField->Link('bulkupload/edit')) ->setAttribute('data-url', $gridField->Link('bulkupload/edit'))
->setUseButtonTag(true); ->setUseButtonTag(true);
}else{ }
else{
$cancelButton = '';
$editAllButton = ''; $editAllButton = '';
} }

View File

@ -199,10 +199,12 @@
{ {
var $bulkUpload = this.parents('.bulkUpload'), var $bulkUpload = this.parents('.bulkUpload'),
$li = $bulkUpload.find('li.ss-uploadfield-item'), $li = $bulkUpload.find('li.ss-uploadfield-item'),
ids = data.records ids
; ;
this.removeClass('loading'); if ( data )
{
ids = data.records;
$li.each(function(index, Element){ $li.each(function(index, Element){
var $this = $(this), var $this = $(this),
@ -215,6 +217,9 @@
} }
}); });
} }
this.removeClass('loading');
}
}); });
$('.bulkUploadFinishButton').entwine({ $('.bulkUploadFinishButton').entwine({
@ -228,10 +233,12 @@
$li = $bulkUpload.find('li.ss-uploadfield-item') $li = $bulkUpload.find('li.ss-uploadfield-item')
; ;
this.addClass('loading');
$li.each(function(index, Element){ $li.each(function(index, Element){
// skip in progress // skip in progress
$(this).remove(); $(this).remove();
}); });
this.removeClass('loading');
} }
}); });
@ -251,16 +258,14 @@
if ( $doBulkActionButton.length > 0 ) if ( $doBulkActionButton.length > 0 )
{ {
this.addClass('loading');
recordsID = $records.map(function() { recordsID = $records.map(function() {
return parseInt( $(this).data('recordid') ) return parseInt( $(this).data('recordid') )
}).get(); }).get();
$doBulkActionButton.doBulkAction('edit', recordsID, this.editCallback); $doBulkActionButton.doBulkAction('bulkedit', recordsID);
} }
},
editCallback: function(response)
{
} }
}); });