mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			975 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			975 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
/*
 | 
						|
 * Status codes for the {{ label }} model.
 | 
						|
 */
 | 
						|
const {{ label }}Codes = {
 | 
						|
    {% for opt in options %}'{{ opt.key }}': {
 | 
						|
        key: '{{ opt.key }}',
 | 
						|
        value: '{{ opt.value }}',{% if opt.color %}
 | 
						|
        label: 'label-{{ opt.color }}',{% 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, options={}) {
 | 
						|
 | 
						|
    key = String(key);
 | 
						|
 | 
						|
    var value = null;
 | 
						|
    var label = null;
 | 
						|
 | 
						|
    if (key in {{ label }}Codes) {
 | 
						|
        value = {{ label }}Codes[key].value;
 | 
						|
        label = {{ label }}Codes[key].label;
 | 
						|
    }
 | 
						|
 | 
						|
    if (value == null || value.length == 0) {
 | 
						|
        value = key;
 | 
						|
        label = '';
 | 
						|
    }
 | 
						|
 | 
						|
    var classes = `label ${label}`;
 | 
						|
 | 
						|
    if (options.classes) {
 | 
						|
        classes += ' ' + options.classes;
 | 
						|
    }
 | 
						|
 | 
						|
    return `<span class='${classes}'>${value}</span>`;
 | 
						|
}
 |