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;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 )
|
||||||
{
|
{
|
||||||
$editAllButton = FormAction::create('EditAll', _t('GridFieldBulkTools.EDIT_ALL_BTN_LABEL', 'Edit all'))
|
$cancelButton = FormAction::create('Cancel', _t('GridFieldBulkTools.CANCEL_BTN_LABEL', 'Cancel'))
|
||||||
->addExtraClass('bulkUploadEditButton')
|
->addExtraClass('bulkUploadCancelButton ss-ui-action-destructive')
|
||||||
->setAttribute('data-icon', 'pencil')
|
->setAttribute('data-icon', 'decline')
|
||||||
->setAttribute('data-url', $gridField->Link('bulkupload/edit'))
|
->setAttribute('data-url', $gridField->Link('bulkupload/cancel'))
|
||||||
->setUseButtonTag(true);
|
->setUseButtonTag(true);
|
||||||
}else{
|
|
||||||
|
$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{
|
||||||
|
$cancelButton = '';
|
||||||
$editAllButton = '';
|
$editAllButton = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,21 +199,26 @@
|
|||||||
{
|
{
|
||||||
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
|
||||||
;
|
;
|
||||||
|
|
||||||
|
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');
|
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')
|
$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)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user