mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds ability to specify which fields are displayed
This commit is contained in:
parent
e7bc53a548
commit
1754af3d43
@ -182,10 +182,25 @@ function constructCreateForm(url, fields, options={}) {
|
|||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
|
var allowed_fields = options.fields || null;
|
||||||
|
var ignored_fields = options.ignore || [];
|
||||||
|
|
||||||
|
if (!ignored_fields.includes('pk')) {
|
||||||
|
ignored_fields.push('pk');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ignored_fields.includes('id')) {
|
||||||
|
ignored_fields.push('id');
|
||||||
|
}
|
||||||
|
|
||||||
for (const key in fields) {
|
for (const key in fields) {
|
||||||
|
|
||||||
// Ignore any PK fields
|
// Skip over fields
|
||||||
if (key.toLowerCase() in ['pk', 'id']) {
|
if (allowed_fields && !allowed_fields.includes(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ignored_fields && ignored_fields.includes(key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,9 +420,12 @@ function constructInputOptions(name, classes, type, parameters) {
|
|||||||
|
|
||||||
opts.push(`type='${type}'`);
|
opts.push(`type='${type}'`);
|
||||||
|
|
||||||
// Existing value?
|
|
||||||
if (parameters.value) {
|
if (parameters.value) {
|
||||||
|
// Existing value?
|
||||||
opts.push(`value='${parameters.value}'`);
|
opts.push(`value='${parameters.value}'`);
|
||||||
|
} else if (parameters.default) {
|
||||||
|
// Otherwise, a defualt value?
|
||||||
|
opts.push(`value='${parameters.default}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maximum input length
|
// Maximum input length
|
||||||
|
Loading…
Reference in New Issue
Block a user