From d606df16f7d668c8958e54e2a261e5535bf8662b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 11 Apr 2020 22:09:09 +1000 Subject: [PATCH] Bug fixes: - prevent addition of empty filter tags --- .../InvenTree/static/script/inventree/filters.js | 14 +++++++++----- .../InvenTree/static/script/inventree/order.js | 2 +- InvenTree/templates/table_filters.html | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/filters.js b/InvenTree/InvenTree/static/script/inventree/filters.js index 143b5bc2f7..2aa57b913c 100644 --- a/InvenTree/InvenTree/static/script/inventree/filters.js +++ b/InvenTree/InvenTree/static/script/inventree/filters.js @@ -16,6 +16,7 @@ function defaultFilters() { return { stock: "cascade=1", build: "", + parts: "cascade=1", }; } @@ -308,12 +309,15 @@ function setupFilterList(tableKey, table, target) { var tag = element.find(`#filter-tag-${tableKey}`).val(); var val = element.find(`#filter-value-${tableKey}`).val(); - var filters = addTableFilter(tableKey, tag, val); + // Only add the new filter if it is not empty! + if (tag && tag.length > 0) { + var filters = addTableFilter(tableKey, tag, val); + reloadTable(table, filters); + + // Run this function again + setupFilterList(tableKey, table, target); + } - reloadTable(table, filters); - - // Run this function again - setupFilterList(tableKey, table, target); }); } else { addClicked = false; diff --git a/InvenTree/InvenTree/static/script/inventree/order.js b/InvenTree/InvenTree/static/script/inventree/order.js index 4ef2fae019..f0d2663b32 100644 --- a/InvenTree/InvenTree/static/script/inventree/order.js +++ b/InvenTree/InvenTree/static/script/inventree/order.js @@ -106,7 +106,7 @@ function loadPurchaseOrderTable(table, options) { var params = options.params || {}; - var filters = loadTableFilters("build"); + var filters = loadTableFilters("order"); for (var key in params) { filters[key] = params[key]; diff --git a/InvenTree/templates/table_filters.html b/InvenTree/templates/table_filters.html index 0cefc2d9f5..cf8b609328 100644 --- a/InvenTree/templates/table_filters.html +++ b/InvenTree/templates/table_filters.html @@ -19,8 +19,8 @@ function getAvailableTableFilters(tableKey) { return { cascade: { type: 'bool', - description: '{% trans "Include stock in sublocations" %}', title: '{% trans "Include sublocations" %}', + description: '{% trans "Include stock in sublocations" %}', }, active: { type: 'bool',