mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
[TLC-674] Do not display duplicate section if data is empty
This commit is contained in:
@@ -55,6 +55,9 @@ import parseSectionErrorPaths, { SectionErrorPath } from '../utils/parseSectionE
|
||||
import {FormState} from '../../shared/form/form.reducer';
|
||||
import {SubmissionSectionObject} from './submission-section-object.model';
|
||||
import {SubmissionSectionError} from './submission-section-error.model';
|
||||
import {
|
||||
WorkspaceitemSectionDuplicatesObject
|
||||
} from '../../core/submission/models/workspaceitem-section-duplicates.model';
|
||||
|
||||
@Injectable()
|
||||
export class SubmissionObjectEffects {
|
||||
@@ -71,7 +74,11 @@ export class SubmissionObjectEffects {
|
||||
const selfLink = sectionDefinition._links.self.href || sectionDefinition._links.self;
|
||||
const sectionId = selfLink.substr(selfLink.lastIndexOf('/') + 1);
|
||||
const config = sectionDefinition._links.config ? (sectionDefinition._links.config.href || sectionDefinition._links.config) : '';
|
||||
const enabled = (sectionDefinition.mandatory) || (isNotEmpty(action.payload.sections) && action.payload.sections.hasOwnProperty(sectionId));
|
||||
// A section is enabled if it is mandatory (except duplicate detection) or contains data in its section payload
|
||||
const enabled = (sectionDefinition.mandatory && (sectionDefinition.sectionType !== SectionsType.Duplicates))
|
||||
|| (isNotEmpty(action.payload.sections) && action.payload.sections.hasOwnProperty(sectionId)
|
||||
&& (sectionDefinition.sectionType === SectionsType.Duplicates && isNotEmpty((action.payload.sections[sectionId] as WorkspaceitemSectionDuplicatesObject).potentialDuplicates))
|
||||
);
|
||||
let sectionData;
|
||||
if (sectionDefinition.sectionType !== SectionsType.SubmissionForm) {
|
||||
sectionData = (isNotUndefined(action.payload.sections) && isNotUndefined(action.payload.sections[sectionId])) ? action.payload.sections[sectionId] : Object.create(null);
|
||||
@@ -434,8 +441,13 @@ export class SubmissionObjectEffects {
|
||||
&& isEmpty(sections[sherpaPoliciesSectionId])) {
|
||||
mappedActions.push(new UpdateSectionDataAction(submissionId, sherpaPoliciesSectionId, null, [], []));
|
||||
}
|
||||
});
|
||||
|
||||
// When Duplicate Detection step is enabled, add it only if there are duplicates
|
||||
const duplicatesSectionId = findKey(currentState.sections, (section) => section.sectionType === SectionsType.Duplicates);
|
||||
if (isNotUndefined(duplicatesSectionId) && isNotEmpty(currentState.sections[duplicatesSectionId]?.data) && isEmpty(sections[duplicatesSectionId])) {
|
||||
mappedActions.push(new UpdateSectionDataAction(submissionId, duplicatesSectionId, null, [], []));
|
||||
}
|
||||
});
|
||||
}
|
||||
return mappedActions;
|
||||
}
|
||||
|
Reference in New Issue
Block a user