From 4cd41bd0a3f3b474ab1402114a5d0754ca79c740 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 9 Mar 2022 15:23:23 +1100 Subject: [PATCH] Display "loading" until allocations loaded --- InvenTree/InvenTree/version.py | 1 + InvenTree/build/api.py | 1 + InvenTree/templates/js/translated/build.js | 24 +++++++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index e040b8fcc3..19373e930c 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -19,6 +19,7 @@ Increment this API version number whenever there is a significant change to the v30 -> 2022-03-09 - Adds "exclude_location" field to BuildAutoAllocation API endpoint + - Allows BuildItem API endpoint to be filtered by BomItem relation v29 -> 2022-03-08 - Adds "scheduling" endpoint for predicted stock scheduling information diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py index 114268fa2b..33f3f4ab36 100644 --- a/InvenTree/build/api.py +++ b/InvenTree/build/api.py @@ -461,6 +461,7 @@ class BuildItemList(generics.ListCreateAPIView): filter_fields = [ 'build', 'stock_item', + 'bom_item', 'install_into', ] diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 86796520c2..629c61b856 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -1219,6 +1219,18 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { $(table).bootstrapTable('updateByUniqueId', key, tableRow, true); } + // Update any rows which we did not receive allocation information for + var td = $(table).bootstrapTable('getData'); + + td.forEach(function(tableRow) { + if (tableRow.allocations == null) { + + tableRow.allocations = []; + + $(table).bootstrapTable('updateByUniqueId', tableRow.pk, tableRow, true); + } + }); + // Update the progress bar for this build output var build_progress = $(`#output-progress-${outputId}`); @@ -1419,15 +1431,17 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { formatter: function(value, row) { var allocated = 0; - if (row.allocations) { + if (row.allocations != null) { row.allocations.forEach(function(item) { allocated += item.quantity; }); + + var required = requiredQuantity(row); + + return makeProgressBar(allocated, required); + } else { + return `{% trans "Loading" %}`; } - - var required = requiredQuantity(row); - - return makeProgressBar(allocated, required); }, sorter: function(valA, valB, rowA, rowB) { // Custom sorting function for progress bars