mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
API remove cancel and edit upload buttons
API remove cancel and edit btns
This commit is contained in:
parent
efb89e5b64
commit
aa9bf472c6
@ -78,8 +78,6 @@
|
||||
refresh: function(total, done, error)
|
||||
{
|
||||
var $info = this.find('.colymba-bulkupload-info'),
|
||||
$editBtn = this.find('.bulkUploadEditButton'),
|
||||
$cancelBtn = this.find('.bulkUploadCancelButton'),
|
||||
$finishBtn = this.find('.bulkUploadFinishButton'),
|
||||
$clearErrorBtn = this.find('.bulkUploadClearErrorButton')
|
||||
;
|
||||
@ -95,8 +93,6 @@
|
||||
error
|
||||
));
|
||||
|
||||
$cancelBtn.removeClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'false').removeAttr('disabled');
|
||||
|
||||
//if there are still uploads going
|
||||
if ( (done + error) < total )
|
||||
{
|
||||
@ -111,15 +107,6 @@
|
||||
$finishBtn.removeClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'false').removeAttr('disabled');
|
||||
}
|
||||
|
||||
//if all done and OK, enable edit
|
||||
if ( total === done )
|
||||
{
|
||||
$editBtn.removeClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'false').removeAttr('disabled');
|
||||
}
|
||||
else{
|
||||
$editBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true');
|
||||
}
|
||||
|
||||
//toggle clear error button
|
||||
if ( error > 0 )
|
||||
{
|
||||
@ -132,8 +119,6 @@
|
||||
else{
|
||||
//if not uploading, reset + hide
|
||||
this.css({display: 'none'}).removeClass('loading');
|
||||
$editBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true');
|
||||
$cancelBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true');
|
||||
$finishBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true');
|
||||
$clearErrorBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true');
|
||||
}
|
||||
@ -162,70 +147,6 @@
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Cancel all uploads
|
||||
* Clear the ones with warnings/error and delete dataObjects from the successful ones
|
||||
*/
|
||||
$('.bulkUploadCancelButton:not(.ui-state-disabled)').entwine({
|
||||
onmatch: function(){
|
||||
this.removeClass('action');
|
||||
},
|
||||
onunmatch: function(){},
|
||||
onclick: function()
|
||||
{
|
||||
var $bulkUpload = this.parents('.bulkUpload'),
|
||||
$li = $bulkUpload.find('li.ss-uploadfield-item'),
|
||||
$records = $li.filter('[data-recordid]'),
|
||||
$other = $li.not($records),
|
||||
$doBulkActionButton = $bulkUpload.parents('.ss-gridfield-table').find('.doBulkActionButton'),
|
||||
recordsID
|
||||
;
|
||||
|
||||
$other.each(function(index, Element){
|
||||
// skip in progress
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
if ( $doBulkActionButton.length > 0 )
|
||||
{
|
||||
recordsID = $records.map(function() {
|
||||
return parseInt( $(this).data('recordid') )
|
||||
}).get();
|
||||
|
||||
this.addClass('loading');
|
||||
$doBulkActionButton.doBulkAction('delete', recordsID, this.cancelCallback, this);
|
||||
}
|
||||
},
|
||||
cancelCallback: function(data)
|
||||
{
|
||||
var $bulkUpload = this.parents('.bulkUpload'),
|
||||
$li = $bulkUpload.find('li.ss-uploadfield-item'),
|
||||
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).parents('.ss-gridfield').entwine('.').entwine('ss').reload();
|
||||
}
|
||||
|
||||
this.removeClass('loading');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Clear all the warning/error/finished uploads
|
||||
*/
|
||||
@ -252,33 +173,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('.bulkUploadEditButton:not(.ui-state-disabled)').entwine({
|
||||
onmatch: function(){
|
||||
this.removeClass('action');
|
||||
},
|
||||
onunmatch: function(){},
|
||||
onclick: function()
|
||||
{
|
||||
var $bulkUpload = this.parents('.bulkUpload'),
|
||||
$li = $bulkUpload.find('li.ss-uploadfield-item'),
|
||||
$records = $li.filter('[data-recordid]'),
|
||||
recordsID,
|
||||
$doBulkActionButton = $bulkUpload.parents('.ss-gridfield-table').find('.doBulkActionButton')
|
||||
;
|
||||
|
||||
if ( $doBulkActionButton.length > 0 )
|
||||
{
|
||||
this.addClass('loading');
|
||||
|
||||
recordsID = $records.map(function() {
|
||||
return parseInt( $(this).data('recordid') )
|
||||
}).get();
|
||||
|
||||
$doBulkActionButton.doBulkAction('bulkedit', recordsID);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}); // colymba namespace
|
||||
|
||||
}); // ss namespace
|
||||
|
@ -370,9 +370,6 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
||||
return array();
|
||||
}
|
||||
|
||||
// check BulkManager exists
|
||||
$bulkManager = $gridField->getConfig()->getComponentsByType('Colymba\\BulkManager\\BulkManager');
|
||||
|
||||
// upload management buttons
|
||||
$finishButton = FormAction::create('Finish', _t('GRIDFIELD_BULK_UPLOAD.FINISH_BTN_LABEL', 'Finish'))
|
||||
->addExtraClass('bulkUploadFinishButton')
|
||||
@ -384,37 +381,12 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
||||
->setAttribute('data-icon', 'arrow-circle-double')
|
||||
->setUseButtonTag(true);
|
||||
|
||||
if (count($bulkManager)) {
|
||||
$cancelButton = FormAction::create('Cancel', _t('GRIDFIELD_BULK_UPLOAD.CANCEL_BTN_LABEL', 'Cancel'))
|
||||
->addExtraClass('bulkUploadCancelButton ss-ui-action-destructive')
|
||||
->setAttribute('data-icon', 'decline')
|
||||
->setAttribute('data-url', $gridField->Link('bulkupload/cancel'))
|
||||
->setUseButtonTag(true);
|
||||
|
||||
$bulkManager_config = $bulkManager->first()->getConfig();
|
||||
$bulkManager_actions = $bulkManager_config['actions'];
|
||||
if (array_key_exists('bulkedit', $bulkManager_actions)) {
|
||||
$editAllButton = FormAction::create('EditAll', _t('GRIDFIELD_BULK_UPLOAD.EDIT_ALL_BTN_LABEL', 'Edit all'))
|
||||
->addExtraClass('bulkUploadEditButton')
|
||||
->setAttribute('data-icon', 'pencil')
|
||||
->setAttribute('data-url', $gridField->Link('bulkupload/edit'))
|
||||
->setUseButtonTag(true);
|
||||
} else {
|
||||
$editAllButton = '';
|
||||
}
|
||||
} else {
|
||||
$cancelButton = '';
|
||||
$editAllButton = '';
|
||||
}
|
||||
|
||||
// get uploadField + inject extra buttons
|
||||
// get uploadField
|
||||
$uploadField = $this->bulkUploadField($gridField);
|
||||
$uploadField->FinishButton = $finishButton;
|
||||
$uploadField->CancelButton = $cancelButton;
|
||||
$uploadField->EditAllButton = $editAllButton;
|
||||
$uploadField->ClearErrorButton = $clearErrorButton;
|
||||
|
||||
$data = ArrayData::create(array(
|
||||
'Finish' => $finishButton,
|
||||
'ClearErrors' => $clearErrorButton,
|
||||
'Colspan' => (count($gridField->getColumns())),
|
||||
'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
|
||||
));
|
||||
|
@ -1,5 +1,7 @@
|
||||
<tr class="bulkUploader">
|
||||
<th class="" colspan="$Colspan">
|
||||
$UploadField
|
||||
$Finish
|
||||
$ClearErrors
|
||||
</th>
|
||||
</tr>
|
Loading…
Reference in New Issue
Block a user