mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
Implement editAll + bulkManager requirement check
This commit is contained in:
parent
20350d3f35
commit
699fa6712d
@ -150,11 +150,15 @@
|
||||
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')) )
|
||||
{
|
||||
e.preventDefault();
|
||||
if ( callbackFunction && callbackContext )
|
||||
{
|
||||
callbackFunction.call(callbackContext, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -265,31 +265,36 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
return array();
|
||||
}
|
||||
|
||||
// check BulkManager exists
|
||||
$bulkManager = $gridField->getConfig()->getComponentsByType('GridFieldBulkManager');
|
||||
|
||||
// upload management buttons
|
||||
$finishButton = FormAction::create('Finish', _t('GridFieldBulkTools.FINISH_BTN_LABEL', 'Finish'))
|
||||
->addExtraClass('bulkUploadFinishButton')
|
||||
->setAttribute('data-icon', 'accept')
|
||||
->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'))
|
||||
->addExtraClass('bulkUploadClearErrorButton')
|
||||
->setAttribute('data-icon', 'arrow-circle-double')
|
||||
->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'))
|
||||
->addExtraClass('bulkUploadEditButton')
|
||||
->setAttribute('data-icon', 'pencil')
|
||||
->setAttribute('data-url', $gridField->Link('bulkupload/edit'))
|
||||
->setUseButtonTag(true);
|
||||
}else{
|
||||
->addExtraClass('bulkUploadEditButton')
|
||||
->setAttribute('data-icon', 'pencil')
|
||||
->setAttribute('data-url', $gridField->Link('bulkupload/edit'))
|
||||
->setUseButtonTag(true);
|
||||
}
|
||||
else{
|
||||
$cancelButton = '';
|
||||
$editAllButton = '';
|
||||
}
|
||||
|
||||
|
@ -199,21 +199,26 @@
|
||||
{
|
||||
var $bulkUpload = this.parents('.bulkUpload'),
|
||||
$li = $bulkUpload.find('li.ss-uploadfield-item'),
|
||||
ids = data.records
|
||||
ids
|
||||
;
|
||||
|
||||
if ( data )
|
||||
{
|
||||
ids = data.records;
|
||||
|
||||
$li.each(function(index, Element){
|
||||
var $this = $(this),
|
||||
recordID = parseInt( $this.data('recordid') )
|
||||
;
|
||||
|
||||
if ( ids.indexOf(recordID) !== -1 )
|
||||
{
|
||||
$this.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.removeClass('loading');
|
||||
|
||||
$li.each(function(index, Element){
|
||||
var $this = $(this),
|
||||
recordID = parseInt( $this.data('recordid') )
|
||||
;
|
||||
|
||||
if ( ids.indexOf(recordID) !== -1 )
|
||||
{
|
||||
$this.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -228,10 +233,12 @@
|
||||
$li = $bulkUpload.find('li.ss-uploadfield-item')
|
||||
;
|
||||
|
||||
this.addClass('loading');
|
||||
$li.each(function(index, Element){
|
||||
// skip in progress
|
||||
$(this).remove();
|
||||
});
|
||||
this.removeClass('loading');
|
||||
}
|
||||
});
|
||||
|
||||
@ -251,16 +258,14 @@
|
||||
|
||||
if ( $doBulkActionButton.length > 0 )
|
||||
{
|
||||
this.addClass('loading');
|
||||
|
||||
recordsID = $records.map(function() {
|
||||
return parseInt( $(this).data('recordid') )
|
||||
}).get();
|
||||
|
||||
$doBulkActionButton.doBulkAction('edit', recordsID, this.editCallback);
|
||||
$doBulkActionButton.doBulkAction('bulkedit', recordsID);
|
||||
}
|
||||
},
|
||||
editCallback: function(response)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user