From c09ae9329937a6218a8ba50a0e7897651e1e34b5 Mon Sep 17 00:00:00 2001 From: "Zickermann, Jan" <jan.zickermann@dataport.de> Date: Tue, 2 Apr 2024 17:37:59 +0200 Subject: [PATCH] OZG-4995 Fix bad OE form update --- .../organisationseinheit.formservice.spec.ts | 16 ++++++++++++++++ .../organisationseinheit.formservice.ts | 2 ++ 2 files changed, 18 insertions(+) diff --git a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts index 6b4b53f7a4..1319b8d935 100644 --- a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts +++ b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts @@ -263,6 +263,14 @@ describe('OrganisationseinheitFormService', () => { describe('patch', () => { const organisationseinheit: Organisationseinheit = createOrganisationseinheit(); + it('should reset', () => { + formService.reset = jest.fn(); + + formService.patch(organisationseinheit); + + expect(formService.reset).toHaveBeenCalled(); + }); + it('should set source', () => { formService.patch(organisationseinheit); @@ -305,6 +313,14 @@ describe('OrganisationseinheitFormService', () => { }); describe('reset', () => { + it('should set source to null', () => { + formService.form.reset = jest.fn(); + + formService.reset(); + + expect(formService.source).toBeNull(); + }); + it('should call form reset', () => { formService.form.reset = jest.fn(); diff --git a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts index 5d57598564..ecad82623c 100644 --- a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts +++ b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts @@ -119,6 +119,7 @@ export class OrganisationseinheitFormservice { } public patch(organisationseinheit: Organisationseinheit): void { + this.reset(); this.source = organisationseinheit; this.form.patchValue({ [OrganisationseinheitFormservice.ORGANISATIONSEINHEIT_NAME_FIELD]: organisationseinheit.name, @@ -128,6 +129,7 @@ export class OrganisationseinheitFormservice { } public reset(): void { + this.source = null; this.form.reset(); this.form.markAsUntouched(); } -- GitLab