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:
@ -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 %}
|
||||
|
40
InvenTree/templates/table_filters.html
Normal file
40
InvenTree/templates/table_filters.html
Normal 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>
|
Reference in New Issue
Block a user