From a8d9d01b9d497af1198d04581bbe7b4a498aff52 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Fri, 29 Nov 2024 13:07:20 +0100 Subject: [PATCH] OZG-6477 7189 refresh after successfull --- .../src/lib/collaboration.service.spec.ts | 8 ++++++++ .../src/lib/collaboration.service.ts | 4 ++++ .../collaboration.request.formservice.spec.ts | 12 ++++++++++-- .../collaboration.request.formservice.ts | 6 ++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts index 3ad660af24..80d2dfbf96 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts @@ -46,6 +46,14 @@ describe('CollaborationService', () => { }); }); + describe('refresh list', () => { + it('should call service', () => { + service.refreshList(); + + expect(listService.refresh).toHaveBeenCalled(); + }); + }); + describe('organisationsEinheit', () => { describe('is form visible', () => { it('should return value', (done) => { diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts index 5e3a4bddae..d2e60c0515 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts @@ -28,6 +28,10 @@ export class CollaborationService { return this.listService.getList(); } + public refreshList(): void { + this.listService.refresh(); + } + public isOrganisationsEinheitFormVisible(): Observable<boolean> { return this.showOrganisationsEinheitForm$.asObservable(); } diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts index 989607ccc5..4820b2987e 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts @@ -1,5 +1,5 @@ import { CollaborationListResource } from '@alfa-client/collaboration-shared'; -import { CommandResource } from '@alfa-client/command-shared'; +import { CommandLinkRel, CommandResource } from '@alfa-client/command-shared'; import { StateResource, createStateResource } from '@alfa-client/tech-shared'; import { Mock, mock, useFromMock } from '@alfa-client/test-utils'; import { UntypedFormBuilder } from '@angular/forms'; @@ -44,7 +44,9 @@ describe('CollaborationRequestFormService', () => { }); describe('do submit', () => { - const stateCommandResource: StateResource<CommandResource> = createStateResource(createCommandResource()); + const stateCommandResource: StateResource<CommandResource> = createStateResource( + createCommandResource([CommandLinkRel.EFFECTED_RESOURCE]), + ); beforeEach(() => { formService.listResource = collaborationListResource; @@ -57,6 +59,12 @@ describe('CollaborationRequestFormService', () => { expect(service.create).toHaveBeenCalledWith(collaborationListResource, formService.form.value); }); + it('should call service refresh', () => { + formService.submit().subscribe(); + + expect(service.refreshList).toHaveBeenCalled(); + }); + it('should return stateCommandResource', () => { const response$: Observable<StateResource<CommandResource>> = formService.submit(); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts index 3e9334240e..0b3f33a899 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts @@ -1,5 +1,5 @@ import { CollaborationListResource } from '@alfa-client/collaboration-shared'; -import { CommandResource } from '@alfa-client/command-shared'; +import { CommandResource, tapOnCommandSuccessfullyDone } from '@alfa-client/command-shared'; import { AbstractFormService, StateResource } from '@alfa-client/tech-shared'; import { Injectable } from '@angular/core'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; @@ -33,7 +33,9 @@ export class CollaborationRequestFormService extends AbstractFormService<Command } protected doSubmit(): Observable<StateResource<CommandResource>> { - return this.service.create(this.listResource, this.getFormValue()); + return this.service + .create(this.listResource, this.getFormValue()) + .pipe(tapOnCommandSuccessfullyDone(() => this.service.refreshList())); } protected getPathPrefix(): string { -- GitLab