In my function, there are various statements to check the visibility of fields:
isFieldVisible(node: any, field: DocumentField): boolean {
if (field.tag === 'ADDR_KOMU') {
let field = this.dfs_look(node.children, 'ADDR_APPLICANTTYPE');
return field.fieldvalue == 1;
}
if (field.tag === 'ADDR_SNAME') {
let field = this.dfs_look(node.children, 'ADDR_APPLICANTTYPE');
return field.fieldvalue == 1;
}
if (field.tag === 'ADDR_FNAME') {
let field = this.dfs_look(node.children, 'ADDR_APPLICANTTYPE');
return field.fieldvalue == 1 || field.fieldvalue == 2;
}
}
To enhance the function and prevent duplicates, consider using a more modular approach.
I experimented with using foreach loops with tuples for iteration but encountered difficulties in returning boolean values from them.