mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-27 17:20:49 +00:00
Improvements for status code generation
- Now includes labels - Python template generates javascript which is then rendered? I don't even follow it any more
This commit is contained in:
27
InvenTree/templates/status_codes.html
Normal file
27
InvenTree/templates/status_codes.html
Normal file
@ -0,0 +1,27 @@
|
||||
var {{ label }}Codes = {
|
||||
{% for opt in options %}'{{ opt.key }}': {
|
||||
key: '{{ opt.key }}',
|
||||
value: '{{ opt.value }}',{% if opt.label %}
|
||||
label: '{{ opt.label }}',{% endif %}
|
||||
},{% endfor %}
|
||||
};
|
||||
|
||||
function {{ label }}StatusDisplay(key) {
|
||||
|
||||
key = String(key);
|
||||
|
||||
var label = {{ label }}Codes[key].label;
|
||||
|
||||
var value = {{ label }}Codes[key].value;
|
||||
|
||||
if (value == null || value.length == 0) {
|
||||
value = key;
|
||||
}
|
||||
|
||||
// Label not found, return the original string
|
||||
if (label == null || label.length == 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return `<span class='label label-${label}'>${value}</span>`;
|
||||
}
|
Reference in New Issue
Block a user