Skip to content

Commit

Permalink
moved repeated code to function
Browse files Browse the repository at this point in the history
  • Loading branch information
RiteshHMCTS committed Nov 26, 2024
1 parent 2074faf commit 6d96a8a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export class FieldTypeSanitiser {
field.field_type.complex_fields.forEach((complexField) => {
if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
this.checkNestedDynamicList(complexField, caseFieldData?.[complexField.id]);
} else if (
FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(complexField.field_type.type) !== -1 &&
} else if (this.isDynamicList(complexField.field_type.type) &&
complexField.display_context !== 'HIDDEN' &&
field._value?.[complexField.id]
) {
Expand All @@ -81,8 +80,7 @@ export class FieldTypeSanitiser {
caseField.field_type.complex_fields.forEach((complexField) => {
if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
this.checkNestedDynamicList(complexField, fieldData?.[complexField.id]);
} else if (
FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(complexField.field_type.type) !== -1 &&
} else if (this.isDynamicList(complexField.field_type.type) &&
complexField.display_context !== 'HIDDEN' &&
fieldData?.[complexField.id]
) {
Expand All @@ -91,6 +89,10 @@ export class FieldTypeSanitiser {
});
}

private isDynamicList(fieldType: FieldTypeEnum): boolean {
return FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(fieldType) !== -1;
}

private convertArrayToDynamicListOutput(field: CaseField, data: any): void {
const values = data[field.id];
if (Array.isArray(values)) {
Expand Down

0 comments on commit 6d96a8a

Please sign in to comment.