Fixed issue with a subscribiption when submission component is destroyed

This commit is contained in:
Giuseppe Digilio
2018-11-21 14:55:50 +01:00
parent 9eb00b9e62
commit 8efa2cfc4b
3 changed files with 2 additions and 4 deletions

View File

@@ -615,7 +615,7 @@ function changeSectionState(state: SubmissionObjectState, action: EnableSectionA
* the new state, with the section new validity status. * the new state, with the section new validity status.
*/ */
function setIsValid(state: SubmissionObjectState, action: SectionStatusChangeAction): SubmissionObjectState { function setIsValid(state: SubmissionObjectState, action: SectionStatusChangeAction): SubmissionObjectState {
if (hasValue(state[ action.payload.submissionId ].sections[ action.payload.sectionId ])) { if (isNotEmpty(state[ action.payload.submissionId ]) && hasValue(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,

View File

@@ -74,7 +74,6 @@ export class LicenseSectionComponent extends SectionModelComponent {
// Retrieve license accepted status // Retrieve license accepted status
if ((this.sectionData.data as WorkspaceitemSectionLicenseObject).granted) { if ((this.sectionData.data as WorkspaceitemSectionLicenseObject).granted) {
(model as DynamicCheckboxModel).valueUpdates.next(true); (model as DynamicCheckboxModel).valueUpdates.next(true);
// this.sectionService.setSectionStatus(this.submissionId, this.sectionData.id, true);
} else { } else {
(model as DynamicCheckboxModel).valueUpdates.next(false); (model as DynamicCheckboxModel).valueUpdates.next(false);
} }
@@ -130,7 +129,6 @@ export class LicenseSectionComponent extends SectionModelComponent {
onChange(event: DynamicFormControlEvent) { onChange(event: DynamicFormControlEvent) {
const path = this.formOperationsService.getFieldPathSegmentedFromChangeEvent(event); const path = this.formOperationsService.getFieldPathSegmentedFromChangeEvent(event);
const value = this.formOperationsService.getFieldValueFromChangeEvent(event); const value = this.formOperationsService.getFieldValueFromChangeEvent(event);
// this.sectionService.setSectionStatus(this.submissionId, this.sectionData.id, value.value);
if (value) { if (value) {
this.operationsBuilder.add(this.pathCombiner.getPath(path), value.value.toString(), false, true); this.operationsBuilder.add(this.pathCombiner.getPath(path), value.value.toString(), false, true);
// Remove any section's errors // Remove any section's errors

View File

@@ -47,9 +47,9 @@ export abstract class SectionModelComponent implements OnDestroy, OnInit, Sectio
} }
ngOnDestroy(): void { ngOnDestroy(): void {
this.onSectionDestroy();
if (hasValue(this.sectionStatusSub)) { if (hasValue(this.sectionStatusSub)) {
this.sectionStatusSub.unsubscribe(); this.sectionStatusSub.unsubscribe();
} }
this.onSectionDestroy();
} }
} }