From c63a09330fdf1e935cf2491ae9d8cef5f5fa9340 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 24 Oct 2020 22:05:19 +1100 Subject: [PATCH] Hide some buttons if row is fully allocated already --- InvenTree/templates/js/build.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index e4c911634f..637b5d7e1f 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -504,15 +504,17 @@ function loadBuildOutputAllocationTable(buildId, partId, output, options={}) { // Generate action buttons for this build output var html = `
`; - if (row.sub_part_detail.assembly) { - html += makeIconButton('fa-tools icon-blue', 'button-build', row.sub_part, '{% trans "Build stock" %}'); - } + if (sumAllocations(row) < requiredQuantity(row)) { + if (row.sub_part_detail.assembly) { + html += makeIconButton('fa-tools icon-blue', 'button-build', row.sub_part, '{% trans "Build stock" %}'); + } - if (row.sub_part_detail.purchaseable) { - html += makeIconButton('fa-shopping-cart icon-blue', 'button-buy', row.sub_part, '{% trans "Order stock" %}', {disabled: true}); - } + if (row.sub_part_detail.purchaseable) { + html += makeIconButton('fa-shopping-cart icon-blue', 'button-buy', row.sub_part, '{% trans "Order stock" %}', {disabled: true}); + } - html += makeIconButton('fa-sign-in-alt icon-green', 'button-add', row.sub_part, '{% trans "Allocate stock" %}'); + html += makeIconButton('fa-sign-in-alt icon-green', 'button-add', row.sub_part, '{% trans "Allocate stock" %}'); + } html += makeIconButton('fa-times-circle icon-red', 'button-unallocate', row.sub_part, '{% trans "Unallocate stock" %}');