mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 03:25:42 +00:00
Fixes multiple issues for "used in" table
This commit is contained in:
@ -872,33 +872,10 @@ function loadUsedInTable(table, part_id, options={}) {
|
||||
|
||||
setupFilterList('usedin', $(table), options.filterTarget || '#filter-list-usedin');
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: options.url || '{% url "api-bom-list" %}',
|
||||
name: options.table_name || 'usedin',
|
||||
sortable: true,
|
||||
search: true,
|
||||
showColumns: true,
|
||||
queryParams: filters,
|
||||
original: params,
|
||||
rootParentId: 'top-level-item',
|
||||
idField: 'pk',
|
||||
uniqueId: 'pk',
|
||||
parentIdField: 'parent',
|
||||
treeShowField: 'part',
|
||||
onLoadSuccess: function(tableData) {
|
||||
// Once the initial data are loaded, check if there are any "inherited" BOM lines
|
||||
for (var ii = 0; ii < tableData.length; ii++) {
|
||||
var row = tableData[ii];
|
||||
function loadVariantData(row) {
|
||||
// Load variants information for inherited BOM rows
|
||||
|
||||
// This is a "top level" item in the table
|
||||
row.parent = 'top-level-item';
|
||||
|
||||
// Ignore this row as it is not "inherited" by variant parts
|
||||
if (!row.inherited) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var variants = inventreeGet(
|
||||
inventreeGet(
|
||||
'{% url "api-part-list" %}',
|
||||
{
|
||||
assembly: true,
|
||||
@ -929,7 +906,35 @@ function loadUsedInTable(table, part_id, options={}) {
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: options.url || '{% url "api-bom-list" %}',
|
||||
name: options.table_name || 'usedin',
|
||||
sortable: true,
|
||||
search: true,
|
||||
showColumns: true,
|
||||
queryParams: filters,
|
||||
original: params,
|
||||
rootParentId: 'top-level-item',
|
||||
idField: 'pk',
|
||||
uniqueId: 'pk',
|
||||
parentIdField: 'parent',
|
||||
treeShowField: 'part',
|
||||
onLoadSuccess: function(tableData) {
|
||||
// Once the initial data are loaded, check if there are any "inherited" BOM lines
|
||||
for (var ii = 0; ii < tableData.length; ii++) {
|
||||
var row = tableData[ii];
|
||||
|
||||
// This is a "top level" item in the table
|
||||
row.parent = 'top-level-item';
|
||||
|
||||
// Ignore this row as it is not "inherited" by variant parts
|
||||
if (!row.inherited) {
|
||||
continue;
|
||||
}
|
||||
|
||||
loadVariantData(row);
|
||||
}
|
||||
},
|
||||
onPostBody: function() {
|
||||
@ -985,7 +990,7 @@ function loadUsedInTable(table, part_id, options={}) {
|
||||
formatter: function(value, row) {
|
||||
var html = value;
|
||||
|
||||
if (row.parent != 'top-level-item') {
|
||||
if (row.parent && row.parent != 'top-level-item') {
|
||||
html += ` <em>({% trans "Inherited from parent BOM" %})</em>`;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user