Skip to content

Commit

Permalink
Merge branch 'w2p-113996_Improvements-submission-sections-7.6' into w…
Browse files Browse the repository at this point in the history
…2p-113996_Improvements-submission-sections-main
  • Loading branch information
Atmire-Kristof committed Apr 12, 2024
2 parents 39d2a75 + 713564b commit 03d13e3
Show file tree
Hide file tree
Showing 18 changed files with 46 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 @@ -41,6 +41,12 @@ export class SubmissionSectionModel extends ConfigObject {
@autoserialize
sectionType: SectionsType;

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

Check failure on line 48 in src/app/core/config/models/config-submission-section.model.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected indentation of 4 spaces but found 2

Check failure on line 48 in src/app/core/config/models/config-submission-section.model.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Expected indentation of 4 spaces but found 2

/**
* The [SubmissionSectionVisibility] object for this section
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,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 @@ -121,6 +121,7 @@ export class InitSectionAction implements Action {
config: string;
mandatory: boolean;
sectionType: SectionsType;
extendsSectionType: SectionsType;
visibility: SectionVisibility;
enabled: boolean;
data: WorkspaceitemSectionDataType;
Expand All @@ -142,6 +143,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 @@ -157,11 +160,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
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ describe('SubmissionObjectEffects test suite', () => {
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.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export class SubmissionObjectEffects {
config,
sectionDefinition.mandatory,
sectionDefinition.sectionType,
sectionDefinition.extendsSectionType,
sectionDefinition.visibility,
enabled,
sectionData,
Expand Down
2 changes: 2 additions & 0 deletions src/app/submission/objects/submission-objects.reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ describe('submissionReducer test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
mandatory: true,
sectionType: 'submission-form',
extendsSectionType: undefined,
visibility: undefined,
collapsed: false,
enabled: true,
Expand All @@ -259,6 +260,7 @@ describe('submissionReducer test suite', () => {
true,
SectionsType.SubmissionForm,
undefined,
undefined,
true,
{},
null);
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 @@ -566,6 +566,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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('SubmissionSectionCcLicensesComponent', () => {
header: 'test header',
id: 'test section id',
sectionType: SectionsType.SubmissionForm,
extendsSectionType: undefined,
};

const submissionCcLicenses: SubmissionCcLicence[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const sectionObject: SectionDataObject = {
header: 'submit.progressbar.describe.stepone',
id: 'traditionalpageone',
sectionType: SectionsType.SubmissionForm,
extendsSectionType: undefined,
};

describe('SubmissionSectionContainerComponent test suite', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const sectionObject: SectionDataObject = {
header: 'submit.progressbar.describe.stepone',
id: 'traditionalpageone',
sectionType: SectionsType.SubmissionForm,
extendsSectionType: undefined,
};

const testFormConfiguration = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const sectionObject: SectionDataObject = {
header: 'submission.sections.submit.progressbar.identifiers',
id: 'identifiers',
sectionType: SectionsType.Identifiers,
extendsSectionType: undefined,
sectionVisibility: null,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const sectionObject: SectionDataObject = {
header: 'submit.progressbar.describe.license',
id: 'license',
sectionType: SectionsType.License,
extendsSectionType: undefined,
};

const dynamicFormControlEvent: DynamicFormControlEvent = {
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 @@ -388,7 +388,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 @@ -404,7 +406,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
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
header: 'submit.progressbar.describe.upload',
id: 'upload-id',
sectionType: SectionsType.Upload,
extendsSectionType: undefined,
};
submissionId = mockSubmissionId;
collectionId = mockSubmissionCollectionId;
Expand Down
8 changes: 8 additions & 0 deletions src/app/submission/submission.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ describe('SubmissionService test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/keyinformation',
mandatory: true,
sectionType: 'submission-form',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
Expand All @@ -615,6 +616,7 @@ describe('SubmissionService test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/indexing',
mandatory: false,
sectionType: 'submission-form',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
Expand All @@ -625,6 +627,7 @@ describe('SubmissionService test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/publicationchannel',
mandatory: true,
sectionType: 'submission-form',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
Expand All @@ -635,6 +638,7 @@ describe('SubmissionService test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/acknowledgement',
mandatory: false,
sectionType: 'submission-form',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
Expand All @@ -645,6 +649,7 @@ describe('SubmissionService test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/identifiers',
mandatory: false,
sectionType: 'submission-form',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
Expand All @@ -655,6 +660,7 @@ describe('SubmissionService test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/references',
mandatory: false,
sectionType: 'submission-form',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
Expand All @@ -665,6 +671,7 @@ describe('SubmissionService test suite', () => {
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
mandatory: true,
sectionType: 'upload',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
Expand All @@ -675,6 +682,7 @@ describe('SubmissionService test suite', () => {
config: '',
mandatory: true,
sectionType: 'license',
extendsSectionType: undefined,
data: {},
errorsToShow: [],
serverValidationErrors: [],
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 @@ -321,6 +321,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 03d13e3

Please sign in to comment.