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
|
* Construct a "sub table" showing the required BOM items
|
||||||
*/
|
*/
|
||||||
@ -855,6 +858,9 @@ function loadBuildOutputTable(build_info, options={}) {
|
|||||||
|
|
||||||
element.html(html);
|
element.html(html);
|
||||||
|
|
||||||
|
// Pass through the cached BOM items
|
||||||
|
build_info.bom_items = bom_items;
|
||||||
|
|
||||||
loadBuildOutputAllocationTable(
|
loadBuildOutputAllocationTable(
|
||||||
build_info,
|
build_info,
|
||||||
row,
|
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) {
|
function updateAllocationData(rows) {
|
||||||
// Update stock allocation information for the build outputs
|
// Update stock allocation information for the build outputs
|
||||||
|
|
||||||
console.log("updateAllocationData");
|
|
||||||
|
|
||||||
// Request list of BOM data for this build order
|
// Request list of BOM data for this build order
|
||||||
if (bom_items == null) {
|
if (bom_items == null) {
|
||||||
inventreeGet(
|
inventreeGet(
|
||||||
@ -896,7 +897,9 @@ function loadBuildOutputTable(build_info, options={}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("BOM ITEMS:", bom_items);
|
rows.forEach(function(row) {
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var part_tests = null;
|
var part_tests = null;
|
||||||
@ -904,8 +907,6 @@ function loadBuildOutputTable(build_info, options={}) {
|
|||||||
function updateTestResultData(rows) {
|
function updateTestResultData(rows) {
|
||||||
// Update test result information for the build outputs
|
// Update test result information for the build outputs
|
||||||
|
|
||||||
console.log("updateTestResultData");
|
|
||||||
|
|
||||||
// Request test template data if it has not already been retrieved
|
// Request test template data if it has not already been retrieved
|
||||||
if (part_tests == null) {
|
if (part_tests == null) {
|
||||||
inventreeGet(
|
inventreeGet(
|
||||||
@ -1002,20 +1003,14 @@ function loadBuildOutputTable(build_info, options={}) {
|
|||||||
return '{% trans "No active build outputs found" %}';
|
return '{% trans "No active build outputs found" %}';
|
||||||
},
|
},
|
||||||
onPostBody: function(rows) {
|
onPostBody: function(rows) {
|
||||||
console.log("onPostBody");
|
|
||||||
// Add callbacks for the buttons
|
// Add callbacks for the buttons
|
||||||
setupBuildOutputButtonCallbacks();
|
setupBuildOutputButtonCallbacks();
|
||||||
},
|
},
|
||||||
onLoadSuccess: function(rows) {
|
onLoadSuccess: function(rows) {
|
||||||
|
|
||||||
console.log("onLoadSuccess");
|
|
||||||
|
|
||||||
updateAllocationData(rows);
|
updateAllocationData(rows);
|
||||||
updateTestResultData(rows);
|
updateTestResultData(rows);
|
||||||
},
|
},
|
||||||
onRefresh: function() {
|
|
||||||
console.log("onRefresh");
|
|
||||||
},
|
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
@ -1320,14 +1315,29 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// Load table of BOM items
|
||||||
$(table).inventreeTable({
|
$(table).inventreeTable({
|
||||||
url: '{% url "api-bom-list" %}',
|
data: bom_items,
|
||||||
queryParams: {
|
|
||||||
part: partId,
|
|
||||||
sub_part_detail: true,
|
|
||||||
sub_part_trackable: trackable,
|
|
||||||
},
|
|
||||||
disablePagination: true,
|
disablePagination: true,
|
||||||
formatNoMatches: function() {
|
formatNoMatches: function() {
|
||||||
return '{% trans "No BOM items found" %}';
|
return '{% trans "No BOM items found" %}';
|
||||||
|
Loading…
Reference in New Issue
Block a user