Skip to content
Snippets Groups Projects
Commit 8efa2cfc authored by Giuseppe Digilio's avatar Giuseppe Digilio
Browse files

Fixed issue with a subscribiption when submission component is destroyed

parent 9eb00b9e
No related branches found
No related tags found
No related merge requests found
...@@ -615,7 +615,7 @@ function changeSectionState(state: SubmissionObjectState, action: EnableSectionA ...@@ -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,
......
...@@ -74,7 +74,6 @@ export class LicenseSectionComponent extends SectionModelComponent { ...@@ -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 { ...@@ -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
......
...@@ -47,9 +47,9 @@ export abstract class SectionModelComponent implements OnDestroy, OnInit, Sectio ...@@ -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();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment