diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index 1d6a99525c..09646cd270 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -11,33 +11,31 @@ InvenTree | Allocate Parts {% include "build/tabs.html" with tab='allocate' %} -
- {% if build.status == BuildStatus.PENDING %} -
- - - -
- {% endif %} -
- - - -

{% trans "Allocated Stock" %}

-
- {% include "build/allocation_card.html" %} -
{% if build.incomplete_outputs %} -

{% trans "Build Ouputs" %}

+

{% trans "Tracked Build Ouputs" %}

{% for item in build.incomplete_outputs %} {% include "build/allocation_card.html" with item=item %} {% endfor %}
+ +
+

{% trans "Untracked Parts" %}

{% endif %} + +
+ {% if build.status == BuildStatus.PENDING %} +
+ + + +
+ {% endif %} +
+ +
+ {% endblock %} {% block js_ready %} @@ -50,7 +48,13 @@ InvenTree | Allocate Parts part: {{ build.part.pk }}, }; - loadBuildOutputAllocationTable(buildInfo, null); + loadBuildOutputAllocationTable( + buildInfo, + null, + { + table: '#build-item-list', + } + ); {% for item in build.incomplete_outputs %} // Get the build output as a javascript object diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index b2b0599ed8..59678ce11c 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -53,14 +53,13 @@ function makeBuildOutputActionButtons(output, buildInfo) { var html = `
`; - // 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); + } } } )