From 912a3c4b9985ddba226ab7f2f88c791b15c66eae Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 25 Apr 2020 21:21:52 +1000 Subject: [PATCH] Update progress bar based on sum of allocated quantities --- InvenTree/build/templates/build/allocate.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index 60637cf66f..7752e318d1 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -33,6 +33,14 @@ InvenTree | Allocate Parts buildTable.inventreeTable({ uniqueId: 'sub_part', url: "{% url 'api-bom-list' %}", + detailViewByClick: true, + detailView: true, + detailFilter: function(index, row) { + return row.allocations != null; + }, + detailFormatter: function(index, row, element) { + return "Hello world"; + }, formatNoMatches: function() { return "{% trans 'No BOM items found' %}"; }, onLoadSuccess: function(tableData) { // Once the BOM data are loaded, request allocation data for the build @@ -114,9 +122,16 @@ InvenTree | Allocate Parts field: 'allocated', title: '{% trans "Allocated" %}', formatter: function(value, row) { - var progress = value || 0; - return makeProgressBar(progress, row.quantity * {{ build.quantity }}); + var allocated = 0; + + if (row.allocations != null) { + row.allocations.forEach(function(allocation) { + allocated += allocation.quantity; + }); + } + + return makeProgressBar(allocated, row.quantity * {{ build.quantity }}); }, sorter: function(valA, valB, rowA, rowB) {