2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Render filter options as a template

- This allows the values to be seen by the translation layer
- Also means that whenever a new option is added, it will be automatically available to the front-end!
This commit is contained in:
Oliver Walters
2020-04-11 13:24:23 +10:00
parent 57c5d6c97a
commit c1b59eeaab
5 changed files with 78 additions and 46 deletions

View File

@ -1,4 +1,5 @@
{% load static %}
{% load i18n %}
<!DOCTYPE html>
<html lang="en">
@ -116,7 +117,10 @@ InvenTree
{% block js_load %}
{% endblock %}
{% include "table_filters.html" %}
<script type='text/javascript'>
$(document).ready(function () {
{% block js_ready %}
{% endblock %}
@ -125,6 +129,7 @@ $(document).ready(function () {
showCachedAlerts();
});
</script>
{% block js %}

View File

@ -0,0 +1,40 @@
{% load i18n %}
{% load inventree_extras %}
<script type='text/javascript'>
{% load_status_codes %}
function getAvailableTableFilters(tableKey) {
// Filters for the "Stock" table
if (tableKey == 'stock') {
return {
'cascade': {
'type': 'bool',
'description': '{% trans "Include stock in sublocations" %}',
'title': '{% trans "Include sublocations" %}',
},
'active': {
'type': 'bool',
'title': '{% trans "Active parts" %}',
'description': '{% trans "Show stock for active parts" %}',
},
'status': {
'options': {
{% for opt in stock_status_codes %}'{{ opt.value }}': '{{ opt.key }}',
{% endfor %}
},
'title': 'Stock status',
'description': 'Stock status',
},
'test': {
title: 'A test parameter',
},
};
}
// Finally, no matching key
return {};
}
</script>