mirror of
https://github.com/frappe/books.git
synced 2024-12-22 19:09:01 +00:00
fix: isRequired handling
- add support for default value in fields
This commit is contained in:
parent
387688cebb
commit
9f4f2828ca
@ -92,4 +92,5 @@ export type RawCustomField = {
|
|||||||
options?: string;
|
options?: string;
|
||||||
target?: string;
|
target?: string;
|
||||||
references?: string;
|
references?: string;
|
||||||
|
default?: string;
|
||||||
};
|
};
|
||||||
|
@ -150,5 +150,6 @@ export class CustomField extends Doc {
|
|||||||
this.fieldtype === 'Select' || this.fieldtype === 'AutoComplete',
|
this.fieldtype === 'Select' || this.fieldtype === 'AutoComplete',
|
||||||
target: () => this.fieldtype === 'Link' || this.fieldtype === 'Table',
|
target: () => this.fieldtype === 'Link' || this.fieldtype === 'Table',
|
||||||
references: () => this.fieldtype === 'DynamicLink',
|
references: () => this.fieldtype === 'DynamicLink',
|
||||||
|
default: () => !!this.isRequired,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,11 @@
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "default",
|
||||||
|
"label": "Default",
|
||||||
|
"fieldtype": "Data"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section",
|
"fieldname": "section",
|
||||||
"label": "Form Section",
|
"label": "Form Section",
|
||||||
@ -128,6 +133,7 @@
|
|||||||
"fieldname",
|
"fieldname",
|
||||||
"fieldtype",
|
"fieldtype",
|
||||||
"isRequired",
|
"isRequired",
|
||||||
|
"default",
|
||||||
"options",
|
"options",
|
||||||
"target",
|
"target",
|
||||||
"references",
|
"references",
|
||||||
|
@ -296,6 +296,7 @@ function getFieldMapFromRawCustomFields(
|
|||||||
section,
|
section,
|
||||||
tab,
|
tab,
|
||||||
options: rawOptions,
|
options: rawOptions,
|
||||||
|
default: defaultValue,
|
||||||
target,
|
target,
|
||||||
references,
|
references,
|
||||||
}
|
}
|
||||||
@ -343,6 +344,14 @@ function getFieldMapFromRawCustomFields(
|
|||||||
(field as DynamicLinkField).references = references;
|
(field as DynamicLinkField).references = references;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field.required && defaultValue != null) {
|
||||||
|
field.default = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.required && field.default == null) {
|
||||||
|
field.required = false;
|
||||||
|
}
|
||||||
|
|
||||||
map[parent].push(field);
|
map[parent].push(field);
|
||||||
return map;
|
return map;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user