2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

Merge pull request #1361 from SchrodingersGat/multi-bom-delete

Refactor multi-bom deletion
This commit is contained in:
Oliver 2021-02-26 11:15:51 +11:00 committed by GitHub
commit 414a981858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,34 +111,25 @@
{ {
accept: function() { accept: function() {
// Delete each row one at a time! // Keep track of each DELETE request
function deleteRow(idx) { var requests = [];
if (idx >= rows.length) { rows.forEach(function(row) {
// All selected rows deleted - reload the table requests.push(
$("#bom-table").bootstrapTable('refresh'); inventreeDelete(
} `/api/bom/${row.pk}/`,
)
);
});
var row = rows[idx]; // Wait for *all* the requests to complete
$.when.apply($, requests).then(function() {
var url = `/api/bom/${row.pk}/`; $('#bom-table').bootstrapTable('refresh');
});
inventreeDelete(
url,
{
complete: function(xhr, status) {
deleteRow(idx + 1);
}
}
)
}
// Start the deletion!
deleteRow(0);
} }
} }
); );
}); });
$('#bom-upload').click(function() { $('#bom-upload').click(function() {
location.href = "{% url 'upload-bom' part.id %}"; location.href = "{% url 'upload-bom' part.id %}";