Part BOM list now shows how many of each sub-item are available

- If there are enough to build the available quantity is shown in green
- Otherwise, shown in orange
This commit is contained in:
Oliver Walters 2019-04-12 22:09:50 +10:00
parent 8a3706dd76
commit 2d21bf0626
2 changed files with 21 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class PartBriefSerializer(serializers.ModelSerializer):
'url', 'url',
'name', 'name',
'description', 'description',
'available_stock',
] ]

View File

@ -85,10 +85,29 @@
}, },
{ {
field: 'quantity', field: 'quantity',
title: 'Quantity', title: 'Required',
searchable: false, searchable: false,
sortable: true sortable: true
}, },
{
field: 'sub_part.available_stock',
title: 'Available',
searchable: false,
sortable: true,
formatter: function(value, row, index, field) {
var text = "";
if (row.quantity < row.sub_part.available_stock)
{
text = "<span class='label label-success'>" + value + "</span>";
}
else
{
text = "<span class='label label-warning'>" + value + "</span>";
}
return renderLink(text, row.sub_part.url + "stock/");
}
},
{ {
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
return editButton(row.url + 'edit') + ' ' + deleteButton(row.url + 'delete'); return editButton(row.url + 'edit') + ' ' + deleteButton(row.url + 'delete');