Handle delete differently

This commit is contained in:
Oliver 2021-07-12 20:06:53 +10:00
parent 2bebf2d41a
commit 74e5b2cd3f

View File

@ -223,6 +223,32 @@ function adjustStock(items, options={}) {
modal: modal,
onSubmit: function(fields, opts) {
// "Delete" action gets handled differently
if (options.action == 'delete') {
var requests = [];
items.forEach(function(item) {
requests.push(
inventreeDelete(
`/api/stock/${item.pk}/`,
)
)
});
// Wait for *all* the requests to complete
$.when.apply($, requests).then(function() {
// Destroy the modal window
$(modal).modal('hide');
if (options.onSuccess) {
options.onSuccess();
}
});
return;
}
// Data to transmit
var data = {
items: [],