Display "loading" until allocations loaded

This commit is contained in:
Oliver 2022-03-09 15:23:23 +11:00
parent 4191a043b2
commit 4cd41bd0a3
3 changed files with 21 additions and 5 deletions

View File

@ -19,6 +19,7 @@ Increment this API version number whenever there is a significant change to the
v30 -> 2022-03-09 v30 -> 2022-03-09
- Adds "exclude_location" field to BuildAutoAllocation API endpoint - Adds "exclude_location" field to BuildAutoAllocation API endpoint
- Allows BuildItem API endpoint to be filtered by BomItem relation
v29 -> 2022-03-08 v29 -> 2022-03-08
- Adds "scheduling" endpoint for predicted stock scheduling information - Adds "scheduling" endpoint for predicted stock scheduling information

View File

@ -461,6 +461,7 @@ class BuildItemList(generics.ListCreateAPIView):
filter_fields = [ filter_fields = [
'build', 'build',
'stock_item', 'stock_item',
'bom_item',
'install_into', 'install_into',
] ]

View File

@ -1219,6 +1219,18 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
$(table).bootstrapTable('updateByUniqueId', key, tableRow, true); $(table).bootstrapTable('updateByUniqueId', key, tableRow, true);
} }
// Update any rows which we did not receive allocation information for
var td = $(table).bootstrapTable('getData');
td.forEach(function(tableRow) {
if (tableRow.allocations == null) {
tableRow.allocations = [];
$(table).bootstrapTable('updateByUniqueId', tableRow.pk, tableRow, true);
}
});
// Update the progress bar for this build output // Update the progress bar for this build output
var build_progress = $(`#output-progress-${outputId}`); var build_progress = $(`#output-progress-${outputId}`);
@ -1419,15 +1431,17 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
formatter: function(value, row) { formatter: function(value, row) {
var allocated = 0; var allocated = 0;
if (row.allocations) { if (row.allocations != null) {
row.allocations.forEach(function(item) { row.allocations.forEach(function(item) {
allocated += item.quantity; allocated += item.quantity;
}); });
}
var required = requiredQuantity(row); var required = requiredQuantity(row);
return makeProgressBar(allocated, required); return makeProgressBar(allocated, required);
} else {
return `<em>{% trans "Loading" %}</em>`;
}
}, },
sorter: function(valA, valB, rowA, rowB) { sorter: function(valA, valB, rowA, rowB) {
// Custom sorting function for progress bars // Custom sorting function for progress bars