mirror of
https://github.com/frappe/books.git
synced 2024-12-25 12:10:06 +00:00
feat: add convenience function to get fields meta map
This commit is contained in:
parent
317eb3116b
commit
0af2ce86f4
@ -194,7 +194,6 @@ module.exports = class BaseDocument extends Observable {
|
||||
}
|
||||
|
||||
validateMandatory() {
|
||||
const fieldValueMap = this.getFieldValueMap();
|
||||
let checkForMandatory = [this];
|
||||
let tableFields = this.meta.fields.filter((df) => df.fieldtype === 'Table');
|
||||
tableFields.map((df) => {
|
||||
@ -215,7 +214,7 @@ module.exports = class BaseDocument extends Observable {
|
||||
function getMissingMandatory(doc) {
|
||||
let mandatoryFields = doc.meta.fields.filter((df) => {
|
||||
if (df.required instanceof Function) {
|
||||
return df.required(fieldValueMap);
|
||||
return df.required(doc);
|
||||
}
|
||||
return df.required;
|
||||
});
|
||||
@ -702,4 +701,11 @@ module.exports = class BaseDocument extends Observable {
|
||||
}, {});
|
||||
return Object.freeze(fieldValueMap);
|
||||
}
|
||||
|
||||
getFieldMetaMap() {
|
||||
return this.meta.fields.reduce((obj, meta) => {
|
||||
obj[meta.fieldname] = meta;
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user