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 pattern2 = {pattern: 'endorsement', multipleRequest: false};
|
||||||
const service1: LdnService = Object.assign(new LdnService(), {
|
const service1: LdnService = Object.assign(new LdnService(), {
|
||||||
id: 1,
|
id: 1,
|
||||||
|
uuid: 1,
|
||||||
name: 'service1',
|
name: 'service1',
|
||||||
notifyServiceInboundPatterns: [
|
notifyServiceInboundPatterns: [
|
||||||
Object.assign(new NotifyServicePattern(), {
|
Object.assign(new NotifyServicePattern(), {
|
||||||
@@ -220,6 +221,7 @@ describe('SubmissionSectionCoarNotifyComponent', () => {
|
|||||||
});
|
});
|
||||||
const service2: LdnService = Object.assign(new LdnService(), {
|
const service2: LdnService = Object.assign(new LdnService(), {
|
||||||
id: 2,
|
id: 2,
|
||||||
|
uuid: 2,
|
||||||
name: 'service2',
|
name: 'service2',
|
||||||
notifyServiceInboundPatterns: [
|
notifyServiceInboundPatterns: [
|
||||||
Object.assign(new NotifyServicePattern(), {
|
Object.assign(new NotifyServicePattern(), {
|
||||||
@@ -229,6 +231,7 @@ describe('SubmissionSectionCoarNotifyComponent', () => {
|
|||||||
});
|
});
|
||||||
const service3: LdnService = Object.assign(new LdnService(), {
|
const service3: LdnService = Object.assign(new LdnService(), {
|
||||||
id: 3,
|
id: 3,
|
||||||
|
uuid: 3,
|
||||||
name: 'service3',
|
name: 'service3',
|
||||||
notifyServiceInboundPatterns: [
|
notifyServiceInboundPatterns: [
|
||||||
Object.assign(new NotifyServicePattern(), {
|
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', () => {
|
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[pattern1.pattern] = [service1.uuid, service3.uuid];
|
||||||
component.sectionData.data[pattern2.pattern] = [service2, service3];
|
component.sectionData.data[pattern2.pattern] = [service2.uuid, service3.uuid];
|
||||||
component.initSelectedServicesByPattern();
|
component.initSelectedServicesByPattern();
|
||||||
|
|
||||||
expect(component.ldnServiceByPattern[pattern1.pattern].services).toEqual([
|
expect(component.ldnServiceByPattern[pattern1.pattern].services).toEqual([
|
||||||
|
@@ -163,10 +163,18 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
|
|||||||
this.subs.push(
|
this.subs.push(
|
||||||
this.filterServices(ldnPattern.pattern)
|
this.filterServices(ldnPattern.pattern)
|
||||||
.subscribe((services: LdnService[]) => {
|
.subscribe((services: LdnService[]) => {
|
||||||
|
|
||||||
|
if (!this.ldnServiceByPattern[ldnPattern.pattern]) {
|
||||||
|
this.ldnServiceByPattern[ldnPattern.pattern] = {
|
||||||
|
services: [],
|
||||||
|
allowsMultipleRequests: ldnPattern.multipleRequest
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
this.ldnServiceByPattern[ldnPattern.pattern].services = services.filter((service) => {
|
this.ldnServiceByPattern[ldnPattern.pattern].services = services.filter((service) => {
|
||||||
const selection = (this.sectionData.data[ldnPattern.pattern] as LdnService[]).find((s: LdnService) => s.id === service.id);
|
const selection = (this.sectionData.data[ldnPattern.pattern] as LdnService[]).find((s: LdnService) => s.id === service.id);
|
||||||
this.addService(ldnPattern, selection);
|
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