mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
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:
parent
4ca2aa6cd8
commit
121d68aa87
@ -1308,15 +1308,20 @@ function loadBomTable(table, options={}) {
|
|||||||
|
|
||||||
var data = table.bootstrapTable('getData');
|
var data = table.bootstrapTable('getData');
|
||||||
|
|
||||||
|
var update_required = false;
|
||||||
|
|
||||||
for (var idx = 0; idx < data.length; idx++) {
|
for (var idx = 0; idx < data.length; idx++) {
|
||||||
var row = data[idx];
|
|
||||||
|
|
||||||
if (!row.parentId) {
|
if (!data[idx].parentId) {
|
||||||
row.parentId = parent_id;
|
data[idx].parentId = parent_id;
|
||||||
|
update_required = true;
|
||||||
table.bootstrapTable('updateByUniqueId', row.pk, row, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-load the table back data
|
||||||
|
if (update_required) {
|
||||||
|
table.bootstrapTable('load', data);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLoadSuccess: function(data) {
|
onLoadSuccess: function(data) {
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ function setupFilterList(tableKey, table, target, options={}) {
|
|||||||
|
|
||||||
// Callback for reloading the table
|
// Callback for reloading the table
|
||||||
element.find(`#reload-${tableKey}`).click(function() {
|
element.find(`#reload-${tableKey}`).click(function() {
|
||||||
$(table).bootstrapTable('refresh');
|
reloadTableFilters(table);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add a callback for downloading table data
|
// Add a callback for downloading table data
|
||||||
|
@ -1301,15 +1301,17 @@ function loadParametricPartTable(table, options={}) {
|
|||||||
|
|
||||||
for (var idx = 0; idx < data.length; idx++) {
|
for (var idx = 0; idx < data.length; idx++) {
|
||||||
var row = data[idx];
|
var row = data[idx];
|
||||||
var pk = row.pk;
|
|
||||||
|
|
||||||
// Make each parameter accessible, based on the "template" columns
|
// Make each parameter accessible, based on the "template" columns
|
||||||
row.parameters.forEach(function(parameter) {
|
row.parameters.forEach(function(parameter) {
|
||||||
row[`parameter_${parameter.template}`] = parameter.data;
|
row[`parameter_${parameter.template}`] = parameter.data;
|
||||||
});
|
});
|
||||||
|
|
||||||
$(table).bootstrapTable('updateByUniqueId', pk, row);
|
data[idx] = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the table
|
||||||
|
$(table).bootstrapTable('load', data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user