diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form.component.html index 8b84b592d7..5684f4eac9 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form.component.html @@ -2,7 +2,7 @@ [formId]="formId" [group]="formGroup" [hasErrorMessaging]="model.hasErrorMessages" - [hidden]="model.hidden"linke + [hidden]="model.hidden" [layout]="formLayout" [model]="model" [ngClass]="[getClass(model, 'element', 'host'), getClass(model, 'grid', 'host')]" diff --git a/src/app/shared/form/form.reducer.ts b/src/app/shared/form/form.reducer.ts index b5b4090ef9..59b942ebc3 100644 --- a/src/app/shared/form/form.reducer.ts +++ b/src/app/shared/form/form.reducer.ts @@ -235,7 +235,7 @@ function changeTouchedState(state: FormState, action: FormAddTouchedAction): For newState[action.payload.formId] = newForm; newForm.touched = { ... newForm.touched}; - action.payload.touched.forEach((field) => newForm[field] = true); + action.payload.touched.forEach((field) => newForm.touched[field] = true); return newState; } else { diff --git a/src/app/submission/objects/submission-objects.effects.ts b/src/app/submission/objects/submission-objects.effects.ts index a4b3a94ff8..4f6563c662 100644 --- a/src/app/submission/objects/submission-objects.effects.ts +++ b/src/app/submission/objects/submission-objects.effects.ts @@ -443,7 +443,7 @@ function getForm(forms, currentState, sectionId) { * @param notify * Whether notifications are enabled */ -function filterErrors(sectionForm: FormState, sectionErrors: SubmissionSectionError[], sectionType: string, notify: boolean): any { +function filterErrors(sectionForm: FormState, sectionErrors: SubmissionSectionError[], sectionType: string, notify: boolean): SubmissionSectionError[] { if (notify || sectionType !== SectionsType.SubmissionForm) { return sectionErrors; } diff --git a/src/app/submission/objects/submission-objects.reducer.ts b/src/app/submission/objects/submission-objects.reducer.ts index 91caeb1e77..9d2030ce25 100644 --- a/src/app/submission/objects/submission-objects.reducer.ts +++ b/src/app/submission/objects/submission-objects.reducer.ts @@ -695,7 +695,7 @@ function setSectionFormId(state: SubmissionObjectState, action: SetSectionFormId */ function updateSectionData(state: SubmissionObjectState, action: UpdateSectionDataAction): SubmissionObjectState { if (isNotEmpty(state[ action.payload.submissionId ]) - && isNotEmpty(state[ action.payload.submissionId ].sections[ action.payload.sectionId])) { + && isNotEmpty(state[ action.payload.submissionId ].sections[ action.payload.sectionId])) { return Object.assign({}, state, { [ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], { sections: Object.assign({}, state[ action.payload.submissionId ].sections, { @@ -718,8 +718,10 @@ function updateSectionData(state: SubmissionObjectState, action: UpdateSectionDa * Keep the existent otherwise. * @param newMetadata * @param oldMetadata + * @return + * new sectionMetadata value */ -function reduceSectionMetadata(newMetadata: string[], oldMetadata: string[]) { +function reduceSectionMetadata(newMetadata: string[], oldMetadata: string[]): string[] { if (newMetadata) { return newMetadata; } diff --git a/src/app/submission/sections/form/section-form.component.ts b/src/app/submission/sections/form/section-form.component.ts index 5a04187ea3..6e1e6d52f3 100644 --- a/src/app/submission/sections/form/section-form.component.ts +++ b/src/app/submission/sections/form/section-form.component.ts @@ -240,7 +240,7 @@ export class SubmissionSectionformComponent extends SectionModelComponent { const sectionDataToCheck = {}; Object.keys(sectionData).forEach((key) => { - if (this.sectionMetadata.includes(key)) { + if (this.sectionMetadata && this.sectionMetadata.includes(key)) { sectionDataToCheck[key] = sectionData[key]; } }) diff --git a/src/app/submission/sections/sections.service.spec.ts b/src/app/submission/sections/sections.service.spec.ts index 5c7bff13ce..75b6dfe67e 100644 --- a/src/app/submission/sections/sections.service.spec.ts +++ b/src/app/submission/sections/sections.service.spec.ts @@ -380,4 +380,25 @@ describe('SectionsService test suite', () => { expect(store.dispatch).toHaveBeenCalledWith(new UpdateSectionDataAction(submissionId, sectionId, data, [])); }); }); + + describe('computeSectionConfiguredMetadata', () => { + it('should return the configured metadata of the section from the form configuration', () => { + + const formConfig = { + rows: [{ + fields: [{ + selectableMetadata: [{ + metadata: 'dc.contributor.author' + }] + }] + }] + } + + const expectedConfiguredMetadata = [ 'dc.contributor.author' ]; + + const configuredMetadata = service.computeSectionConfiguredMetadata(formConfig as any); + + expect(configuredMetadata).toEqual(expectedConfiguredMetadata); + }); + }); });