From df9a33935def45d7a21406209e60713363a3d75f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 28 Apr 2022 23:26:08 +1000 Subject: [PATCH] Row button fixes --- InvenTree/templates/js/translated/build.js | 53 +++++++++++----------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 7705bfaa16..3376cb21a0 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -838,6 +838,23 @@ function loadBuildOutputTable(build_info, options={}) { // List of "tracked bom items" required for this build order var bom_items = null; + // Request list of BOM data for this build order + inventreeGet( + '{% url "api-bom-list" %}', + { + part: build_info.part, + sub_part_detail: true, + sub_part_trackable: true, + }, + { + async: false, + success: function(response) { + // Save the BOM items + bom_items = response; + } + } + ); + /* * Construct a "sub table" showing the required BOM items */ @@ -868,29 +885,6 @@ function loadBuildOutputTable(build_info, options={}) { function updateAllocationData(rows) { // Update stock allocation information for the build outputs - // Request list of BOM data for this build order - if (bom_items == null) { - inventreeGet( - '{% url "api-bom-list" %}', - { - part: build_info.part, - sub_part_detail: true, - sub_part_trackable: true, - }, - { - success: function(response) { - // Save the BOM items - bom_items = response; - - // Callback to this function again - updateAllocationData(rows); - } - } - ); - - return; - } - // Request updated stock allocation data for this build order inventreeGet( '{% url "api-build-item-list" %}', @@ -1098,6 +1092,13 @@ function loadBuildOutputTable(build_info, options={}) { visible: true, switchable: false, formatter: function(value, row) { + // Display a progress bar which shows how many rows have been allocated + var n_bom_lines = 0; + + if (bom_items) { + n_bom_lines = bom_items.length; + } + return `lines: ${n_bom_lines}`; return `
`; }, sorter: function(value_a, value_b, row_a, row_b) { @@ -1548,7 +1549,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { quantity: {}, }, title: '{% trans "Edit Allocation" %}', - onSuccess: reloadTable, + onSuccess: reloadAllocationData, }); }); @@ -1558,7 +1559,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { constructForm(`/api/build/item/${pk}/`, { method: 'DELETE', title: '{% trans "Remove Allocation" %}', - onSuccess: reloadTable, + onSuccess: reloadAllocationData, }); }); }, @@ -1718,7 +1719,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { 'fa-minus-circle icon-red', 'button-unallocate', row.sub_part, '{% trans "Unallocate stock" %}', { - disabled: row.allocations == null + disabled: sumAllocations(row) == 0, } );