From 5b402b6bc0cff818e824f3b7d34d0f62ca6f24ff Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 17 Feb 2021 22:18:32 +1100 Subject: [PATCH] BOM table formatting - Display link to external BOM - Prevent item from being edited to selected --- InvenTree/templates/js/bom.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/js/bom.js b/InvenTree/templates/js/bom.js index bbaca2c04b..8ab1b03227 100644 --- a/InvenTree/templates/js/bom.js +++ b/InvenTree/templates/js/bom.js @@ -137,6 +137,16 @@ function loadBomTable(table, options) { checkbox: true, visible: true, switchable: false, + formatter: function(value, row, index, field) { + // Disable checkbox if the row is defined for a *different* part! + if (row.part != options.parent_id) { + return { + disabled: true, + }; + } else { + return value; + } + } }); } @@ -264,6 +274,20 @@ function loadBomTable(table, options) { field: 'inherited', title: '{% trans "Inherited" %}', searchable: false, + formatter: function(value, row, index, field) { + // This BOM item *is* inheritable, but is defined for this BOM + if (!row.inherited) { + return "-"; + } else if (row.part == options.parent_id) { + return '{% trans "Inheritable" %}'; + } else { + // If this BOM item is inherited from a parent part + return renderLink( + '{% trans "View BOM" %}', + `/part/${row.part}/bom/`, + ); + } + } }); cols.push( @@ -342,7 +366,12 @@ function loadBomTable(table, options) { return html; } else { - return ''; + // Return a link to the external BOM + + return renderLink( + '{% trans "View BOM" %}', + `/part/${row.part}/bom/` + ); } } });