diff --git a/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts b/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts index a437a7423d4fd97d9f9ca822e6d1afe8140ed2e7..2f77fb889712a69d0b7c21e4b791e137e43ed532 100644 --- a/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts +++ b/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts @@ -439,7 +439,7 @@ describe('PostfachService', () => { const postfachMailListResource: PostfachMailListResource = createPostfachMailListResource(); beforeEach(() => { - service.loadPostfachMailList = jest.fn(); + service._loadPostfachMailList = jest.fn(); repository.resetHasNewPostfachNachrichten = jest.fn().mockReturnValue(of({})); }); @@ -452,7 +452,7 @@ describe('PostfachService', () => { it('should load postfach mail list', () => { service._loadAfterResetHasNewPostfachNachrichten(postfachMailListResource); - expect(service.loadPostfachMailList).toHaveBeenCalled(); + expect(service._loadPostfachMailList).toHaveBeenCalled(); }); }); @@ -492,7 +492,7 @@ describe('PostfachService', () => { describe('getPostfachMailListByVorgang', () => { beforeEach(() => { - service.loadPostfachMailList = jest.fn(); + service._loadPostfachMailList = jest.fn(); service.postfachMailList$.next(createEmptyStateResource()); service._refreshVorgangSubscription = jest.fn(); }); @@ -506,7 +506,7 @@ describe('PostfachService', () => { it('should call service loadPostfachMailList', () => { service.getPostfachMailListByVorgang(); - expect(service.loadPostfachMailList).toHaveBeenCalled(); + expect(service._loadPostfachMailList).toHaveBeenCalled(); }); }); @@ -520,25 +520,25 @@ describe('PostfachService', () => { vorgangService.getVorgangWithEingang.mockReturnValue(of(createStateResource(createVorgangWithEingangResource()))); }); it('should set loading to true', () => { - service.loadPostfachMailList(); + service._loadPostfachMailList(); expect(service._setPostfachMailListLoading).toHaveBeenCalled(); }); it('should call vorgang service', () => { - service.loadPostfachMailList(); + service._loadPostfachMailList(); expect(vorgangService.getVorgangWithEingang).toHaveBeenCalled(); }); it('should call repository', () => { - service.loadPostfachMailList(); + service._loadPostfachMailList(); expect(repository.loadPostfachMailList).toHaveBeenCalled(); }); it('should set loading to false', () => { - service.loadPostfachMailList(); + service._loadPostfachMailList(); expect(service._setPostfachMailList).toHaveBeenCalled(); }); diff --git a/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts b/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts index 8fe65072e995c95a4f97ee07dfc9b8ccc9891548..4e37da76a3dbe6829b8c20653fdb5320aa467a4c 100644 --- a/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts +++ b/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts @@ -273,7 +273,7 @@ export class PostfachService { .resetHasNewPostfachNachrichten(postfachMailListResource) .pipe( take(1), - tap(() => this.loadPostfachMailList()), + tap(() => this._loadPostfachMailList()), ) .subscribe(); } @@ -307,12 +307,12 @@ export class PostfachService { public getPostfachMailListByVorgang(): Observable<StateResource<PostfachMailListResource>> { this._refreshVorgangSubscription(); doIfLoadingRequired(this.postfachMailList$.value, () => { - this.loadPostfachMailList(); + this._loadPostfachMailList(); }); return this.postfachMailList$.asObservable(); } - loadPostfachMailList(): void { + _loadPostfachMailList(): void { this._setPostfachMailListLoading(); this.vorgangService .getVorgangWithEingang() diff --git a/alfa-client/libs/postfach-shared/test/postfach.ts b/alfa-client/libs/postfach-shared/test/postfach.ts index 831f9b7eeafd5401719b392b56d1a79b2c0cb212..8f5abd0ae423b823545323039f6cda385250ee9d 100644 --- a/alfa-client/libs/postfach-shared/test/postfach.ts +++ b/alfa-client/libs/postfach-shared/test/postfach.ts @@ -21,9 +21,9 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { createStateResource } from '@alfa-client/tech-shared'; import { faker } from '@faker-js/faker'; import { Resource } from '@ngxp/rest'; +import { createStateResource } from 'libs/tech-shared/src/lib/resource/resource.util'; import { toResource } from 'libs/tech-shared/test/resource'; import { times } from 'lodash-es'; import { PostfachMailListLinkRel } from '../src/lib/postfach.linkrel'; diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail-list.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail-list.component.html index 672c5309e6edfdcabc8116e325294378c1d22847..8261c1c0b92f4fd2a4654c77e5d270c5e0281b5e 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail-list.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail-list.component.html @@ -28,42 +28,36 @@ <h3 class="nachrichten">Nachrichten</h3> <alfa-postfach-mail-list-mailbox-icon [hasNewPostfachNachricht]="vorgangStateResource.resource.hasNewPostfachNachricht" /> </div> - <alfa-postfach-mail-pdf-button-container - [postfachMailListResource]="postfachMailListStateResource.resource" - ></alfa-postfach-mail-pdf-button-container> - <ng-container *ngIf="postfachMailListStateResource.resource | hasLink: postfachMailListLinkRel.SEND_POSTFACH_MAIL"> + + <alfa-postfach-mail-pdf-button-container [postfachMailListResource]="postfachMailListStateResource.resource" /> + + @if(postfachMailListStateResource.resource | hasLink: postfachMailListLinkRel.SEND_POSTFACH_MAIL){ <alfa-postfach-mail-button-container toolTip="Neue Nachricht erstellen" tooltipAriaType="aria-labelledby" [vorgang]="vorgangStateResource.resource" data-test-id="postfach-mail-button-container-no-label" - ></alfa-postfach-mail-button-container> - </ng-container> + /> + } </div> <ozgcloud-spinner [stateResource]="postfachMailListStateResource"> - <alfa-postfach-mail - *ngFor=" - let postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST - " - class="postfach" - [vorgangStateResource]="vorgangStateResource" - [postfachMail]="postfachMail" - [attr.data-test-id]="(postfachMail.subject | convertForDataTest) + '-item'" - > - </alfa-postfach-mail> + @for (postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST; track $index){ + <alfa-postfach-mail + class="postfach" + [vorgangStateResource]="vorgangStateResource" + [postfachMail]="postfachMail" + [attr.data-test-id]="(postfachMail.subject | convertForDataTest) + '-item'" + /> + } </ozgcloud-spinner> -<ng-container - *ngIf="postfachMailListStateResource.resource | hasLink: postfachMailListLinkRel.SEND_POSTFACH_MAIL; else noPostfach" -> +@if(postfachMailListStateResource.resource | hasLink: postfachMailListLinkRel.SEND_POSTFACH_MAIL){ <alfa-postfach-mail-button-container text="Nachricht" [vorgang]="vorgangStateResource.resource" data-test-id="postfach-mail-button-container" - ></alfa-postfach-mail-button-container> -</ng-container> - -<ng-template #noPostfach> + /> +} @else { <span class="no-postfach-text" data-test-id="no-postfach-text">Dieser Vorgang ist nicht mit einem Postfach verknüpft.</span> -</ng-template> +} \ No newline at end of file diff --git a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.html b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.html index 617abb23dfe032aa974dd451cce361768a82a5a5..c9887d2a2ced78a630f8a120a194add65966b786 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.html @@ -1,4 +1,4 @@ -@if (postfachMailListStateResource.resource | hasLink: PostfachMailListLinkRel.SET_HAS_NEW_POSTFACH_NACHRICHT) { +@if (postfachMailListResource | hasLink: PostfachMailListLinkRel.SET_HAS_NEW_POSTFACH_NACHRICHT) { @if (showAsIconButton) { <ods-button (clickEmitter)="markMailAsUnread()" diff --git a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.spec.ts index 0b08858c9ce2be4a4877a09d91632cd8c363c044..30c0efcf88e0ddfb174ff9f95789c0c14a277852 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.spec.ts @@ -1,5 +1,5 @@ import { PostfachMailListLinkRel, PostfachMailListResource, PostfachService } from '@alfa-client/postfach-shared'; -import { createEmptyStateResource, createStateResource, HasLinkPipe, StateResource } from '@alfa-client/tech-shared'; +import { HasLinkPipe } from '@alfa-client/tech-shared'; import { dispatchEventFromFixture, existsAsHtmlElement, @@ -21,9 +21,9 @@ describe('MailUnreadButtonLinkContainerComponent', () => { let postfachService: Mock<PostfachService>; - const postfachMailListStateResource: StateResource<PostfachMailListResource> = createStateResource( - createPostfachMailListResource([PostfachMailListLinkRel.SET_HAS_NEW_POSTFACH_NACHRICHT]), - ); + const postfachMailListResource: PostfachMailListResource = createPostfachMailListResource([ + PostfachMailListLinkRel.SET_HAS_NEW_POSTFACH_NACHRICHT, + ]); const button: string = getDataTestIdOf('mail-unread-button-link-host'); const iconButton: string = getDataTestIdOf('mail-unread-icon-button-link-host'); @@ -44,7 +44,7 @@ describe('MailUnreadButtonLinkContainerComponent', () => { fixture = TestBed.createComponent(MailUnreadButtonLinkContainerComponent); component = fixture.componentInstance; - component.postfachMailListStateResource = postfachMailListStateResource; + component.postfachMailListResource = postfachMailListResource; fixture.detectChanges(); }); @@ -76,7 +76,7 @@ describe('MailUnreadButtonLinkContainerComponent', () => { it('should not exist if link does not exist', () => { component.showAsIconButton = true; - component.postfachMailListStateResource = createEmptyStateResource(); + component.postfachMailListResource = createPostfachMailListResource(); fixture.detectChanges(); @@ -114,7 +114,7 @@ describe('MailUnreadButtonLinkContainerComponent', () => { it('should not exist if link does not exist', () => { component.showAsIconButton = false; - component.postfachMailListStateResource = createEmptyStateResource(); + component.postfachMailListResource = createPostfachMailListResource(); fixture.detectChanges(); diff --git a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.ts b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.ts index 7aea03d4bbc13514c25f350642a38fce4c62fc0c..588013e8b9ddb432654f61cea5dc3dc426b57ea8 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component.ts @@ -14,14 +14,14 @@ import { Observable, of } from 'rxjs'; export class MailUnreadButtonLinkContainerComponent { private readonly postfachService = inject(PostfachService); - @Input() postfachMailListStateResource: StateResource<PostfachMailListResource>; + @Input() postfachMailListResource: PostfachMailListResource; @Input() showAsIconButton: boolean = false; commandStateResource$: Observable<StateResource<CommandResource>> = of(createEmptyStateResource<CommandResource>()); protected readonly PostfachMailListLinkRel = PostfachMailListLinkRel; - markMailAsUnread() { + public markMailAsUnread() { this.postfachService.setPostfachNachrichtListAsUnread(); } } diff --git a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html index 190e90255d61cd7770fb5cd8c3e50fdb40cac609..1729d7519c1a41b14e730394d1fb9b55b962c413 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html @@ -24,23 +24,21 @@ --> <ozgcloud-spinner [stateResource]="postfachMailListStateResource"> - <alfa-postfach-mail - *ngFor=" - let postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST - " - [attr.data-test-id]="(postfachMail.subject | convertForDataTest) + '-item'" - class="postfach w-full lg:w-1/2" - [postfachMail]="postfachMail" - > - </alfa-postfach-mail> + @for(postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST; track $index){ + <alfa-postfach-mail + + [attr.data-test-id]="(postfachMail.subject | convertForDataTest) + '-item'" + class="postfach w-full lg:w-1/2" + [postfachMail]="postfachMail" + /> + } <div class="mb-4 ml-6 mt-4 flex gap-4"> <alfa-postfach-mail-pdf-button-container - [showButtonWithLabel]="true" [postfachMailListResource]="postfachMailListStateResource.resource" - > - </alfa-postfach-mail-pdf-button-container> + [showButtonWithLabel]="true" + /> - <alfa-mail-unread-button-link-container [postfachMailListStateResource]="postfachMailListStateResource" /> + <alfa-mail-unread-button-link-container [postfachMailListResource]="postfachMailListStateResource.resource" /> </div> </ozgcloud-spinner> diff --git a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page.component.html b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page.component.html index 303cd37a84f66bf6d73ac5eb326874cdc577c064..b44cdbd15137fdf89cd5652000899280ddb87010 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page.component.html @@ -26,7 +26,7 @@ <ozgcloud-subnavigation class="mat-typography mat-app-background"> <ozgcloud-back-button linkTo="../" label="zurück zur Detailseite" /> <alfa-mail-unread-button-link-container - [postfachMailListStateResource]="postfachMailListStateResource" + [postfachMailListResource]="postfachMailListStateResource.resource" showAsIconButton="true" /> </ozgcloud-subnavigation>