2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 13:35:40 +00:00

Update javascript callbacks

This commit is contained in:
Oliver Walters
2020-10-27 21:47:24 +11:00
parent 06a3899325
commit 54d5d2899e
2 changed files with 42 additions and 30 deletions

View File

@ -53,14 +53,13 @@ function makeBuildOutputActionButtons(output, buildInfo) {
var html = `<div class='btn-group float-right' role='group'>`;
// Add a button to "auto allocate" against the particular build output
html += makeIconButton(
'fa-magic icon-blue', 'button-output-auto', outputId,
'{% trans "Auto-allocate stock items to this output" %}',
{
disabled: true,
}
);
// Add a button to "auto allocate" against the build
if (!output) {
html += makeIconButton(
'fa-magic icon-blue', 'button-output-auto', outputId,
'{% trans "Auto-allocate stock items to this output" %}',
);
}
if (output) {
// Add a button to "complete" the particular build output
@ -75,7 +74,7 @@ function makeBuildOutputActionButtons(output, buildInfo) {
// Add a button to "cancel" the particular build output (unallocate)
html += makeIconButton(
'fa-times-circle icon-red', 'button-output-unallocate', outputId,
'fa-minus-circle icon-red', 'button-output-unallocate', outputId,
'{% trans "Unallocate stock from build output" %}',
);
@ -239,9 +238,18 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
`/api/stock/${value}/`, {},
{
success: function(response) {
// How many items are actually available for the given stock item?
var available = response.quantity - response.allocated;
console.log('available: ' + available);
var field = getFieldByName('#modal-form', 'quantity');
// Allocation quantity initial value
var initial = field.attr('value');
if (available < initial) {
field.val(available);
}
}
}
)