mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-09 07:00:56 +00:00
Adds API mixin for "bulk delete" (#3146)
* Introduces a BulkDelete API mixin class - Allows deletion of multiple items against a single API request * Bump API version * Adds BulkDelete mixin to StockItemTestResult API class * refactor "multi BOM Item delete" to use new approach * Refactor various attachment API endpoints * Refactor multi delete for StockItem * Convert remaining enndpoints over * Fix for API test code
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
/* globals
|
||||
constructForm,
|
||||
imageHoverIcon,
|
||||
inventreeMultiDelete,
|
||||
loadTableFilters,
|
||||
makeIconButton,
|
||||
renderLink,
|
||||
@ -238,9 +237,11 @@ function deleteSupplierParts(parts, options={}) {
|
||||
}
|
||||
|
||||
var rows = '';
|
||||
var ids = [];
|
||||
|
||||
parts.forEach(function(sup_part) {
|
||||
rows += renderPart(sup_part);
|
||||
ids.push(sup_part.pk);
|
||||
});
|
||||
|
||||
var html = `
|
||||
@ -258,21 +259,14 @@ function deleteSupplierParts(parts, options={}) {
|
||||
</table>
|
||||
`;
|
||||
|
||||
constructFormBody({}, {
|
||||
constructForm('{% url "api-supplier-part-list" %}', {
|
||||
method: 'DELETE',
|
||||
title: '{% trans "Delete Supplier Parts" %}',
|
||||
preFormContent: html,
|
||||
onSubmit: function(fields, opts) {
|
||||
|
||||
inventreeMultiDelete(
|
||||
'{% url "api-supplier-part-list" %}',
|
||||
parts,
|
||||
{
|
||||
modal: opts.modal,
|
||||
success: options.success
|
||||
}
|
||||
);
|
||||
}
|
||||
form_data: {
|
||||
items: ids,
|
||||
},
|
||||
onSuccess: options.success,
|
||||
});
|
||||
}
|
||||
|
||||
@ -472,9 +466,11 @@ function deleteManufacturerParts(selections, options={}) {
|
||||
}
|
||||
|
||||
var rows = '';
|
||||
var ids = [];
|
||||
|
||||
selections.forEach(function(man_part) {
|
||||
rows += renderPart(man_part);
|
||||
ids.push(man_part.pk);
|
||||
});
|
||||
|
||||
var html = `
|
||||
@ -491,21 +487,14 @@ function deleteManufacturerParts(selections, options={}) {
|
||||
</table>
|
||||
`;
|
||||
|
||||
constructFormBody({}, {
|
||||
constructForm('{% url "api-manufacturer-part-list" %}', {
|
||||
method: 'DELETE',
|
||||
title: '{% trans "Delete Manufacturer Parts" %}',
|
||||
preFormContent: html,
|
||||
onSubmit: function(fields, opts) {
|
||||
|
||||
inventreeMultiDelete(
|
||||
'{% url "api-manufacturer-part-list" %}',
|
||||
selections,
|
||||
{
|
||||
modal: opts.modal,
|
||||
success: options.success,
|
||||
}
|
||||
);
|
||||
}
|
||||
form_data: {
|
||||
items: ids,
|
||||
},
|
||||
onSuccess: options.success,
|
||||
});
|
||||
}
|
||||
|
||||
@ -525,9 +514,11 @@ function deleteManufacturerPartParameters(selections, options={}) {
|
||||
}
|
||||
|
||||
var rows = '';
|
||||
var ids = [];
|
||||
|
||||
selections.forEach(function(param) {
|
||||
rows += renderParam(param);
|
||||
ids.push(param.pk);
|
||||
});
|
||||
|
||||
var html = `
|
||||
@ -543,20 +534,14 @@ function deleteManufacturerPartParameters(selections, options={}) {
|
||||
</table>
|
||||
`;
|
||||
|
||||
constructFormBody({}, {
|
||||
constructForm('{% url "api-manufacturer-part-parameter-list" %}', {
|
||||
method: 'DELETE',
|
||||
title: '{% trans "Delete Parameters" %}',
|
||||
preFormContent: html,
|
||||
onSubmit: function(fields, opts) {
|
||||
inventreeMultiDelete(
|
||||
'{% url "api-manufacturer-part-parameter-list" %}',
|
||||
selections,
|
||||
{
|
||||
modal: opts.modal,
|
||||
success: options.success,
|
||||
}
|
||||
);
|
||||
}
|
||||
form_data: {
|
||||
items: ids,
|
||||
},
|
||||
onSuccess: options.success,
|
||||
});
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user