Build table improvements (#3833)

* Add extra columns to build order table

* Optimize build table update

* Improve loading speed of 'test results' in build output table
This commit is contained in:
Oliver 2022-10-22 18:56:23 +11:00 committed by GitHub
parent 9d39d5b00f
commit c120de90ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1036,9 +1036,12 @@ function loadBuildOutputTable(build_info, options={}) {
// Now that the allocations have been grouped by stock item, // Now that the allocations have been grouped by stock item,
// we can update each row in the table, // we can update each row in the table,
// using the pk value of each row (stock item) // using the pk value of each row (stock item)
var data = [];
rows.forEach(function(row) { rows.forEach(function(row) {
row.allocations = allocations[row.pk] || []; row.allocations = allocations[row.pk] || [];
$(table).bootstrapTable('updateByUniqueId', row.pk, row, true); data.push(row);
var n_completed_lines = 0; var n_completed_lines = 0;
@ -1066,6 +1069,9 @@ function loadBuildOutputTable(build_info, options={}) {
} }
}); });
}); });
// Reload table with updated data
$(table).bootstrapTable('load', data);
} }
} }
); );
@ -1108,6 +1114,7 @@ function loadBuildOutputTable(build_info, options={}) {
{ {
success: function(results) { success: function(results) {
var data = [];
// Iterate through each row and find matching test results // Iterate through each row and find matching test results
rows.forEach(function(row) { rows.forEach(function(row) {
var test_results = {}; var test_results = {};
@ -1124,8 +1131,10 @@ function loadBuildOutputTable(build_info, options={}) {
row.passed_tests = test_results; row.passed_tests = test_results;
$(table).bootstrapTable('updateByUniqueId', row.pk, row, true); data.push(row);
}); });
$(table).bootstrapTable('load', row);
} }
} }
); );
@ -1466,7 +1475,6 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
function redrawAllocationData() { function redrawAllocationData() {
// Force a refresh of each row in the table // Force a refresh of each row in the table
// Note we cannot call 'refresh' because we are passing data from memory // Note we cannot call 'refresh' because we are passing data from memory
// var rows = $(table).bootstrapTable('getData');
// How many rows are fully allocated? // How many rows are fully allocated?
var allocated_rows = 0; var allocated_rows = 0;
@ -1678,7 +1686,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
setupCallbacks(); setupCallbacks();
}, },
sortable: true, sortable: true,
showColumns: false, showColumns: true,
detailView: true, detailView: true,
detailFilter: function(index, row) { detailFilter: function(index, row) {
return allocatedQuantity(row) > 0; return allocatedQuantity(row) > 0;
@ -1809,6 +1817,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
field: 'sub_part_detail.full_name', field: 'sub_part_detail.full_name',
title: '{% trans "Required Part" %}', title: '{% trans "Required Part" %}',
sortable: true, sortable: true,
switchable: false,
formatter: function(value, row) { formatter: function(value, row) {
var url = `/part/${row.sub_part}/`; var url = `/part/${row.sub_part}/`;
var thumb = row.sub_part_detail.thumbnail; var thumb = row.sub_part_detail.thumbnail;
@ -1833,16 +1842,37 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
field: 'reference', field: 'reference',
title: '{% trans "Reference" %}', title: '{% trans "Reference" %}',
sortable: true, sortable: true,
switchable: true,
},
{
field: 'consumable',
title: '{% trans "Consumable" %}',
sortable: true,
switchable: true,
formatter: function(value) {
return yesNoLabel(value);
}
},
{
field: 'optional',
title: '{% trans "Optional" %}',
sortable: true,
switchable: true,
formatter: function(value) {
return yesNoLabel(value);
}
}, },
{ {
field: 'quantity', field: 'quantity',
title: '{% trans "Quantity Per" %}', title: '{% trans "Quantity Per" %}',
sortable: true, sortable: true,
switchable: false,
}, },
{ {
field: 'available_stock', field: 'available_stock',
title: '{% trans "Available" %}', title: '{% trans "Available" %}',
sortable: true, sortable: true,
switchable: true,
formatter: function(value, row) { formatter: function(value, row) {
var url = `/part/${row.sub_part_detail.pk}/?display=part-stock`; var url = `/part/${row.sub_part_detail.pk}/?display=part-stock`;
@ -1906,6 +1936,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
field: 'allocated', field: 'allocated',
title: '{% trans "Allocated" %}', title: '{% trans "Allocated" %}',
sortable: true, sortable: true,
switchable: false,
formatter: function(value, row) { formatter: function(value, row) {
var required = requiredQuantity(row); var required = requiredQuantity(row);
var allocated = row.consumable ? required : allocatedQuantity(row); var allocated = row.consumable ? required : allocatedQuantity(row);
@ -1946,6 +1977,8 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
{ {
field: 'actions', field: 'actions',
title: '{% trans "Actions" %}', title: '{% trans "Actions" %}',
switchable: false,
sortable: false,
formatter: function(value, row) { formatter: function(value, row) {
if (row.consumable) { if (row.consumable) {