Stock installed table fix (#5305)

* Prevent installed items from being hidden

* Fix parent / child relationship
This commit is contained in:
Oliver 2023-07-21 23:53:58 +10:00 committed by GitHub
parent 6b4717cb28
commit f70294b247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2375,6 +2375,10 @@ function loadStockTable(table, options) {
let row = table.bootstrapTable('getRowByUniqueId', stock_item);
row.installed_items_received = true;
for (let ii = 0; ii < response.length; ii++) {
response[ii].belongs_to_item = stock_item;
}
table.bootstrapTable('updateByUniqueId', stock_item, row, true);
table.bootstrapTable('append', response);
@ -2390,6 +2394,7 @@ function loadStockTable(table, options) {
}
let parent_id = 'top-level';
let loaded = false;
table.inventreeTable({
method: 'get',
@ -2405,13 +2410,25 @@ function loadStockTable(table, options) {
showFooter: true,
columns: columns,
treeEnable: show_installed_items,
rootParentId: parent_id,
parentIdField: 'belongs_to',
rootParentId: show_installed_items ? parent_id : null,
parentIdField: show_installed_items ? 'belongs_to_item' : null,
uniqueId: 'pk',
idField: 'pk',
treeShowField: 'part',
onPostBody: function() {
treeShowField: show_installed_items ? 'part' : null,
onLoadSuccess: function(data) {
let records = data.results || data;
// Set the 'parent' ID for each root item
if (!loaded && show_installed_items) {
for (let i = 0; i < records.length; i++) {
records[i].belongs_to_item = parent_id;
}
loaded = true;
$(table).bootstrapTable('load', records);
}
},
onPostBody: function() {
if (show_installed_items) {
table.treegrid({
treeColumn: 1,