From 7ac52d4d9f39c782af6c3c6ae521b4551a7b0046 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 28 May 2019 19:12:10 +1000 Subject: [PATCH] Optionally select which column gets grouped - Allow grouping by numerical values --- InvenTree/part/templates/part/stock.html | 1 + .../static/script/bootstrap/bootstrap-table-group-by.js | 4 ++-- InvenTree/static/script/inventree/stock.js | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index e9c22bf1d9..04d1b0278a 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -46,6 +46,7 @@ location_detail: true, part_detail: true, }, + groupByField: 'location', buttons: [ '#stock-options', ], diff --git a/InvenTree/static/script/bootstrap/bootstrap-table-group-by.js b/InvenTree/static/script/bootstrap/bootstrap-table-group-by.js index d31dbec22a..fd65e6b560 100644 --- a/InvenTree/static/script/bootstrap/bootstrap-table-group-by.js +++ b/InvenTree/static/script/bootstrap/bootstrap-table-group-by.js @@ -72,9 +72,9 @@ if (this.options.groupBy && this.options.groupByField !== '') { - if (1 || (this.options.sortName != this.options.groupByField)) { + if (this.options.sortName != this.options.groupByField) { this.data.sort(function (a, b) { - return a[that.options.groupByField].localeCompare(b[that.options.groupByField]); + return a[that.options.groupByField] == b[that.options.groupByField]; }); } diff --git a/InvenTree/static/script/inventree/stock.js b/InvenTree/static/script/inventree/stock.js index f6632b2ec3..810d1a0327 100644 --- a/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/static/script/inventree/stock.js @@ -385,8 +385,7 @@ function loadStockTable(table, options) { pageSize: 25, rememberOrder: true, groupBy: true, - groupByField: 'part_name', - groupByFields: ['part_name', 'test'], + groupByField: options.groupByField || 'part', groupByFormatter: function(field, id, data) { if (field == 'Part') { @@ -404,7 +403,7 @@ function loadStockTable(table, options) { stock += item.quantity; }); - return stock + ' (' + data.length + ' items)'; + return stock; } else if (field == 'Location') { /* Determine how many locations */ var locations = [];