From 6be10a81f45171d896e6142e8f839d6406d7b7b5 Mon Sep 17 00:00:00 2001 From: FrancescoMolinaro Date: Tue, 27 Feb 2024 18:19:34 +0100 Subject: [PATCH] fix section data load for coar section in submission --- .../section-coar-notify.component.spec.ts | 7 +++++-- .../section-coar-notify.component.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/submission/sections/section-coar-notify/section-coar-notify.component.spec.ts b/src/app/submission/sections/section-coar-notify/section-coar-notify.component.spec.ts index e581abed45..74e82722a6 100644 --- a/src/app/submission/sections/section-coar-notify/section-coar-notify.component.spec.ts +++ b/src/app/submission/sections/section-coar-notify/section-coar-notify.component.spec.ts @@ -211,6 +211,7 @@ describe('SubmissionSectionCoarNotifyComponent', () => { const pattern2 = {pattern: 'endorsement', multipleRequest: false}; const service1: LdnService = Object.assign(new LdnService(), { id: 1, + uuid: 1, name: 'service1', notifyServiceInboundPatterns: [ Object.assign(new NotifyServicePattern(), { @@ -220,6 +221,7 @@ describe('SubmissionSectionCoarNotifyComponent', () => { }); const service2: LdnService = Object.assign(new LdnService(), { id: 2, + uuid: 2, name: 'service2', notifyServiceInboundPatterns: [ Object.assign(new NotifyServicePattern(), { @@ -229,6 +231,7 @@ describe('SubmissionSectionCoarNotifyComponent', () => { }); const service3: LdnService = Object.assign(new LdnService(), { id: 3, + uuid: 3, name: 'service3', notifyServiceInboundPatterns: [ Object.assign(new NotifyServicePattern(), { @@ -271,8 +274,8 @@ describe('SubmissionSectionCoarNotifyComponent', () => { }); it('should add the service to the selected services by pattern if the section data has a value for the pattern', () => { - component.sectionData.data[pattern1.pattern] = [service1, service3]; - component.sectionData.data[pattern2.pattern] = [service2, service3]; + component.sectionData.data[pattern1.pattern] = [service1.uuid, service3.uuid]; + component.sectionData.data[pattern2.pattern] = [service2.uuid, service3.uuid]; component.initSelectedServicesByPattern(); expect(component.ldnServiceByPattern[pattern1.pattern].services).toEqual([ diff --git a/src/app/submission/sections/section-coar-notify/section-coar-notify.component.ts b/src/app/submission/sections/section-coar-notify/section-coar-notify.component.ts index d0e2724e85..df5288cad1 100644 --- a/src/app/submission/sections/section-coar-notify/section-coar-notify.component.ts +++ b/src/app/submission/sections/section-coar-notify/section-coar-notify.component.ts @@ -163,10 +163,18 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent this.subs.push( this.filterServices(ldnPattern.pattern) .subscribe((services: LdnService[]) => { + + if (!this.ldnServiceByPattern[ldnPattern.pattern]) { + this.ldnServiceByPattern[ldnPattern.pattern] = { + services: [], + allowsMultipleRequests: ldnPattern.multipleRequest + }; + } + this.ldnServiceByPattern[ldnPattern.pattern].services = services.filter((service) => { const selection = (this.sectionData.data[ldnPattern.pattern] as LdnService[]).find((s: LdnService) => s.id === service.id); this.addService(ldnPattern, selection); - return this.sectionData.data[ldnPattern.pattern].includes(service); + return this.sectionData.data[ldnPattern.pattern].includes(service.uuid); }); }) );