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