Skip to content
Snippets Groups Projects
Commit bd486efb authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6989 loading on dialog button

parent 76367981
No related branches found
No related tags found
No related merge requests found
<alfa-vorgang-archive-confirmation-dialog <alfa-vorgang-archive-confirmation-dialog
[archiveStateResource]="archiveStateResource$ | async"
(confirmationButtonClicked)="onConfirmationButtonClicked()" (confirmationButtonClicked)="onConfirmationButtonClicked()"
(cancelButtonClicked)="onCancelButtonClicked()" (cancelButtonClicked)="onCancelButtonClicked()"
/> />
\ No newline at end of file
<ng-container *ngIf="archiveSubscription$ | async"/>
...@@ -5,10 +5,10 @@ import { createStateResource, StateResource } from '@alfa-client/tech-shared'; ...@@ -5,10 +5,10 @@ import { createStateResource, StateResource } from '@alfa-client/tech-shared';
import { mock } from '@alfa-client/test-utils'; import { mock } from '@alfa-client/test-utils';
import { VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { DialogRef } from '@angular/cdk/dialog'; import { DialogRef } from '@angular/cdk/dialog';
import { createCommandResource } from 'libs/command-shared/test/command';
import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { createCommandResource } from '../../../../../../../command-shared/test/command';
import { VorgangArchiveConfirmationDialogContainerComponent } from './vorgang-archive-confirmation-dialog-container.component'; import { VorgangArchiveConfirmationDialogContainerComponent } from './vorgang-archive-confirmation-dialog-container.component';
import { VorgangArchiveConfirmationDialogComponent } from './vorgang-archive-confirmation-dialog/vorgang-archive-confirmation-dialog.component'; import { VorgangArchiveConfirmationDialogComponent } from './vorgang-archive-confirmation-dialog/vorgang-archive-confirmation-dialog.component';
...@@ -86,7 +86,7 @@ describe('VorgangArchiveConfirmationDialogContainerComponent', () => { ...@@ -86,7 +86,7 @@ describe('VorgangArchiveConfirmationDialogContainerComponent', () => {
(isSuccessfulDone as jest.Mock).mockReturnValue(true); (isSuccessfulDone as jest.Mock).mockReturnValue(true);
component.onConfirmationButtonClicked(); component.onConfirmationButtonClicked();
component.archiveSubscription$.subscribe(); component.archiveStateResource$.subscribe();
expect(component.archiveDoneHandler).toHaveBeenCalled(); expect(component.archiveDoneHandler).toHaveBeenCalled();
}); });
...@@ -95,7 +95,7 @@ describe('VorgangArchiveConfirmationDialogContainerComponent', () => { ...@@ -95,7 +95,7 @@ describe('VorgangArchiveConfirmationDialogContainerComponent', () => {
(isSuccessfulDone as jest.Mock).mockReturnValue(false); (isSuccessfulDone as jest.Mock).mockReturnValue(false);
component.onConfirmationButtonClicked(); component.onConfirmationButtonClicked();
component.archiveSubscription$.subscribe(); component.archiveStateResource$.subscribe();
expect(component.archiveDoneHandler).not.toHaveBeenCalled(); expect(component.archiveDoneHandler).not.toHaveBeenCalled();
}); });
......
import { CommandResource, isSuccessfulDone } from '@alfa-client/command-shared'; 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 { VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { DialogRef } from '@angular/cdk/dialog'; import { DialogRef } from '@angular/cdk/dialog';
import { Component, inject } from '@angular/core'; import { Component, inject } from '@angular/core';
...@@ -15,7 +15,7 @@ export class VorgangArchiveConfirmationDialogContainerComponent { ...@@ -15,7 +15,7 @@ export class VorgangArchiveConfirmationDialogContainerComponent {
private dialogRef = inject(DialogRef<unknown, VorgangArchiveConfirmationDialogData>); private dialogRef = inject(DialogRef<unknown, VorgangArchiveConfirmationDialogData>);
private vorgangWithEingang: VorgangWithEingangResource = this.dialogRef.config.data.vorgangWithEingang; private vorgangWithEingang: VorgangWithEingangResource = this.dialogRef.config.data.vorgangWithEingang;
public archiveSubscription$: Observable<CommandResource>; public archiveStateResource$: Observable<StateResource<CommandResource>>;
archiveDoneHandler(): void { archiveDoneHandler(): void {
this.dialogRef.close(); this.dialogRef.close();
...@@ -26,10 +26,9 @@ export class VorgangArchiveConfirmationDialogContainerComponent { ...@@ -26,10 +26,9 @@ export class VorgangArchiveConfirmationDialogContainerComponent {
} }
public onConfirmationButtonClicked(): void { public onConfirmationButtonClicked(): void {
this.archiveSubscription$ = this.vorgangService.archive(this.vorgangWithEingang).pipe( this.archiveStateResource$ = this.vorgangService.archive(this.vorgangWithEingang).pipe(
mapToResource(), tap((command: StateResource<CommandResource>) => {
tap((command: CommandResource) => { if (isSuccessfulDone(command.resource)) this.archiveDoneHandler();
if (isSuccessfulDone(command)) this.archiveDoneHandler();
}), }),
); );
} }
......
import { CommandResource } from '@alfa-client/command-shared';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource } from '@alfa-client/tech-shared';
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
...@@ -6,8 +7,8 @@ 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', templateUrl: './vorgang-archive-confirmation-dialog.component.html',
}) })
export class VorgangArchiveConfirmationDialogComponent { export class VorgangArchiveConfirmationDialogComponent {
@Input() archiveStateResource: StateResource<boolean>; @Input() archiveStateResource: StateResource<CommandResource>;
@Output() cancelButtonClicked = new EventEmitter(); @Output() cancelButtonClicked: EventEmitter<void> = new EventEmitter();
@Output() confirmationButtonClicked = new EventEmitter(); @Output() confirmationButtonClicked: EventEmitter<void> = new EventEmitter();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment