diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html index f9051a515a935c512c5e6660db737afac2114d72..d56015aac37f56b6dcfc2896294f60388b1c5865 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html @@ -40,7 +40,7 @@ [formControlName]="formServiceClass.FIELD_MAIL_BODY" label="Text" class="message-editor mt-3" - [value]="signatur" + [value]="signatur$ | async" [autoFocus]="true" [required]="true" > diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts index 466c580e54dc255424203fa32e167954a5a94131..08e3be339ca7e06c358779a2d18ea45c5568fd18 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts @@ -125,18 +125,20 @@ describe('PostfachMailFormComponent', () => { expect(component.patchPostfachNachricht).toHaveBeenCalled(); }); }); + }); - describe('on setting signatur', () => { - it('should call postfachService', () => { - component.ngOnInit(); + describe('ngAfterViewInit', () => { + it('should call postfachService', () => { + component.ngOnInit(); - expect(postfachService.getSettings).toHaveBeenCalled(); - }); + expect(postfachService.getSettings).toHaveBeenCalled(); + }); - it('should set signatur', () => { - component.ngOnInit(); + it('should set signatur', () => { + component.ngOnInit(); - expect(component.signatur).toBe(postfachSettings.signatur); + component.signatur$.subscribe((signatur: string) => { + expect(signatur).toBe(postfachSettings.signatur); }); }); }); diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts index f49b402a431bc3150e5b6948739db2147570e4b6..007d0797b4cca8e6da1083cffe3b5565d6806a38 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts @@ -25,7 +25,7 @@ import { CommandResource } from '@alfa-client/command-shared'; import { PostfachMailFormDialogData } from '@alfa-client/postfach-shared'; import { StateResource, createEmptyStateResource, isNotNil } from '@alfa-client/tech-shared'; import { DialogService } from '@alfa-client/ui'; -import { Component, Inject, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { Observable, of, tap } from 'rxjs'; import { PostfachMailFormservice } from './postfach-mail.formservice'; @@ -39,8 +39,8 @@ import * as CommandUtil from '../../../../command-shared/src/lib/command.util'; providers: [PostfachMailFormservice], }) export class PostfachMailFormComponent implements OnInit { + public signatur$: Observable<string>; public readonly formServiceClass = PostfachMailFormservice; - public signatur = ''; public sendInProgress$: Observable<StateResource<CommandResource>> = of( createEmptyStateResource<CommandResource>(), @@ -50,16 +50,18 @@ export class PostfachMailFormComponent implements OnInit { private dialogService: DialogService, @Inject(MAT_DIALOG_DATA) public dialogData: PostfachMailFormDialogData, public formService: PostfachMailFormservice, + private changeDetectorRef: ChangeDetectorRef, ) {} ngOnInit(): void { if (isNotNil(this.dialogData.postfachNachricht)) { this.patchPostfachNachricht(); } + } - this.formService.getSignatur().subscribe((signatur: string) => { - this.signatur = signatur; - }); + ngAfterViewInit(): void { + this.signatur$ = this.formService.getSignatur(); + this.changeDetectorRef.detectChanges(); } patchPostfachNachricht(): void { diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail.formservice.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail.formservice.spec.ts index ac21899898805e073c303f03f79285dbc08722ae..6a566911033bb6c879743d89ff6cb87b5462c308 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail.formservice.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail.formservice.spec.ts @@ -102,7 +102,7 @@ describe('PostfachMailFormservice', () => { }); it('should return signatur', () => { - formService.getSignatur().subscribe((signatur) => { + formService.getSignatur().subscribe((signatur: string) => { expect(signatur).toBe(postfachSettings.signatur); }); });