Skip to content

Commit

Permalink
113996: Support for extending submission steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Atmire-Kristof committed Apr 11, 2024
1 parent 404ccd9 commit 072ea80
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/app/core/config/models/config-submission-section.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export class SubmissionSectionModel extends ConfigObject {
@autoserialize
sectionType: SectionsType;

/**
* A string representing the type this section extends
*/
@autoserialize
extendsSectionType: SectionsType;

/**
* The [SubmissionSectionVisibility] object for this section
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
// Iterate over all workspaceitem's sections
Object.keys(item.sections)
.forEach((sectionId) => {
if (typeof item.sections[sectionId] === 'object' && (isNotEmpty(item.sections[sectionId]) &&
// When Upload section is disabled, add to submission only if there are files
(!item.sections[sectionId].hasOwnProperty('files') || isNotEmpty((item.sections[sectionId] as any).files)))) {

if (typeof item.sections[sectionId] === 'object' && (isNotEmpty(item.sections[sectionId]))) {
const sectiondata = Object.create({});
// Iterate over all sections property
Object.keys(item.sections[sectionId])
Expand Down
6 changes: 5 additions & 1 deletion src/app/submission/objects/submission-objects.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class InitSectionAction implements Action {
config: string;
mandatory: boolean;
sectionType: SectionsType;
extendsSectionType: SectionsType;
visibility: SectionVisibility;
enabled: boolean;
data: WorkspaceitemSectionDataType;
Expand All @@ -138,6 +139,8 @@ export class InitSectionAction implements Action {
* the section's mandatory
* @param sectionType
* the section's type
* @param extendsSectionType
* the type of the section it extends
* @param visibility
* the section's visibility
* @param enabled
Expand All @@ -153,11 +156,12 @@ export class InitSectionAction implements Action {
config: string,
mandatory: boolean,
sectionType: SectionsType,
extendsSectionType: SectionsType,
visibility: SectionVisibility,
enabled: boolean,
data: WorkspaceitemSectionDataType,
errors: SubmissionSectionError[]) {
this.payload = { submissionId, sectionId, header, config, mandatory, sectionType, visibility, enabled, data, errors };
this.payload = { submissionId, sectionId, header, config, mandatory, sectionType, extendsSectionType, visibility, enabled, data, errors };
}
}

Expand Down
1 change: 1 addition & 0 deletions src/app/submission/objects/submission-objects.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class SubmissionObjectEffects {
config,
sectionDefinition.mandatory,
sectionDefinition.sectionType,
sectionDefinition.extendsSectionType,
sectionDefinition.visibility,
enabled,
sectionData,
Expand Down
1 change: 1 addition & 0 deletions src/app/submission/objects/submission-objects.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ function initSection(state: SubmissionObjectState, action: InitSectionAction): S
config: action.payload.config,
mandatory: action.payload.mandatory,
sectionType: action.payload.sectionType,
extendsSectionType: action.payload.extendsSectionType,
visibility: action.payload.visibility,
collapsed: false,
enabled: action.payload.enabled,
Expand Down
5 changes: 5 additions & 0 deletions src/app/submission/objects/submission-section-object.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export interface SubmissionSectionObject {
*/
sectionType: SectionsType;

/**
* The type this section extends
*/
extendsSectionType: SectionsType;

/**
* The section visibility
*/
Expand Down
5 changes: 5 additions & 0 deletions src/app/submission/sections/models/section-data.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export interface SectionDataObject {
*/
sectionType: SectionsType;

/**
* The type this section extends
*/
extendsSectionType: SectionsType;

/**
* Eventually additional fields
*/
Expand Down
6 changes: 4 additions & 2 deletions src/app/submission/sections/sections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ export class SectionsService {
return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe(
filter((submissionState: SubmissionObjectEntry) => isNotUndefined(submissionState)),
map((submissionState: SubmissionObjectEntry) => {
return isNotUndefined(submissionState.sections) && isNotUndefined(findKey(submissionState.sections, { sectionType: sectionType }));
return isNotUndefined(submissionState.sections) &&
(isNotUndefined(findKey(submissionState.sections, { sectionType: sectionType })) ||
isNotUndefined(findKey(submissionState.sections, { extendsSectionType: sectionType })));
}),
distinctUntilChanged());
}
Expand All @@ -390,7 +392,7 @@ export class SectionsService {
filter((submissionState: SubmissionObjectEntry) => isNotUndefined(submissionState)),
map((submissionState: SubmissionObjectEntry) => {
return isNotUndefined(submissionState.sections) && isNotUndefined(submissionState.sections[sectionId])
&& submissionState.sections[sectionId].sectionType === sectionType;
&& (submissionState.sections[sectionId].sectionType === sectionType || submissionState.sections[sectionId].extendsSectionType === sectionType);
}),
distinctUntilChanged());
}
Expand Down
1 change: 1 addition & 0 deletions src/app/submission/submission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export class SubmissionService {
sectionObject.header = sections[sectionId].header;
sectionObject.id = sectionId;
sectionObject.sectionType = sections[sectionId].sectionType;
sectionObject.extendsSectionType = sections[sectionId].extendsSectionType;
availableSections.push(sectionObject);
});
return availableSections;
Expand Down

0 comments on commit 072ea80

Please sign in to comment.