mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
[835] Auto-save in new Item Submission form breaks the form
Minor fixes and method computeSectionConfiguredMetadata tested
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
[formId]="formId"
|
[formId]="formId"
|
||||||
[group]="formGroup"
|
[group]="formGroup"
|
||||||
[hasErrorMessaging]="model.hasErrorMessages"
|
[hasErrorMessaging]="model.hasErrorMessages"
|
||||||
[hidden]="model.hidden"linke
|
[hidden]="model.hidden"
|
||||||
[layout]="formLayout"
|
[layout]="formLayout"
|
||||||
[model]="model"
|
[model]="model"
|
||||||
[ngClass]="[getClass(model, 'element', 'host'), getClass(model, 'grid', 'host')]"
|
[ngClass]="[getClass(model, 'element', 'host'), getClass(model, 'grid', 'host')]"
|
||||||
|
@@ -235,7 +235,7 @@ function changeTouchedState(state: FormState, action: FormAddTouchedAction): For
|
|||||||
newState[action.payload.formId] = newForm;
|
newState[action.payload.formId] = newForm;
|
||||||
|
|
||||||
newForm.touched = { ... newForm.touched};
|
newForm.touched = { ... newForm.touched};
|
||||||
action.payload.touched.forEach((field) => newForm[field] = true);
|
action.payload.touched.forEach((field) => newForm.touched[field] = true);
|
||||||
|
|
||||||
return newState;
|
return newState;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -443,7 +443,7 @@ function getForm(forms, currentState, sectionId) {
|
|||||||
* @param notify
|
* @param notify
|
||||||
* Whether notifications are enabled
|
* 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) {
|
if (notify || sectionType !== SectionsType.SubmissionForm) {
|
||||||
return sectionErrors;
|
return sectionErrors;
|
||||||
}
|
}
|
||||||
|
@@ -695,7 +695,7 @@ function setSectionFormId(state: SubmissionObjectState, action: SetSectionFormId
|
|||||||
*/
|
*/
|
||||||
function updateSectionData(state: SubmissionObjectState, action: UpdateSectionDataAction): SubmissionObjectState {
|
function updateSectionData(state: SubmissionObjectState, action: UpdateSectionDataAction): SubmissionObjectState {
|
||||||
if (isNotEmpty(state[ action.payload.submissionId ])
|
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, {
|
return Object.assign({}, state, {
|
||||||
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
|
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
|
||||||
sections: Object.assign({}, state[ action.payload.submissionId ].sections, {
|
sections: Object.assign({}, state[ action.payload.submissionId ].sections, {
|
||||||
@@ -718,8 +718,10 @@ function updateSectionData(state: SubmissionObjectState, action: UpdateSectionDa
|
|||||||
* Keep the existent otherwise.
|
* Keep the existent otherwise.
|
||||||
* @param newMetadata
|
* @param newMetadata
|
||||||
* @param oldMetadata
|
* @param oldMetadata
|
||||||
|
* @return
|
||||||
|
* new sectionMetadata value
|
||||||
*/
|
*/
|
||||||
function reduceSectionMetadata(newMetadata: string[], oldMetadata: string[]) {
|
function reduceSectionMetadata(newMetadata: string[], oldMetadata: string[]): string[] {
|
||||||
if (newMetadata) {
|
if (newMetadata) {
|
||||||
return newMetadata;
|
return newMetadata;
|
||||||
}
|
}
|
||||||
|
@@ -240,7 +240,7 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
|
|
||||||
const sectionDataToCheck = {};
|
const sectionDataToCheck = {};
|
||||||
Object.keys(sectionData).forEach((key) => {
|
Object.keys(sectionData).forEach((key) => {
|
||||||
if (this.sectionMetadata.includes(key)) {
|
if (this.sectionMetadata && this.sectionMetadata.includes(key)) {
|
||||||
sectionDataToCheck[key] = sectionData[key];
|
sectionDataToCheck[key] = sectionData[key];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -380,4 +380,25 @@ describe('SectionsService test suite', () => {
|
|||||||
expect(store.dispatch).toHaveBeenCalledWith(new UpdateSectionDataAction(submissionId, sectionId, data, []));
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user