mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Refactored status code label generation
- Larger style available
This commit is contained in:
@ -4,8 +4,8 @@
|
||||
var {{ label }}Codes = {
|
||||
{% for opt in options %}'{{ opt.key }}': {
|
||||
key: '{{ opt.key }}',
|
||||
value: '{{ opt.value }}',{% if opt.label %}
|
||||
label: '{{ opt.label }}',{% endif %}
|
||||
value: '{{ opt.value }}',{% if opt.color %}
|
||||
color: '{{ opt.color }}',{% endif %}
|
||||
},{% endfor %}
|
||||
};
|
||||
|
||||
@ -18,18 +18,14 @@ 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;
|
||||
}
|
||||
// Select the label color
|
||||
var color = {{ label }}Codes[key].color ?? '#AAA';
|
||||
|
||||
return `<span class='label label-${label}'>${value}</span>`;
|
||||
return `<span class='label' style='background: ${color};'>${value}</span>`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user