mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Updates for field rendering
This commit is contained in:
		@@ -176,9 +176,14 @@ function constructCreateForm(url, fields, options={}) {
 | 
				
			|||||||
    var html = '';
 | 
					    var html = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const key in fields) {
 | 
					    for (const key in fields) {
 | 
				
			||||||
        //console.log('field:', key);
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        html += constructField(key, fields[key], options);
 | 
					        var field = fields[key];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        console.log(key, field.label, field.help_text);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        var f = constructField(key, field, options);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        html += f;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var modal = '#modal-form';
 | 
					    var modal = '#modal-form';
 | 
				
			||||||
@@ -218,16 +223,19 @@ function constructField(name, parameters, options={}) {
 | 
				
			|||||||
    html += constructLabel(name, parameters);
 | 
					    html += constructLabel(name, parameters);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    html += `<div class='controls'>`;
 | 
					    html += `<div class='controls'>`;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    html += constructInput(name, parameters, options);
 | 
					    html += constructInput(name, parameters, options);
 | 
				
			||||||
    html += constructHelpText(name, parameters, options);
 | 
					    
 | 
				
			||||||
 | 
					    if (parameters.help_text) {
 | 
				
			||||||
 | 
					        html += constructHelpText(name, parameters, options);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    // TODO: Add the "error message"
 | 
					    // TODO: Add the "error message"
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    html += `</div>`;   // controls
 | 
					    html += `</div>`;   // controls
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    html += `</div>`;   // form-group
 | 
					    html += `</div>`;   // form-group
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    return html;
 | 
					    return html;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -247,15 +255,18 @@ function constructLabel(name, parameters) {
 | 
				
			|||||||
        label_classes += ' requiredField';
 | 
					        label_classes += ' requiredField';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var html ='';
 | 
					    var html = `<label class='${label_classes}' for='id_${name}'>`;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    html += `<label class='${label_classes}' for='id_${name}'>`;
 | 
					    if (parameters.label) {
 | 
				
			||||||
    html += name;
 | 
					        html += `${parameters.label}`;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        html += `${name}`;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (parameters.required) {
 | 
					    if (parameters.required) {
 | 
				
			||||||
        html =+ `<span class='asteriskField'>*</span>`;
 | 
					        html += `<span class='asteriskField'>*</span>`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    html += `</label>`;
 | 
					    html += `</label>`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return html;
 | 
					    return html;
 | 
				
			||||||
@@ -274,7 +285,15 @@ function constructInput(name, parameters, options={}) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    var html = '';
 | 
					    var html = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO: Construct an input field based on the field type!
 | 
					    // TODO: Construct input differently depending on the input type!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    html = `<input id='id_${name}' class='form-control'`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (parameters.required) {
 | 
				
			||||||
 | 
					        html += " required=''";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    html += '>';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return html;
 | 
					    return html;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user