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

OZG-6311 clear collaboration request result (workaround until loading is implemented)

parent 106ba4ec
Branches
Tags
No related merge requests found
...@@ -99,4 +99,12 @@ describe('OrganisationsEinheitService', () => { ...@@ -99,4 +99,12 @@ describe('OrganisationsEinheitService', () => {
expect(searchService.selectResult).toHaveBeenCalledWith(organisationsEinheitResource); expect(searchService.selectResult).toHaveBeenCalledWith(organisationsEinheitResource);
}); });
}); });
describe('clear selected result', () => {
it('should call service', () => {
service.clearSelectedResult();
expect(searchService.clearSelectedResult).toHaveBeenCalled();
});
});
}); });
...@@ -30,4 +30,8 @@ export class OrganisationsEinheitService { ...@@ -30,4 +30,8 @@ export class OrganisationsEinheitService {
public selectSearchResult(organisationsEinheitResource: OrganisationsEinheitResource): void { public selectSearchResult(organisationsEinheitResource: OrganisationsEinheitResource): void {
this.searchService.selectResult(organisationsEinheitResource); this.searchService.selectResult(organisationsEinheitResource);
} }
public clearSelectedResult(): void {
this.searchService.clearSelectedResult();
}
} }
...@@ -155,4 +155,12 @@ describe('CollaborationInVorgangContainerComponent', () => { ...@@ -155,4 +155,12 @@ describe('CollaborationInVorgangContainerComponent', () => {
expect(service.hideRequestForm).toHaveBeenCalled(); expect(service.hideRequestForm).toHaveBeenCalled();
}); });
}); });
describe('ngOnDestroy', () => {
it('should call service to clear selected result', () => {
component.ngOnDestroy();
expect(organisationsEinheitSearchService.clearSelectedResult).toHaveBeenCalled();
});
});
}); });
import { OrganisationsEinheitResource } from '@alfa-client/collaboration-shared'; import { OrganisationsEinheitResource } from '@alfa-client/collaboration-shared';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource } from '@alfa-client/tech-shared';
import { Component, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { CollaborationListResource } from 'libs/collaboration-shared/src/lib/collaboration.model'; import { CollaborationListResource } from 'libs/collaboration-shared/src/lib/collaboration.model';
import { CollaborationService } from 'libs/collaboration-shared/src/lib/collaboration.service'; import { CollaborationService } from 'libs/collaboration-shared/src/lib/collaboration.service';
import { OrganisationsEinheitResourceSearchService } from 'libs/collaboration-shared/src/lib/organisations-einheit-resource-search.service'; import { OrganisationsEinheitResourceSearchService } from 'libs/collaboration-shared/src/lib/organisations-einheit-resource-search.service';
...@@ -10,7 +10,7 @@ import { Observable } from 'rxjs'; ...@@ -10,7 +10,7 @@ import { Observable } from 'rxjs';
selector: 'alfa-collaboration-in-vorgang-container', selector: 'alfa-collaboration-in-vorgang-container',
templateUrl: './collaboration-in-vorgang-container.component.html', templateUrl: './collaboration-in-vorgang-container.component.html',
}) })
export class CollaborationInVorgangContainerComponent implements OnInit { export class CollaborationInVorgangContainerComponent implements OnInit, OnDestroy {
public collaborationStateListResource$: Observable<StateResource<CollaborationListResource>>; public collaborationStateListResource$: Observable<StateResource<CollaborationListResource>>;
public isRequestFormVisible$: Observable<boolean>; public isRequestFormVisible$: Observable<boolean>;
public selectedOrganisationsEinheit$: Observable<OrganisationsEinheitResource>; public selectedOrganisationsEinheit$: Observable<OrganisationsEinheitResource>;
...@@ -33,4 +33,8 @@ export class CollaborationInVorgangContainerComponent implements OnInit { ...@@ -33,4 +33,8 @@ export class CollaborationInVorgangContainerComponent implements OnInit {
public hideRequestForm(): void { public hideRequestForm(): void {
this.service.hideRequestForm(); this.service.hideRequestForm();
} }
ngOnDestroy(): void {
this.searchService.clearSelectedResult();
}
} }
...@@ -191,4 +191,16 @@ describe('ResourceSearchService', () => { ...@@ -191,4 +191,16 @@ describe('ResourceSearchService', () => {
expect(service.selectedResource.value).toEqual(dummyResource); expect(service.selectedResource.value).toEqual(dummyResource);
}); });
}); });
describe('clear select result', () => {
const dummyResource: Resource = createDummyResource();
it('should update selected resource to null', () => {
service.selectedResource.next(dummyResource);
service.clearSelectedResult();
expect(service.selectedResource.value).toBeNull();
});
});
}); });
...@@ -98,4 +98,8 @@ export class ResourceSearchService< ...@@ -98,4 +98,8 @@ export class ResourceSearchService<
public selectResult(selected: I): void { public selectResult(selected: I): void {
this.selectedResource.next(selected); this.selectedResource.next(selected);
} }
public clearSelectedResult(): void {
this.selectedResource.next(null);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment