Bom table load fix (#3826)

* Optimize loading of BOM table

- Do not use updateByUniqueId (inefficient!)
- Instead, process and reload the entire table

* Optimize part parameter table

* Revert testing change

* javascript linting
This commit is contained in:
Oliver 2022-10-21 17:05:10 +11:00 committed by GitHub
parent 4ca2aa6cd8
commit 121d68aa87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View File

@ -1308,15 +1308,20 @@ function loadBomTable(table, options={}) {
var data = table.bootstrapTable('getData');
var update_required = false;
for (var idx = 0; idx < data.length; idx++) {
var row = data[idx];
if (!row.parentId) {
row.parentId = parent_id;
table.bootstrapTable('updateByUniqueId', row.pk, row, true);
if (!data[idx].parentId) {
data[idx].parentId = parent_id;
update_required = true;
}
}
// Re-load the table back data
if (update_required) {
table.bootstrapTable('load', data);
}
},
onLoadSuccess: function(data) {

View File

@ -324,7 +324,7 @@ function setupFilterList(tableKey, table, target, options={}) {
// Callback for reloading the table
element.find(`#reload-${tableKey}`).click(function() {
$(table).bootstrapTable('refresh');
reloadTableFilters(table);
});
// Add a callback for downloading table data

View File

@ -1301,15 +1301,17 @@ function loadParametricPartTable(table, options={}) {
for (var idx = 0; idx < data.length; idx++) {
var row = data[idx];
var pk = row.pk;
// Make each parameter accessible, based on the "template" columns
row.parameters.forEach(function(parameter) {
row[`parameter_${parameter.template}`] = parameter.data;
});
$(table).bootstrapTable('updateByUniqueId', pk, row);
data[idx] = row;
}
// Update the table
$(table).bootstrapTable('load', data);
}
});
}