Merge pull request #10976 from vvlladd28/bug/notification-template/resend-message

Fixed notification again not apply new params
This commit is contained in:
Igor Kulikov 2024-06-12 12:33:37 +03:00 committed by GitHub
commit 7daaf88b70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -95,9 +95,10 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co
branding: false branding: false
}; };
private propagateChange = (v: any) => { }; private propagateChange = null;
private readonly destroy$ = new Subject<void>(); private readonly destroy$ = new Subject<void>();
private expendedBlocks: NotificationDeliveryMethod[]; private expendedBlocks: NotificationDeliveryMethod[];
private propagateChangePending = false;
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private translate: TranslateService) { private translate: TranslateService) {
@ -105,7 +106,7 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co
this.templateConfigurationForm.valueChanges.pipe( this.templateConfigurationForm.valueChanges.pipe(
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe((value) => { ).subscribe((value) => {
this.propagateChange(value); this.updateModel(value);
}); });
} }
@ -129,6 +130,12 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co
registerOnChange(fn: any): void { registerOnChange(fn: any): void {
this.propagateChange = fn; this.propagateChange = fn;
if (this.propagateChangePending) {
this.propagateChangePending = false;
Promise.resolve().then(() => {
this.templateConfigurationForm.updateValueAndValidity();
});
}
} }
registerOnTouched(fn: any): void { registerOnTouched(fn: any): void {
@ -164,6 +171,14 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co
return this.expendedBlocks.includes(name); return this.expendedBlocks.includes(name);
} }
private updateModel(value: Partial<DeliveryMethodsTemplates>) {
if (this.propagateChange) {
this.propagateChange(value);
} else {
this.propagateChangePending = true;
}
}
private updateExpandedForm() { private updateExpandedForm() {
this.expendedBlocks = []; this.expendedBlocks = [];
Object.keys(this.templateConfigurationForm.controls).forEach((name: NotificationDeliveryMethod) => { Object.keys(this.templateConfigurationForm.controls).forEach((name: NotificationDeliveryMethod) => {