mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 09:05:57 +00:00
Implement action callback + cancel behaviour
This commit is contained in:
parent
d141765752
commit
20350d3f35
@ -126,19 +126,24 @@
|
|||||||
},
|
},
|
||||||
onclick: function(e)
|
onclick: function(e)
|
||||||
{
|
{
|
||||||
var $parent = $(this).parents('.bulkManagerOptions'),
|
var $parent = $(this).parents('.bulkManagerOptions'),
|
||||||
$btn = $parent.find('a.doBulkActionButton'),
|
action = $parent.find('select.bulkActionName').val(),
|
||||||
|
ids = $(this).parents('.bulkManagerOptions').find('input.bulkSelectAll:first').getSelectRecordsID()
|
||||||
|
;
|
||||||
|
|
||||||
action = $parent.find('select.bulkActionName').val(),
|
this.doBulkAction(action, ids);
|
||||||
config = $btn.data('config'),
|
},
|
||||||
|
|
||||||
url = this.getActionURL(action, $(this).data('url')),
|
doBulkAction: function(action, ids, callbackFunction, callbackContext)
|
||||||
|
{
|
||||||
|
var $parent = $(this).parents('.bulkManagerOptions'),
|
||||||
|
$btn = $parent.find('a.doBulkActionButton'),
|
||||||
|
|
||||||
ids = $(this).parents('.bulkManagerOptions').find('input.bulkSelectAll:first').getSelectRecordsID(),
|
config = $btn.data('config'),
|
||||||
data = { records: ids }
|
url = this.getActionURL(action, $(this).data('url')),
|
||||||
|
data = { records: ids }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
if ( ids.length <= 0 )
|
if ( ids.length <= 0 )
|
||||||
{
|
{
|
||||||
alert( ss.i18n._t('GridFieldBulkManager.BULKACTION_EMPTY_SELECT') );
|
alert( ss.i18n._t('GridFieldBulkManager.BULKACTION_EMPTY_SELECT') );
|
||||||
@ -163,9 +168,15 @@
|
|||||||
data: data,
|
data: data,
|
||||||
type: "POST",
|
type: "POST",
|
||||||
context: $(this)
|
context: $(this)
|
||||||
}).done(function() {
|
}).done(function(data, textStatus, jqXHR) {
|
||||||
$(this).parents('.ss-gridfield').entwine('.').entwine('ss').reload();
|
|
||||||
$btn.removeClass('loading');
|
$btn.removeClass('loading');
|
||||||
|
if ( callbackFunction && callbackContext )
|
||||||
|
{
|
||||||
|
callbackFunction.call(callbackContext, data);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$(this).parents('.ss-gridfield').entwine('.').entwine('ss').reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -174,12 +185,6 @@
|
|||||||
|
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
doBulkAction: function(action, ids)
|
|
||||||
{
|
|
||||||
console.log(action, ids);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -172,12 +172,12 @@
|
|||||||
onunmatch: function(){},
|
onunmatch: function(){},
|
||||||
onclick: function()
|
onclick: function()
|
||||||
{
|
{
|
||||||
var $bulkUpload = this.parents('.bulkUpload'),
|
var $bulkUpload = this.parents('.bulkUpload'),
|
||||||
$li = $bulkUpload.find('li.ss-uploadfield-item'),
|
$li = $bulkUpload.find('li.ss-uploadfield-item'),
|
||||||
$records = $li.filter('[data-recordid]'),
|
$records = $li.filter('[data-recordid]'),
|
||||||
recordsID,
|
$other = $li.not($records),
|
||||||
$other = $li.not($records),
|
$doBulkActionButton = $bulkUpload.parents('.ss-gridfield-table').find('.doBulkActionButton'),
|
||||||
$doBulkActionButton = $bulkUpload.parents('.ss-gridfield-table').find('.doBulkActionButton')
|
recordsID
|
||||||
;
|
;
|
||||||
|
|
||||||
$other.each(function(index, Element){
|
$other.each(function(index, Element){
|
||||||
@ -191,8 +191,29 @@
|
|||||||
return parseInt( $(this).data('recordid') )
|
return parseInt( $(this).data('recordid') )
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
$doBulkActionButton.doBulkAction('delete', recordsID);
|
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 = data.records
|
||||||
|
;
|
||||||
|
|
||||||
|
this.removeClass('loading');
|
||||||
|
|
||||||
|
$li.each(function(index, Element){
|
||||||
|
var $this = $(this),
|
||||||
|
recordID = parseInt( $this.data('recordid') )
|
||||||
|
;
|
||||||
|
|
||||||
|
if ( ids.indexOf(recordID) !== -1 )
|
||||||
|
{
|
||||||
|
$this.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -234,8 +255,12 @@
|
|||||||
return parseInt( $(this).data('recordid') )
|
return parseInt( $(this).data('recordid') )
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
$doBulkActionButton.doBulkAction('edit', recordsID);
|
$doBulkActionButton.doBulkAction('edit', recordsID, this.editCallback);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
editCallback: function(response)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user