From 57d7d729c12daffe4ce6411d330452f0d9b49053 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 11 Apr 2020 21:23:26 +1000 Subject: [PATCH] More table rendering fixes --- .../static/script/inventree/filters.js | 10 ++++-- .../static/script/inventree/stock.js | 35 ++++++++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/filters.js b/InvenTree/InvenTree/static/script/inventree/filters.js index 1c42ddf46b..143b5bc2f7 100644 --- a/InvenTree/InvenTree/static/script/inventree/filters.js +++ b/InvenTree/InvenTree/static/script/inventree/filters.js @@ -158,8 +158,14 @@ function getFilterOptionList(tableKey, filterKey) { if (settings.type == 'bool') { return { - 'true': '1', - 'false': '0', + '1': { + key: '1', + value: 'true', + }, + '0': { + key: '0', + value: 'false', + }, }; } else if ('options' in settings) { return settings.options; diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index 60f2a8262e..d927d0fbe4 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -105,6 +105,29 @@ function loadStockTable(table, options) { stock = +stock.toFixed(5); return stock + " (" + items + " items)"; + } else if (field == 'status') { + var statii = []; + + data.forEach(function(item) { + var status = String(item.status); + + if (!status || status == '') { + status = '-'; + } + + if (!statii.includes(status)) { + statii.push(status); + } + }); + + // Multiple status codes + if (statii.length > 1) { + return "-"; + } else if (statii.length == 1) { + return stockStatusDisplay(statii[0]); + } else { + return "-"; + } } else if (field == 'batch') { var batches = []; @@ -229,13 +252,17 @@ function loadStockTable(table, options) { var text = renderLink(val, '/stock/item/' + row.pk + '/'); - if (row.status_text != 'OK') { - text = text + "" + row.status_text + ""; - } - return text; } }, + { + field: 'status', + title: 'Status', + sortable: 'true', + formatter: function(value, row, index, field) { + return stockStatusDisplay(value); + }, + }, { field: 'batch', title: 'Batch',