From bd486efb6def42c656b55269fd7879c61b838eb6 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 12 Dec 2024 17:34:49 +0100 Subject: [PATCH] OZG-6989 loading on dialog button --- ...chive-confirmation-dialog-container.component.html | 5 ++--- ...ve-confirmation-dialog-container.component.spec.ts | 6 +++--- ...archive-confirmation-dialog-container.component.ts | 11 +++++------ .../vorgang-archive-confirmation-dialog.component.ts | 7 ++++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.html b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.html index df26f4a900..2e707527f2 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.html +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.html @@ -1,6 +1,5 @@ <alfa-vorgang-archive-confirmation-dialog + [archiveStateResource]="archiveStateResource$ | async" (confirmationButtonClicked)="onConfirmationButtonClicked()" (cancelButtonClicked)="onCancelButtonClicked()" -/> - -<ng-container *ngIf="archiveSubscription$ | async"/> +/> \ No newline at end of file diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.spec.ts index d1b55b2e99..4b6462080e 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.spec.ts @@ -5,10 +5,10 @@ import { createStateResource, StateResource } from '@alfa-client/tech-shared'; import { mock } from '@alfa-client/test-utils'; import { VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { DialogRef } from '@angular/cdk/dialog'; +import { createCommandResource } from 'libs/command-shared/test/command'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; -import { createCommandResource } from '../../../../../../../command-shared/test/command'; import { VorgangArchiveConfirmationDialogContainerComponent } from './vorgang-archive-confirmation-dialog-container.component'; import { VorgangArchiveConfirmationDialogComponent } from './vorgang-archive-confirmation-dialog/vorgang-archive-confirmation-dialog.component'; @@ -86,7 +86,7 @@ describe('VorgangArchiveConfirmationDialogContainerComponent', () => { (isSuccessfulDone as jest.Mock).mockReturnValue(true); component.onConfirmationButtonClicked(); - component.archiveSubscription$.subscribe(); + component.archiveStateResource$.subscribe(); expect(component.archiveDoneHandler).toHaveBeenCalled(); }); @@ -95,7 +95,7 @@ describe('VorgangArchiveConfirmationDialogContainerComponent', () => { (isSuccessfulDone as jest.Mock).mockReturnValue(false); component.onConfirmationButtonClicked(); - component.archiveSubscription$.subscribe(); + component.archiveStateResource$.subscribe(); expect(component.archiveDoneHandler).not.toHaveBeenCalled(); }); diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.ts index 01a663163e..575322d084 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog-container.component.ts @@ -1,5 +1,5 @@ import { CommandResource, isSuccessfulDone } from '@alfa-client/command-shared'; -import { mapToResource } from '@alfa-client/tech-shared'; +import { StateResource } from '@alfa-client/tech-shared'; import { VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { DialogRef } from '@angular/cdk/dialog'; import { Component, inject } from '@angular/core'; @@ -15,7 +15,7 @@ export class VorgangArchiveConfirmationDialogContainerComponent { private dialogRef = inject(DialogRef<unknown, VorgangArchiveConfirmationDialogData>); private vorgangWithEingang: VorgangWithEingangResource = this.dialogRef.config.data.vorgangWithEingang; - public archiveSubscription$: Observable<CommandResource>; + public archiveStateResource$: Observable<StateResource<CommandResource>>; archiveDoneHandler(): void { this.dialogRef.close(); @@ -26,10 +26,9 @@ export class VorgangArchiveConfirmationDialogContainerComponent { } public onConfirmationButtonClicked(): void { - this.archiveSubscription$ = this.vorgangService.archive(this.vorgangWithEingang).pipe( - mapToResource(), - tap((command: CommandResource) => { - if (isSuccessfulDone(command)) this.archiveDoneHandler(); + this.archiveStateResource$ = this.vorgangService.archive(this.vorgangWithEingang).pipe( + tap((command: StateResource<CommandResource>) => { + if (isSuccessfulDone(command.resource)) this.archiveDoneHandler(); }), ); } diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog/vorgang-archive-confirmation-dialog.component.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog/vorgang-archive-confirmation-dialog.component.ts index d955da4738..2da7fc7fc5 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog/vorgang-archive-confirmation-dialog.component.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-more-menu/vorgang-archive-container/vorgang-archive-confirmation-dialog-container/vorgang-archive-confirmation-dialog/vorgang-archive-confirmation-dialog.component.ts @@ -1,3 +1,4 @@ +import { CommandResource } from '@alfa-client/command-shared'; import { StateResource } from '@alfa-client/tech-shared'; import { Component, EventEmitter, Input, Output } from '@angular/core'; @@ -6,8 +7,8 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; templateUrl: './vorgang-archive-confirmation-dialog.component.html', }) export class VorgangArchiveConfirmationDialogComponent { - @Input() archiveStateResource: StateResource<boolean>; + @Input() archiveStateResource: StateResource<CommandResource>; - @Output() cancelButtonClicked = new EventEmitter(); - @Output() confirmationButtonClicked = new EventEmitter(); + @Output() cancelButtonClicked: EventEmitter<void> = new EventEmitter(); + @Output() confirmationButtonClicked: EventEmitter<void> = new EventEmitter(); } -- GitLab