mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cache tracked BOM items for the build order
This commit is contained in:
parent
74a08be5be
commit
e6c95bf6b2
@ -841,6 +841,9 @@ function loadBuildOutputTable(build_info, options={}) {
|
||||
});
|
||||
}
|
||||
|
||||
// List of "tracked bom items" required for this build order
|
||||
var bom_items = null;
|
||||
|
||||
/*
|
||||
* Construct a "sub table" showing the required BOM items
|
||||
*/
|
||||
@ -855,6 +858,9 @@ function loadBuildOutputTable(build_info, options={}) {
|
||||
|
||||
element.html(html);
|
||||
|
||||
// Pass through the cached BOM items
|
||||
build_info.bom_items = bom_items;
|
||||
|
||||
loadBuildOutputAllocationTable(
|
||||
build_info,
|
||||
row,
|
||||
@ -865,14 +871,9 @@ function loadBuildOutputTable(build_info, options={}) {
|
||||
);
|
||||
}
|
||||
|
||||
// List of "tracked bom items" required for this build order
|
||||
var bom_items = null;
|
||||
|
||||
function updateAllocationData(rows) {
|
||||
// Update stock allocation information for the build outputs
|
||||
|
||||
console.log("updateAllocationData");
|
||||
|
||||
// Request list of BOM data for this build order
|
||||
if (bom_items == null) {
|
||||
inventreeGet(
|
||||
@ -896,7 +897,9 @@ function loadBuildOutputTable(build_info, options={}) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("BOM ITEMS:", bom_items);
|
||||
rows.forEach(function(row) {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
var part_tests = null;
|
||||
@ -904,8 +907,6 @@ function loadBuildOutputTable(build_info, options={}) {
|
||||
function updateTestResultData(rows) {
|
||||
// Update test result information for the build outputs
|
||||
|
||||
console.log("updateTestResultData");
|
||||
|
||||
// Request test template data if it has not already been retrieved
|
||||
if (part_tests == null) {
|
||||
inventreeGet(
|
||||
@ -1002,20 +1003,14 @@ function loadBuildOutputTable(build_info, options={}) {
|
||||
return '{% trans "No active build outputs found" %}';
|
||||
},
|
||||
onPostBody: function(rows) {
|
||||
console.log("onPostBody");
|
||||
// Add callbacks for the buttons
|
||||
setupBuildOutputButtonCallbacks();
|
||||
},
|
||||
onLoadSuccess: function(rows) {
|
||||
|
||||
console.log("onLoadSuccess");
|
||||
|
||||
updateAllocationData(rows);
|
||||
updateTestResultData(rows);
|
||||
},
|
||||
onRefresh: function() {
|
||||
console.log("onRefresh");
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
title: '',
|
||||
@ -1320,14 +1315,29 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
});
|
||||
}
|
||||
|
||||
// Load table of BOM items
|
||||
$(table).inventreeTable({
|
||||
url: '{% url "api-bom-list" %}',
|
||||
queryParams: {
|
||||
var bom_items = buildInfo.bom_items || null;
|
||||
|
||||
// If BOM items have not been provided, load via the API
|
||||
if (bom_items == null) {
|
||||
inventreeGet(
|
||||
'{% url "api-bom-list" %}',
|
||||
{
|
||||
part: partId,
|
||||
sub_part_detail: true,
|
||||
sub_part_trackable: trackable,
|
||||
},
|
||||
{
|
||||
async: false,
|
||||
success: function(results) {
|
||||
bom_items = results;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Load table of BOM items
|
||||
$(table).inventreeTable({
|
||||
data: bom_items,
|
||||
disablePagination: true,
|
||||
formatNoMatches: function() {
|
||||
return '{% trans "No BOM items found" %}';
|
||||
|
Loading…
Reference in New Issue
Block a user