Further work on templated filter options

This commit is contained in:
Oliver Walters 2020-04-11 13:38:51 +10:00
parent c1b59eeaab
commit 5d2441776e
3 changed files with 30 additions and 7 deletions

View File

@ -233,7 +233,8 @@ function getFilterDescription(tableKey, filterKey) {
*/ */
function getFilterOptionValue(tableKey, filterKey, valueKey) { function getFilterOptionValue(tableKey, filterKey, valueKey) {
var filter = getFilterOption(tableKey, filterKey); var filter = getFilterSettings(tableKey, filterKey);
var value = String(valueKey); var value = String(valueKey);

View File

@ -55,7 +55,10 @@ function updateStockFilterList(filterListElement, table) {
var filters = loadTableFilters("stock"); var filters = loadTableFilters("stock");
for (var key in filters) { for (var key in filters) {
$(filterListElement).append(`<li>${key} = ${filters[key]}<span filter-tag-stock='${key}' class='close'>x</span></li>` );
var value = getFilterOptionValue("stock", key, filters[key]);
$(filterListElement).append(`<li>${key} = ${value}<span filter-tag-stock='${key}' class='close'>x</span></li>` );
} }
// Whenever the callback is called, pass the original parameters through // Whenever the callback is called, pass the original parameters through

View File

@ -7,6 +7,8 @@
function getAvailableTableFilters(tableKey) { function getAvailableTableFilters(tableKey) {
tableKey = tableKey.toLowerCase();
// Filters for the "Stock" table // Filters for the "Stock" table
if (tableKey == 'stock') { if (tableKey == 'stock') {
return { return {
@ -25,15 +27,32 @@ function getAvailableTableFilters(tableKey) {
{% for opt in stock_status_codes %}'{{ opt.value }}': '{{ opt.key }}', {% for opt in stock_status_codes %}'{{ opt.value }}': '{{ opt.key }}',
{% endfor %} {% endfor %}
}, },
'title': 'Stock status', 'title': '{% trans "Stock status" %}',
'description': 'Stock status', 'description': '{% trans "Stock status" %}',
},
'test': {
title: 'A test parameter',
}, },
}; };
} }
// 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 // Finally, no matching key
return {}; return {};
} }