From b192deb46593f5d8d531fe0943c9479e6b5a48de Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 30 Apr 2019 14:54:42 +1000 Subject: [PATCH] Calculate total allocation data per-row --- InvenTree/static/script/inventree/build.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/InvenTree/static/script/inventree/build.js b/InvenTree/static/script/inventree/build.js index 7e31fdae81..4a9ceae443 100644 --- a/InvenTree/static/script/inventree/build.js +++ b/InvenTree/static/script/inventree/build.js @@ -103,4 +103,15 @@ function fillAllocationTable(table, parent_row, options) { ], url: "/api/build/item?build=" + options.build + "&part=" + parent_row.sub_part, }); + + table.on('load-success.bs.table', function(data) { + var allocated = 0; + + var allocationData = table.bootstrapTable('getData'); + + // Calculate total allocation + for (var i = 0; i < allocationData.length; i++) { + allocated += allocationData[i].quantity; + } + }); } \ No newline at end of file