From b6b8763a55c5253683d8a306ebe6ddd998fd2c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Fri, 27 Aug 2021 17:14:18 +0300 Subject: [PATCH] Fixed changed fn in edit dossier template; update common-ui --- ...-edit-dossier-template-dialog.component.ts | 25 +++++++++---------- libs/common-ui | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-dossier-template-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-dossier-template-dialog.component.ts index 709468570..305b6ddd6 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-dossier-template-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-dossier-template-dialog.component.ts @@ -71,27 +71,26 @@ export class AddEditDossierTemplateDialogComponent implements OnInit { } for (const key of Object.keys(this.dossierTemplateForm.getRawValue())) { + const formValue = this.dossierTemplateForm.get(key).value; + const objectValue = this.dossierTemplate[key]; if (key === 'validFrom') { - if (this.hasValidFrom !== !!this.dossierTemplate.validFrom) { - return true; - } - if ( - this.hasValidFrom && - !moment(this.dossierTemplate.validFrom).isSame(moment(this.dossierTemplateForm.get('validFrom').value)) - ) { + if (this.hasValidFrom !== !!objectValue || (this.hasValidFrom && !moment(objectValue).isSame(moment(formValue)))) { return true; } } else if (key === 'validTo') { - if (this.hasValidTo !== !!this.dossierTemplate.validTo) { + if (this.hasValidTo !== !!objectValue || (this.hasValidTo && !moment(objectValue).isSame(moment(formValue)))) { return true; } - if ( - this.hasValidTo && - !moment(this.dossierTemplate.validTo).isSame(moment(this.dossierTemplateForm.get('validTo').value)) - ) { + } else if (formValue instanceof Array) { + if (objectValue.length !== formValue.length) { return true; } - } else if (this.dossierTemplate[key] !== this.dossierTemplateForm.get(key).value) { + for (const item of objectValue) { + if (!formValue.includes(item)) { + return true; + } + } + } else if (objectValue !== formValue) { return true; } } diff --git a/libs/common-ui b/libs/common-ui index 1afafe0e2..7029f2942 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 1afafe0e28239da365d9f1e663763b210b9a9b6f +Subproject commit 7029f2942d154e7910bb55ec7f7d44e9986f1abc