mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 06:18:48 +00:00
36 lines
868 B
HTML
36 lines
868 B
HTML
/*
|
|
* Status codes for the {{ label }} model.
|
|
*/
|
|
var {{ label }}Codes = {
|
|
{% for opt in options %}'{{ opt.key }}': {
|
|
key: '{{ opt.key }}',
|
|
value: '{{ opt.value }}',{% if opt.label %}
|
|
label: '{{ opt.label }}',{% endif %}
|
|
},{% endfor %}
|
|
};
|
|
|
|
/*
|
|
* Render the status for a {{ label }} object.
|
|
* Uses the values specified in "status_codes.py"
|
|
* This function is generated by the "status_codes.html" template
|
|
*/
|
|
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>`;
|
|
}
|