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

OZG-1065 close dialog on navigation to vorgang list

parent 58ef4a62
No related branches found
No related tags found
No related merge requests found
import { MatDialog } from '@angular/material/dialog';
import { CommandResource, CommandService } from '@goofy-client/command-shared';
import { createStateResource, NavigationService, StateResource } from '@goofy-client/tech-shared';
import { Mock, mock, useFromMock } from '@goofy-client/test-utils';
......@@ -16,6 +17,7 @@ describe('PostfachService', () => {
let commandService: Mock<CommandService>;
let navigationService: Mock<NavigationService>;
let vorgangService: Mock<VorgangService>;
let dialog: Mock<MatDialog>;
const postfachMail: PostfachMail = createPostfachMail();
......@@ -24,11 +26,12 @@ describe('PostfachService', () => {
commandService = mock(CommandService);
navigationService = mock(NavigationService);
vorgangService = mock(VorgangService);
dialog = <any>{ closeAll: jest.fn() };
navigationService.urlChanged = jest.fn();
navigationService.urlChanged.mockReturnValue(of({}));
service = new PostfachService(useFromMock(repository), useFromMock(commandService), useFromMock(navigationService), useFromMock(vorgangService));
service = new PostfachService(useFromMock(repository), useFromMock(commandService), useFromMock(navigationService), useFromMock(vorgangService), useFromMock(dialog));
});
it('should be created', () => {
......@@ -77,16 +80,22 @@ describe('PostfachService', () => {
expect(service.setPollingFalse).toHaveBeenCalled();
})
it('should call unsubscribe', () => {
it('should call clearPostfachMailList', () => {
service.onNavigation({});
expect(service.unsubscribe).toHaveBeenCalled();
expect(service.clearPostfachMailList).toHaveBeenCalled();
})
it('should call clearPostfachMailList', () => {
it('should call closeOpenDialogs', () => {
service.onNavigation({});
expect(service.clearPostfachMailList).toHaveBeenCalled();
expect(dialog.closeAll).toHaveBeenCalled();
})
it('should call unsubscribe', () => {
service.onNavigation({});
expect(service.unsubscribe).toHaveBeenCalled();
})
})
})
......
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Params } from '@angular/router';
import { CommandResource, CommandService, isDone, isPending } from '@goofy-client/command-shared';
import { createEmptyStateResource, createStateResource, doIfLoadingRequired, hasError, NavigationService, StateResource } from '@goofy-client/tech-shared';
......@@ -25,7 +26,8 @@ export class PostfachService {
private repository: PostfachRepository,
private commandService: CommandService,
private navigationService: NavigationService,
private vorgangService: VorgangService
private vorgangService: VorgangService,
private dialog: MatDialog
) { }
public sendMail(postfachMail: PostfachMail): Observable<StateResource<CommandResource>> {
......@@ -53,6 +55,7 @@ export class PostfachService {
if (NavigationService.isVorgangListPage(params)) {
this.setPollingFalse();
this.clearPostfachMailList();
this.closeOpenDialogs();
this.unsubscribe();
}
}
......@@ -65,6 +68,10 @@ export class PostfachService {
this.postfachMailList$.next(createEmptyStateResource());
}
closeOpenDialogs(): void {
this.dialog.closeAll();
}
pollSendPostfachMailCommand(command: StateResource<CommandResource>): StateResource<CommandResource> {
if (this.shouldPoll(command)) {
this.setPollingTrue();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment