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