From 39f32d8e3e727e3ab5fe1356210623ae88606cfc Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Wed, 4 Sep 2024 15:08:11 +0200 Subject: [PATCH] OZG-6620 Bugfix signatur updates --- .../postfach-mail-form.component.html | 2 +- .../postfach-mail-form.component.spec.ts | 18 ++++++++++-------- .../postfach-mail-form.component.ts | 12 +++++++----- .../postfach-mail.formservice.spec.ts | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) 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 f9051a515a..d56015aac3 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 466c580e54..08e3be339c 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 f49b402a43..007d0797b4 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 ac21899898..6a56691103 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); }); }); -- GitLab