2
0
mirror of https://github.com/frappe/books.git synced 2024-09-18 18:49:01 +00:00

fix: isRequired handling

- add support for default value in fields
This commit is contained in:
18alantom 2023-09-18 15:21:56 +05:30 committed by Alan
parent 387688cebb
commit 316f052c53
4 changed files with 17 additions and 0 deletions

View File

@ -92,4 +92,5 @@ export type RawCustomField = {
options?: string;
target?: string;
references?: string;
default?: string;
};

View File

@ -150,5 +150,6 @@ export class CustomField extends Doc {
this.fieldtype === 'Select' || this.fieldtype === 'AutoComplete',
target: () => this.fieldtype === 'Link' || this.fieldtype === 'Table',
references: () => this.fieldtype === 'DynamicLink',
default: () => !!this.isRequired,
};
}

View File

@ -94,6 +94,11 @@
"fieldtype": "Check",
"default": false
},
{
"fieldname": "default",
"label": "Default",
"fieldtype": "Data"
},
{
"fieldname": "section",
"label": "Form Section",
@ -128,6 +133,7 @@
"fieldname",
"fieldtype",
"isRequired",
"default",
"options",
"target",
"references",

View File

@ -296,6 +296,7 @@ function getFieldMapFromRawCustomFields(
section,
tab,
options: rawOptions,
default: defaultValue,
target,
references,
}
@ -343,6 +344,14 @@ function getFieldMapFromRawCustomFields(
(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);
return map;
},