Skip to content

Commit 072ea80

Browse files
113996: Support for extending submission steps
1 parent 404ccd9 commit 072ea80

9 files changed

+29
-7
lines changed

src/app/core/config/models/config-submission-section.model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export class SubmissionSectionModel extends ConfigObject {
3636
@autoserialize
3737
sectionType: SectionsType;
3838

39+
/**
40+
* A string representing the type this section extends
41+
*/
42+
@autoserialize
43+
extendsSectionType: SectionsType;
44+
3945
/**
4046
* The [SubmissionSectionVisibility] object for this section
4147
*/

src/app/core/submission/submission-response-parsing.service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
137137
// Iterate over all workspaceitem's sections
138138
Object.keys(item.sections)
139139
.forEach((sectionId) => {
140-
if (typeof item.sections[sectionId] === 'object' && (isNotEmpty(item.sections[sectionId]) &&
141-
// When Upload section is disabled, add to submission only if there are files
142-
(!item.sections[sectionId].hasOwnProperty('files') || isNotEmpty((item.sections[sectionId] as any).files)))) {
143-
140+
if (typeof item.sections[sectionId] === 'object' && (isNotEmpty(item.sections[sectionId]))) {
144141
const sectiondata = Object.create({});
145142
// Iterate over all sections property
146143
Object.keys(item.sections[sectionId])

src/app/submission/objects/submission-objects.actions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export class InitSectionAction implements Action {
117117
config: string;
118118
mandatory: boolean;
119119
sectionType: SectionsType;
120+
extendsSectionType: SectionsType;
120121
visibility: SectionVisibility;
121122
enabled: boolean;
122123
data: WorkspaceitemSectionDataType;
@@ -138,6 +139,8 @@ export class InitSectionAction implements Action {
138139
* the section's mandatory
139140
* @param sectionType
140141
* the section's type
142+
* @param extendsSectionType
143+
* the type of the section it extends
141144
* @param visibility
142145
* the section's visibility
143146
* @param enabled
@@ -153,11 +156,12 @@ export class InitSectionAction implements Action {
153156
config: string,
154157
mandatory: boolean,
155158
sectionType: SectionsType,
159+
extendsSectionType: SectionsType,
156160
visibility: SectionVisibility,
157161
enabled: boolean,
158162
data: WorkspaceitemSectionDataType,
159163
errors: SubmissionSectionError[]) {
160-
this.payload = { submissionId, sectionId, header, config, mandatory, sectionType, visibility, enabled, data, errors };
164+
this.payload = { submissionId, sectionId, header, config, mandatory, sectionType, extendsSectionType, visibility, enabled, data, errors };
161165
}
162166
}
163167

src/app/submission/objects/submission-objects.effects.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class SubmissionObjectEffects {
8787
config,
8888
sectionDefinition.mandatory,
8989
sectionDefinition.sectionType,
90+
sectionDefinition.extendsSectionType,
9091
sectionDefinition.visibility,
9192
enabled,
9293
sectionData,

src/app/submission/objects/submission-objects.reducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ function initSection(state: SubmissionObjectState, action: InitSectionAction): S
549549
config: action.payload.config,
550550
mandatory: action.payload.mandatory,
551551
sectionType: action.payload.sectionType,
552+
extendsSectionType: action.payload.extendsSectionType,
552553
visibility: action.payload.visibility,
553554
collapsed: false,
554555
enabled: action.payload.enabled,

src/app/submission/objects/submission-section-object.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export interface SubmissionSectionObject {
2727
*/
2828
sectionType: SectionsType;
2929

30+
/**
31+
* The type this section extends
32+
*/
33+
extendsSectionType: SectionsType;
34+
3035
/**
3136
* The section visibility
3237
*/

src/app/submission/sections/models/section-data.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export interface SectionDataObject {
4747
*/
4848
sectionType: SectionsType;
4949

50+
/**
51+
* The type this section extends
52+
*/
53+
extendsSectionType: SectionsType;
54+
5055
/**
5156
* Eventually additional fields
5257
*/

src/app/submission/sections/sections.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,9 @@ export class SectionsService {
374374
return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe(
375375
filter((submissionState: SubmissionObjectEntry) => isNotUndefined(submissionState)),
376376
map((submissionState: SubmissionObjectEntry) => {
377-
return isNotUndefined(submissionState.sections) && isNotUndefined(findKey(submissionState.sections, { sectionType: sectionType }));
377+
return isNotUndefined(submissionState.sections) &&
378+
(isNotUndefined(findKey(submissionState.sections, { sectionType: sectionType })) ||
379+
isNotUndefined(findKey(submissionState.sections, { extendsSectionType: sectionType })));
378380
}),
379381
distinctUntilChanged());
380382
}
@@ -390,7 +392,7 @@ export class SectionsService {
390392
filter((submissionState: SubmissionObjectEntry) => isNotUndefined(submissionState)),
391393
map((submissionState: SubmissionObjectEntry) => {
392394
return isNotUndefined(submissionState.sections) && isNotUndefined(submissionState.sections[sectionId])
393-
&& submissionState.sections[sectionId].sectionType === sectionType;
395+
&& (submissionState.sections[sectionId].sectionType === sectionType || submissionState.sections[sectionId].extendsSectionType === sectionType);
394396
}),
395397
distinctUntilChanged());
396398
}

src/app/submission/submission.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ export class SubmissionService {
297297
sectionObject.header = sections[sectionId].header;
298298
sectionObject.id = sectionId;
299299
sectionObject.sectionType = sections[sectionId].sectionType;
300+
sectionObject.extendsSectionType = sections[sectionId].extendsSectionType;
300301
availableSections.push(sectionObject);
301302
});
302303
return availableSections;

0 commit comments

Comments
 (0)