mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Update javascript rendering in build table
This commit is contained in:
parent
ec34d23bfc
commit
aa20d84cc1
@ -1425,19 +1425,36 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
|||||||
title: '{% trans "Available" %}',
|
title: '{% trans "Available" %}',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
var total = row.available_stock + row.available_substitute_stock;
|
|
||||||
|
|
||||||
var text = `${total}`;
|
var url = `/part/${row.sub_part_detail.pk}/?display=part-stock`;
|
||||||
|
|
||||||
if (total <= 0) {
|
// Calculate total "available" (unallocated) quantity
|
||||||
|
var base_stock = row.available_stock;
|
||||||
|
var substitute_stock = row.available_substitute_stock || 0;
|
||||||
|
var variant_stock = row.allow_variants ? (row.available_variant_stock || 0) : 0;
|
||||||
|
|
||||||
|
var available_stock = base_stock + substitute_stock + variant_stock;
|
||||||
|
|
||||||
|
var text = `${available_stock}`;
|
||||||
|
|
||||||
|
if (available_stock <= 0) {
|
||||||
text = `<span class='badge rounded-pill bg-danger'>{% trans "No Stock Available" %}</span>`;
|
text = `<span class='badge rounded-pill bg-danger'>{% trans "No Stock Available" %}</span>`;
|
||||||
} else {
|
} else {
|
||||||
if (row.available_substitute_stock > 0) {
|
var extra = '';
|
||||||
text += `<span title='{% trans "Includes substitute stock" %}' class='fas fa-info-circle float-right icon-blue'></span>`;
|
if ((substitute_stock > 0) && (variant_stock > 0)) {
|
||||||
|
extra = '{% trans "Includes variant and substitute stock" %}';
|
||||||
|
} else if (variant_stock > 0) {
|
||||||
|
extra = '{% trans "Includes variant stock" %}';
|
||||||
|
} else if (substitute_stock > 0) {
|
||||||
|
extra = '{% trans "Includes substitute stock" %}';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extra) {
|
||||||
|
text += `<span title='${extra}' class='fas fa-info-circle float-right icon-blue'></span>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return renderLink(text, url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user