From 24ab48ef4c77bbf7ee74b107fddf077d81308d03 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 26 Oct 2020 13:53:34 +1100 Subject: [PATCH] Filter BOM table by "trackable" status --- InvenTree/part/templates/part/bom.html | 3 ++ InvenTree/templates/js/bom.js | 45 +++++++++++++++---------- InvenTree/templates/js/table_filters.js | 10 ++++++ 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html index c996edc2db..2d8fb192d6 100644 --- a/InvenTree/part/templates/part/bom.html +++ b/InvenTree/part/templates/part/bom.html @@ -47,6 +47,9 @@ {% endif %} {% endif %} +
+ +
diff --git a/InvenTree/templates/js/bom.js b/InvenTree/templates/js/bom.js index 7686220d8c..e173607bbb 100644 --- a/InvenTree/templates/js/bom.js +++ b/InvenTree/templates/js/bom.js @@ -102,8 +102,31 @@ function loadBomTable(table, options) { * * BOM data are retrieved from the server via AJAX query */ + + var params = { + part: options.parent_id, + ordering: 'name', + } - // Construct the table columns + if (options.part_detail) { + params.part_detail = true; + } + + if (options.sub_part_detail) { + params.sub_part_detail = true; + } + + var filters = {}; + + if (!options.disableFilters) { + filters = loadTableFilters("bom"); + } + + for (var key in params) { + filters[key] = params[key]; + } + + setupFilterList("bom", $(table)); var cols = []; @@ -128,7 +151,7 @@ function loadBomTable(table, options) { var html = imageHoverIcon(row.sub_part_detail.thumbnail) + renderLink(row.sub_part_detail.full_name, url); if (row.sub_part_detail.trackable) { - html += ``; + html += ``; } // Display an extra icon if this part is an assembly @@ -270,21 +293,6 @@ function loadBomTable(table, options) { }); } - // Configure the table (bootstrap-table) - - var params = { - part: options.parent_id, - ordering: 'name', - } - - if (options.part_detail) { - params.part_detail = true; - } - - if (options.sub_part_detail) { - params.sub_part_detail = true; - } - // Function to request BOM data for sub-items // This function may be called recursively for multi-level BOMs function requestSubItems(bom_pk, part_pk) { @@ -337,7 +345,8 @@ function loadBomTable(table, options) { }, formatNoMatches: function() { return "{% trans "No BOM items found" %}"; }, clickToSelect: true, - queryParams: params, + queryParams: filters, + original: params, columns: cols, url: options.bom_url, onPostBody: function() { diff --git a/InvenTree/templates/js/table_filters.js b/InvenTree/templates/js/table_filters.js index 9b73c3f311..114e777c75 100644 --- a/InvenTree/templates/js/table_filters.js +++ b/InvenTree/templates/js/table_filters.js @@ -11,6 +11,16 @@ function getAvailableTableFilters(tableKey) { tableKey = tableKey.toLowerCase(); + // Filters for Bill of Materials table + if (tableKey == "bom") { + return { + trackable: { + type: 'bool', + title: '{% trans "Trackable Part" %}' + } + }; + } + // Filters for the "customer stock" table (really a subset of "stock") if (tableKey == "customerstock") { return {