mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[835] Auto-save in new Item Submission form breaks the form
Section metadata dispatched to the store and retrieved in subscription. Added test case for hasMetadataEnrichment.
This commit is contained in:
@@ -301,6 +301,15 @@ describe('SubmissionSectionformComponent test suite', () => {
|
|||||||
expect(comp.hasMetadataEnrichment(newSectionData)).toBeFalsy();
|
expect(comp.hasMetadataEnrichment(newSectionData)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return false when metadata has Metadata Enrichment but not belonging to sectionMetadata', () => {
|
||||||
|
const newSectionData = {
|
||||||
|
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||||
|
};
|
||||||
|
compAsAny.formData = newSectionData;
|
||||||
|
compAsAny.sectionMetadata = [];
|
||||||
|
expect(comp.hasMetadataEnrichment(newSectionData)).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
it('should update form properly', () => {
|
it('should update form properly', () => {
|
||||||
spyOn(comp, 'initForm');
|
spyOn(comp, 'initForm');
|
||||||
spyOn(comp, 'checksForErrors');
|
spyOn(comp, 'checksForErrors');
|
||||||
|
@@ -283,7 +283,8 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
sectionData,
|
sectionData,
|
||||||
this.submissionService.getSubmissionScope()
|
this.submissionService.getSubmissionScope()
|
||||||
);
|
);
|
||||||
this.sectionMetadata = this.sectionService.computeSectionConfiguredMetadata(this.formConfig);
|
const sectionMetadata = this.sectionService.computeSectionConfiguredMetadata(this.formConfig);
|
||||||
|
this.sectionService.updateSectionData(this.submissionId, this.sectionData.id, sectionData, [], sectionMetadata);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const msg: string = this.translate.instant('error.submission.sections.init-form-error') + e.toString();
|
const msg: string = this.translate.instant('error.submission.sections.init-form-error') + e.toString();
|
||||||
@@ -365,6 +366,7 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
distinctUntilChanged())
|
distinctUntilChanged())
|
||||||
.subscribe((sectionState: SubmissionSectionObject) => {
|
.subscribe((sectionState: SubmissionSectionObject) => {
|
||||||
this.fieldsOnTheirWayToBeRemoved = new Map();
|
this.fieldsOnTheirWayToBeRemoved = new Map();
|
||||||
|
this.sectionMetadata = sectionState.metadata;
|
||||||
this.updateForm(sectionState.data as WorkspaceitemSectionFormObject, sectionState.errors);
|
this.updateForm(sectionState.data as WorkspaceitemSectionFormObject, sectionState.errors);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user