diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts b/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts index eac2dc5a7e..06dd8d030e 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts @@ -95,9 +95,10 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co branding: false }; - private propagateChange = (v: any) => { }; + private propagateChange = null; private readonly destroy$ = new Subject(); private expendedBlocks: NotificationDeliveryMethod[]; + private propagateChangePending = false; constructor(private fb: FormBuilder, private translate: TranslateService) { @@ -105,7 +106,7 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co this.templateConfigurationForm.valueChanges.pipe( takeUntil(this.destroy$) ).subscribe((value) => { - this.propagateChange(value); + this.updateModel(value); }); } @@ -129,6 +130,12 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co registerOnChange(fn: any): void { this.propagateChange = fn; + if (this.propagateChangePending) { + this.propagateChangePending = false; + Promise.resolve().then(() => { + this.templateConfigurationForm.updateValueAndValidity(); + }); + } } registerOnTouched(fn: any): void { @@ -164,6 +171,14 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co return this.expendedBlocks.includes(name); } + private updateModel(value: Partial) { + if (this.propagateChange) { + this.propagateChange(value); + } else { + this.propagateChangePending = true; + } + } + private updateExpandedForm() { this.expendedBlocks = []; Object.keys(this.templateConfigurationForm.controls).forEach((name: NotificationDeliveryMethod) => {