From 81638d06cf06901bf879c5d336ec4449b9e60443 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 Apr 2022 00:51:56 +1000 Subject: [PATCH] Show or hide items based on output BOM --- InvenTree/templates/js/translated/build.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 935206ce2f..705060ce63 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -264,7 +264,7 @@ function makeBuildOutputButtons(output_id, build_info, options={}) { var html = `
`; // Tracked parts? Must be individually allocated - if (build_info.tracked_parts) { + if (options.has_bom_items) { // Add a button to allocate stock against this build output html += makeIconButton( @@ -1085,9 +1085,9 @@ function loadBuildOutputTable(build_info, options={}) { sortable: true, search: false, sidePagination: 'client', - detailView: true, + detailView: bom_items.length > 0, detailFilter: function(index, row) { - return true; + return bom_items.length > 0; }, detailFormatter: function(index, row, element) { constructBuildOutputSubTable(index, row, element); @@ -1159,11 +1159,15 @@ function loadBuildOutputTable(build_info, options={}) { { field: 'allocated', title: '{% trans "Allocated Stock" %}', - visible: true, + visible: bom_items.length > 0, switchable: false, sortable: true, formatter: function(value, row) { + if (bom_items.length == 0) { + return `
{% trans "No tracked BOM items for this build" %}
`; + } + var progressBar = makeProgressBar( countAllocatedLines(row), bom_items.length, @@ -1188,7 +1192,7 @@ function loadBuildOutputTable(build_info, options={}) { switchable: true, formatter: function(value, row) { if (part_tests == null || part_tests.length == 0) { - return `{% trans "No tests found " %}`; + return `{% trans "No required tests for this build" %}`; } var n_passed = countPassedTests(row); @@ -1218,6 +1222,9 @@ function loadBuildOutputTable(build_info, options={}) { return makeBuildOutputButtons( row.pk, build_info, + { + has_bom_items: bom_items.length > 0, + } ); } }