separate display for "no stock" and "low stock" in list view

This commit is contained in:
Oliver Walters 2020-03-30 13:31:14 +11:00
parent e8e0ab8416
commit 06f28898a0

View File

@ -184,23 +184,28 @@ function loadPartTable(table, url, options={}) {
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
var html = ""; var html = "";
var link = "stock"; var link = "stock";
if (value) { if (value) {
// There IS stock available for this part
if (row.units) { // Is stock "low" (below the 'minimum_stock' quantity)?
value += ' <i><small>' + row.units + '</small></i>'; if (row.minimum_stock && row.minimum_stock > value) {
value = "<span class='label label-warning'>Low stock : " + row.in_stock + "</span>";
} }
html = value; html = value;
} else if (row.on_order) { } else if (row.on_order) {
// There is no stock available, but stock is on order
value = "<span class='label label-primary'>On Order : " + row.on_order + "</span>"; value = "<span class='label label-primary'>On Order : " + row.on_order + "</span>";
link = "orders"; link = "orders";
} else if (row.building) { } else if (row.building) {
// There is no stock available, but stock is being built
value = "<span class='label label-info'>Building : " + row.building + "</span>"; value = "<span class='label label-info'>Building : " + row.building + "</span>";
link = "builds"; link = "builds";
} else { } else {
value ="<span class='label label-warning'>No Stock</span>"; // There is no stock available
value ="<span class='label label-danger'>No Stock</span>";
} }
return renderLink(value, '/part/' + row.pk + "/" + link + "/"); return renderLink(value, '/part/' + row.pk + "/" + link + "/");