mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 14:33:03 +00:00
fix section data load for coar section in submission
This commit is contained in:
@@ -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([
|
||||
|
@@ -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);
|
||||
});
|
||||
})
|
||||
);
|
||||
|
Reference in New Issue
Block a user