2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Refactor CancelBuild form

This commit is contained in:
Oliver Walters
2022-05-04 16:30:46 +10:00
parent 768e23c7b8
commit bd3d6f47a1
11 changed files with 153 additions and 68 deletions

View File

@ -21,6 +21,7 @@
/* exported
allocateStockToBuild,
autoAllocateStockToBuild,
cancelBuildOrder,
completeBuildOrder,
createBuildOutput,
editBuildOrder,
@ -123,6 +124,49 @@ function newBuildOrder(options={}) {
}
/* Construct a form to cancel a build order */
function cancelBuildOrder(build_id, options={}) {
constructForm(
`/api/build/${build_id}/cancel/`,
{
method: 'POST',
title: '{% trans "Cancel Build Order" %}',
confirm: true,
fields: {
remove_allocated_stock: {},
remove_incomplete_outputs: {},
},
preFormContent: function(opts) {
var html = `
<div class='alert alert-block alert-info'>
{% trans "Are you sure you wish to cancel this build?" %}
</div>`;
if (opts.context.has_allocated_stock) {
html += `
<div class='alert alert-block alert-warning'>
{% trans "Stock items have been allocated to this build order" %}
</div>`;
}
if (opts.context.incomplete_outputs) {
html += `
<div class='alert alert-block alert-warning'>
{% trans "There are incomplete outputs remaining for this build order" %}
</div>`;
}
return html;
},
onSuccess: function(response) {
handleFormSuccess(response, options);
}
}
);
}
/* Construct a form to "complete" (finish) a build order */
function completeBuildOrder(build_id, options={}) {