mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
[835] Auto-save in new Item Submission form breaks the form
Section formId added to the section state. Error filtering during the parsing of the submission response.
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
SaveSubmissionSectionFormSuccessAction,
|
||||
SectionStatusChangeAction,
|
||||
SetActiveSectionAction,
|
||||
SetSectionFormId,
|
||||
SubmissionObjectAction,
|
||||
SubmissionObjectActionTypes,
|
||||
UpdateSectionDataAction
|
||||
@@ -109,6 +110,11 @@ export interface SubmissionSectionObject {
|
||||
* A boolean representing if this section is valid
|
||||
*/
|
||||
isValid: boolean;
|
||||
|
||||
/**
|
||||
* The formId related to this section
|
||||
*/
|
||||
formId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,6 +269,10 @@ export function submissionObjectReducer(state = initialState, action: Submission
|
||||
return initSection(state, action as InitSectionAction);
|
||||
}
|
||||
|
||||
case SubmissionObjectActionTypes.SET_SECTION_FORM_ID: {
|
||||
return setSectionFormId(state, action as SetSectionFormId);
|
||||
}
|
||||
|
||||
case SubmissionObjectActionTypes.ENABLE_SECTION: {
|
||||
return changeSectionState(state, action as EnableSectionAction, true);
|
||||
}
|
||||
@@ -646,6 +656,33 @@ function initSection(state: SubmissionObjectState, action: InitSectionAction): S
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a section form id.
|
||||
*
|
||||
* @param state
|
||||
* the current state
|
||||
* @param action
|
||||
* an SetSectionFormId
|
||||
* @return SubmissionObjectState
|
||||
* the new state
|
||||
*/
|
||||
function setSectionFormId(state: SubmissionObjectState, action: SetSectionFormId): SubmissionObjectState {
|
||||
if (hasValue(state[ action.payload.submissionId ])) {
|
||||
return Object.assign({}, state, {
|
||||
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
|
||||
sections: Object.assign({}, state[ action.payload.submissionId ].sections, {
|
||||
[ action.payload.sectionId ]: {
|
||||
...state[ action.payload.submissionId ].sections [action.payload.sectionId],
|
||||
formId: action.payload.formId
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update section's data.
|
||||
*
|
||||
|
Reference in New Issue
Block a user