diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 2c0b56c518..c91dc1ccc0 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -1060,6 +1060,21 @@ function loadBuildOutputTable(build_info, options={}) { return n; } + // Return the number of 'fully allocated' lines for a given row + function countAllocatedLines(row) { + var n_completed_lines = 0; + + bom_items.forEach(function(bom_row) { + var required_quantity = bom_row.quantity * row.quantity; + + if (sumAllocationsForBomRow(bom_row, row.allocations || []) >= required_quantity) { + n_completed_lines += 1; + } + }); + + return n_completed_lines; + } + $(table).inventreeTable({ url: '{% url "api-stock-list" %}', queryParams: filters, @@ -1146,28 +1161,12 @@ function loadBuildOutputTable(build_info, options={}) { title: '{% trans "Allocated Stock" %}', visible: true, switchable: false, + sortable: true, formatter: function(value, row) { - // Display a progress bar which shows how many BOM lines have been fully allocated - var n_bom_lines = 1; - var n_completed_lines = 0; - - // Work out how many lines have been allocated for this build output - if (bom_items && row.allocations) { - n_bom_lines = bom_items.length; - - bom_items.forEach(function(bom_row) { - var required_quantity = row.quantity * bom_row.quantity; - - if (sumAllocationsForBomRow(bom_row, row.allocations) >= required_quantity) { - n_completed_lines += 1; - } - }) - } - var progressBar = makeProgressBar( - n_completed_lines, - n_bom_lines, + countAllocatedLines(row), + bom_items.length, { max_width: '150px', } @@ -1176,8 +1175,10 @@ function loadBuildOutputTable(build_info, options={}) { return `