mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor toot-toot
- Now can specify the "order" of fields
This commit is contained in:
parent
1754af3d43
commit
9f3f07aff3
@ -193,23 +193,39 @@ function constructCreateForm(url, fields, options={}) {
|
||||
ignored_fields.push('id');
|
||||
}
|
||||
|
||||
for (const key in fields) {
|
||||
// Construct an ordered list of field names
|
||||
var field_names = [];
|
||||
|
||||
// Skip over fields
|
||||
if (allowed_fields && !allowed_fields.includes(key)) {
|
||||
continue;
|
||||
if (allowed_fields) {
|
||||
allowed_fields.forEach(function(name) {
|
||||
|
||||
// Only push names which are actually in the set of fields
|
||||
if (name in fields) {
|
||||
|
||||
if (!ignored_fields.includes(name) && !field_names.includes(name)) {
|
||||
field_names.push(name);
|
||||
}
|
||||
} else {
|
||||
console.log(`WARNING: '${name}' does not match a valid field name.`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (const name in fields) {
|
||||
|
||||
if (!ignored_fields.includes(name) && !field_names.includes(name)) {
|
||||
field_names.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ignored_fields && ignored_fields.includes(key)) {
|
||||
continue;
|
||||
}
|
||||
field_names.forEach(function(name) {
|
||||
|
||||
var field = fields[key];
|
||||
var field = fields[name];
|
||||
|
||||
var f = constructField(key, field, options);
|
||||
var f = constructField(name, field, options);
|
||||
|
||||
html += f;
|
||||
}
|
||||
});
|
||||
|
||||
var modal = '#modal-form';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user