From 5d2441776e66276efe09c14737168f8dd87217fd Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 11 Apr 2020 13:38:51 +1000 Subject: [PATCH] Further work on templated filter options --- .../static/script/inventree/filters.js | 3 +- .../static/script/inventree/stock.js | 5 +++- InvenTree/templates/table_filters.html | 29 +++++++++++++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/filters.js b/InvenTree/InvenTree/static/script/inventree/filters.js index cadc1021f5..bf22aa4fd7 100644 --- a/InvenTree/InvenTree/static/script/inventree/filters.js +++ b/InvenTree/InvenTree/static/script/inventree/filters.js @@ -233,7 +233,8 @@ function getFilterDescription(tableKey, filterKey) { */ function getFilterOptionValue(tableKey, filterKey, valueKey) { - var filter = getFilterOption(tableKey, filterKey); + var filter = getFilterSettings(tableKey, filterKey); + var value = String(valueKey); diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index 0c039098e3..56e9954f8a 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -55,7 +55,10 @@ function updateStockFilterList(filterListElement, table) { var filters = loadTableFilters("stock"); for (var key in filters) { - $(filterListElement).append(`
  • ${key} = ${filters[key]}x
  • ` ); + + var value = getFilterOptionValue("stock", key, filters[key]); + + $(filterListElement).append(`
  • ${key} = ${value}x
  • ` ); } // Whenever the callback is called, pass the original parameters through diff --git a/InvenTree/templates/table_filters.html b/InvenTree/templates/table_filters.html index d908dfa38c..5ab0aefec8 100644 --- a/InvenTree/templates/table_filters.html +++ b/InvenTree/templates/table_filters.html @@ -7,6 +7,8 @@ function getAvailableTableFilters(tableKey) { + tableKey = tableKey.toLowerCase(); + // Filters for the "Stock" table if (tableKey == 'stock') { return { @@ -25,15 +27,32 @@ function getAvailableTableFilters(tableKey) { {% for opt in stock_status_codes %}'{{ opt.value }}': '{{ opt.key }}', {% endfor %} }, - 'title': 'Stock status', - 'description': 'Stock status', - }, - 'test': { - title: 'A test parameter', + 'title': '{% trans "Stock status" %}', + 'description': '{% trans "Stock status" %}', }, }; } + // Filters for the "Build" table + if (tableKey == 'build') { + return { + + }; + } + + // Filters for the "Order" table + if (tableKey == "order") { + return { + + }; + } + + // Filters fro the "Parts" table + if (tableKey == "parts") { + return { + }; + } + // Finally, no matching key return {}; }