mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixes multiple issues for "used in" table
This commit is contained in:
parent
01da889c46
commit
c367fd7941
@ -872,33 +872,10 @@ function loadUsedInTable(table, part_id, options={}) {
|
|||||||
|
|
||||||
setupFilterList('usedin', $(table), options.filterTarget || '#filter-list-usedin');
|
setupFilterList('usedin', $(table), options.filterTarget || '#filter-list-usedin');
|
||||||
|
|
||||||
$(table).inventreeTable({
|
function loadVariantData(row) {
|
||||||
url: options.url || '{% url "api-bom-list" %}',
|
// Load variants information for inherited BOM rows
|
||||||
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
|
inventreeGet(
|
||||||
row.parent = 'top-level-item';
|
|
||||||
|
|
||||||
// Ignore this row as it is not "inherited" by variant parts
|
|
||||||
if (!row.inherited) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var variants = inventreeGet(
|
|
||||||
'{% url "api-part-list" %}',
|
'{% url "api-part-list" %}',
|
||||||
{
|
{
|
||||||
assembly: true,
|
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() {
|
onPostBody: function() {
|
||||||
@ -985,7 +990,7 @@ function loadUsedInTable(table, part_id, options={}) {
|
|||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
var html = value;
|
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>`;
|
html += ` <em>({% trans "Inherited from parent BOM" %})</em>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user