diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html
index b35a0f1b5a..21d01d7501 100644
--- a/InvenTree/part/templates/part/bom.html
+++ b/InvenTree/part/templates/part/bom.html
@@ -50,8 +50,23 @@
+
+
{% endblock %}
+{% block js_load %}
+{{ block.super }}
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
{% block js_ready %}
{{ block.super }}
diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html
index 1c869a8ca4..ca2ab83f36 100644
--- a/InvenTree/templates/base.html
+++ b/InvenTree/templates/base.html
@@ -29,6 +29,7 @@
+
diff --git a/InvenTree/templates/js/bom.html b/InvenTree/templates/js/bom.html
index 518df74d61..1d75124c39 100644
--- a/InvenTree/templates/js/bom.html
+++ b/InvenTree/templates/js/bom.html
@@ -127,11 +127,10 @@ function loadBomTable(table, options) {
*/
}
-
// Part column
cols.push(
{
- field: 'sub_part_detail.full_name',
+ field: 'sub_part',
title: '{% trans "Part" %}',
sortable: true,
formatter: function(value, row, index, field) {
@@ -150,6 +149,7 @@ function loadBomTable(table, options) {
}
);
+
// Part description
cols.push(
{
@@ -236,26 +236,31 @@ function loadBomTable(table, options) {
cols.push({
formatter: function(value, row, index, field) {
- var bValidate = " ";
- var bValid = " ";
+ if (row.part == options.parent_id) {
- var bEdit = " ";
- var bDelt = " ";
-
- var html = "";
-
- html += bEdit;
- html += bDelt;
-
- if (!row.validated) {
- html += bValidate;
+ var bValidate = "
";
+ var bValid = "
";
+
+ var bEdit = "
";
+ var bDelt = "
";
+
+ var html = "
";
+
+ html += bEdit;
+ html += bDelt;
+
+ if (!row.validated) {
+ html += bValidate;
+ } else {
+ html += bValid;
+ }
+
+ html += "
";
+
+ return html;
} else {
- html += bValid;
+ return '';
}
-
- html += "
";
-
- return html;
}
});
}
@@ -274,8 +279,51 @@ function loadBomTable(table, options) {
if (options.sub_part_detail) {
params.sub_part_detail = true;
}
+
+ function requestBomItems() {
+
+ var data = table.bootstrapTable('getData');
+
+ for (var idx = 0; idx < data.length; idx++) {
+ var row = data[idx];
+
+ if (row.sub_part_detail.assembly && !row.requested) {
+
+ row.requested = true;
+
+ // Mark this row as 'requested' so it doesn't get updated again
+ table.bootstrapTable('updateRow', idx, row, true);
+
+ inventreeGet(
+ options.bom_url,
+ {
+ part: row.sub_part,
+ sub_part_detail: true,
+ },
+ {
+ success: function(response) {
+
+ // Add the data to the table
+ table.bootstrapTable('append', response);
+
+ // Request any NEW sub BOMs
+ requestBomItems();
+ },
+ error: function() {
+ console.log('Error requesting BOM for part=' + row.sub_part);
+ }
+ }
+ );
+ }
+ }
+ }
table.bootstrapTable({
+ treeEnable: true,
+ rootParentId: options.parent_id,
+ idField: 'sub_part',
+ parentIdField: 'part',
+ treeShowField: 'sub_part',
sortable: true,
search: true,
rowStyle: function(row, index) {
@@ -291,7 +339,15 @@ function loadBomTable(table, options) {
return params;
},
columns: cols,
- url: options.bom_url
+ url: options.bom_url,
+ onPostBody: function() {
+ table.treegrid({
+ treeColumn: 0,
+ onExpand: function() {
+ }
+ });
+ },
+ onLoadSuccess: requestBomItems,
});
// In editing mode, attached editables to the appropriate table elements