From cbaaee657ae09ece2ed85b0ad86683422c232981 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 2 May 2023 17:56:29 +0300 Subject: [PATCH 1/2] UI: Fixed error review in send notification --- .../notification/sent/sent-notification-dialog.componet.ts | 3 --- .../home/pages/notification/template/template-configuration.ts | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts index 3d8857694b..b85a891e4e 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts @@ -72,9 +72,6 @@ export class SentNotificationDialogComponent extends notificationRequestForm: FormGroup; - notificationDeliveryMethods = Object.keys(NotificationDeliveryMethod) as NotificationDeliveryMethod[]; - notificationDeliveryMethodTranslateMap = NotificationDeliveryMethodTranslateMap; - selectedIndex = 0; preview: NotificationRequestPreview = null; diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts index 79612a8592..e894c62631 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts @@ -190,7 +190,7 @@ export abstract class TemplateConfiguration extends DialogComponent< protected getNotificationTemplateValue(): NotificationTemplate { const template: NotificationTemplate = deepClone(this.templateNotificationForm.value); this.notificationDeliveryMethods.forEach(method => { - if (template.configuration.deliveryMethodsTemplates[method].enabled) { + if (template.configuration.deliveryMethodsTemplates[method]?.enabled) { Object.assign(template.configuration.deliveryMethodsTemplates[method], this.deliveryMethodFormsMap.get(method).value, {method}); } else { delete template.configuration.deliveryMethodsTemplates[method]; From 64ed2646ccff9e06fafca8655093178dc55b905a Mon Sep 17 00:00:00 2001 From: Vladyslav Prykhodko Date: Tue, 2 May 2023 20:18:15 +0300 Subject: [PATCH 2/2] UI: Fixed incorrect updated allow delivery method disable state --- .../sent/sent-notification-dialog.componet.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts index b85a891e4e..4846cd063d 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts @@ -16,7 +16,6 @@ import { NotificationDeliveryMethod, - NotificationDeliveryMethodTranslateMap, NotificationRequest, NotificationRequestPreview, NotificationTarget, @@ -81,6 +80,8 @@ export class SentNotificationDialogComponent extends private authUser: AuthUser = getCurrentAuthUser(this.store); + private allowNotificationDeliveryMethods: Array; + constructor(protected store: Store, protected router: Router, protected dialogRef: MatDialogRef, @@ -127,6 +128,7 @@ export class SentNotificationDialogComponent extends } else { this.notificationRequestForm.get('templateId').disable({emitEvent: false}); this.notificationRequestForm.get('template').enable({emitEvent: false}); + this.updateDeliveryMethodsDisableState(); } }); @@ -334,15 +336,20 @@ export class SentNotificationDialogComponent extends refreshAllowDeliveryMethod() { this.notificationService.getAvailableDeliveryMethods({ignoreLoading: true}).subscribe(allowMethods => { - this.notificationDeliveryMethods.forEach(method => { - if (allowMethods.includes(method)) { - this.getDeliveryMethodsTemplatesControl(method).enable({emitEvent: true}); - } else { - this.getDeliveryMethodsTemplatesControl(method).disable({emitEvent: true}); - this.getDeliveryMethodsTemplatesControl(method).setValue(false, {emitEvent: true}); //used for notify again - } - }); + this.allowNotificationDeliveryMethods = allowMethods; + this.updateDeliveryMethodsDisableState(); this.showRefresh = (this.notificationDeliveryMethods.length !== allowMethods.length); }); } + + private updateDeliveryMethodsDisableState() { + this.notificationDeliveryMethods.forEach(method => { + if (this.allowNotificationDeliveryMethods.includes(method)) { + this.getDeliveryMethodsTemplatesControl(method).enable({emitEvent: true}); + } else { + this.getDeliveryMethodsTemplatesControl(method).disable({emitEvent: true}); + this.getDeliveryMethodsTemplatesControl(method).setValue(false, {emitEvent: true}); //used for notify again + } + }); + } }