More table rendering fixes

This commit is contained in:
Oliver Walters 2020-04-11 21:23:26 +10:00
parent e69f6c5b9d
commit 57d7d729c1
2 changed files with 39 additions and 6 deletions

View File

@ -158,8 +158,14 @@ function getFilterOptionList(tableKey, filterKey) {
if (settings.type == 'bool') { if (settings.type == 'bool') {
return { return {
'true': '1', '1': {
'false': '0', key: '1',
value: 'true',
},
'0': {
key: '0',
value: 'false',
},
}; };
} else if ('options' in settings) { } else if ('options' in settings) {
return settings.options; return settings.options;

View File

@ -105,6 +105,29 @@ function loadStockTable(table, options) {
stock = +stock.toFixed(5); stock = +stock.toFixed(5);
return stock + " (" + items + " items)"; 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') { } else if (field == 'batch') {
var batches = []; var batches = [];
@ -229,13 +252,17 @@ function loadStockTable(table, options) {
var text = renderLink(val, '/stock/item/' + row.pk + '/'); var text = renderLink(val, '/stock/item/' + row.pk + '/');
if (row.status_text != 'OK') {
text = text + "<span class='badge'>" + row.status_text + "</span>";
}
return text; return text;
} }
}, },
{
field: 'status',
title: 'Status',
sortable: 'true',
formatter: function(value, row, index, field) {
return stockStatusDisplay(value);
},
},
{ {
field: 'batch', field: 'batch',
title: 'Batch', title: 'Batch',