mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Stock installed table fix (#5305)
* Prevent installed items from being hidden * Fix parent / child relationship
This commit is contained in:
parent
6b4717cb28
commit
f70294b247
@ -2375,6 +2375,10 @@ function loadStockTable(table, options) {
|
|||||||
let row = table.bootstrapTable('getRowByUniqueId', stock_item);
|
let row = table.bootstrapTable('getRowByUniqueId', stock_item);
|
||||||
row.installed_items_received = true;
|
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('updateByUniqueId', stock_item, row, true);
|
||||||
table.bootstrapTable('append', response);
|
table.bootstrapTable('append', response);
|
||||||
|
|
||||||
@ -2390,6 +2394,7 @@ function loadStockTable(table, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let parent_id = 'top-level';
|
let parent_id = 'top-level';
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
table.inventreeTable({
|
table.inventreeTable({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -2405,13 +2410,25 @@ function loadStockTable(table, options) {
|
|||||||
showFooter: true,
|
showFooter: true,
|
||||||
columns: columns,
|
columns: columns,
|
||||||
treeEnable: show_installed_items,
|
treeEnable: show_installed_items,
|
||||||
rootParentId: parent_id,
|
rootParentId: show_installed_items ? parent_id : null,
|
||||||
parentIdField: 'belongs_to',
|
parentIdField: show_installed_items ? 'belongs_to_item' : null,
|
||||||
uniqueId: 'pk',
|
uniqueId: 'pk',
|
||||||
idField: 'pk',
|
idField: 'pk',
|
||||||
treeShowField: 'part',
|
treeShowField: show_installed_items ? 'part' : null,
|
||||||
onPostBody: function() {
|
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) {
|
if (show_installed_items) {
|
||||||
table.treegrid({
|
table.treegrid({
|
||||||
treeColumn: 1,
|
treeColumn: 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user