UI: Fixed notification template control not propagate new init value
This commit is contained in:
parent
2c2273d15b
commit
70a418cfb2
@ -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) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user