Merge pull request #478 from SchrodingersGat/show-batch

Display batch information in stock table
This commit is contained in:
Oliver 2019-09-07 10:44:15 +10:00 committed by GitHub
commit e9ba51da52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,6 +82,32 @@ function loadStockTable(table, options) {
});
return stock;
} else if (field == 'batch') {
var batches = [];
data.forEach(function(item) {
var batch = item.batch;
if (!batch || batch == '') {
batch = '-';
}
if (!batches.includes(batch)) {
batches.push(batch);
}
});
if (batches.length > 1) {
return "" + batches.length + " batches";
} else if (batches.length == 1) {
if (batches[0]) {
return batches[0];
} else {
return '-';
}
} else {
return '-';
}
} else if (field == 'location__path') {
/* Determine how many locations */
var locations = [];
@ -165,6 +191,11 @@ function loadStockTable(table, options) {
return text;
}
},
{
field: 'batch',
title: 'Batch',
sortable: true,
},
{
field: 'location__path',
title: 'Location',