mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Refactor multi-bom deletion
This commit is contained in:
parent
44f5e0907e
commit
12c2ea3b37
@ -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 %}";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user