From 04477e3bec729b7e216512e6edabf56a54ad0ecd Mon Sep 17 00:00:00 2001 From: RidhamShah Date: Fri, 28 Apr 2023 10:38:04 +0530 Subject: [PATCH] Solved desgin stepper getting disabled bug --- .../experiment-design-stepper.service.ts | 3 ++- .../store/experiment-design-stepper.actions.ts | 1 + .../store/experiment-design-stepper.reducer.ts | 7 +++++-- .../payloads-table/payloads-table.component.ts | 5 +++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/projects/upgrade/src/app/core/experiment-design-stepper/experiment-design-stepper.service.ts b/frontend/projects/upgrade/src/app/core/experiment-design-stepper/experiment-design-stepper.service.ts index 29ee8c4d0c..8359b17aa5 100644 --- a/frontend/projects/upgrade/src/app/core/experiment-design-stepper/experiment-design-stepper.service.ts +++ b/frontend/projects/upgrade/src/app/core/experiment-design-stepper/experiment-design-stepper.service.ts @@ -547,10 +547,11 @@ export class ExperimentDesignStepperService { this.store$.dispatch(actionUpdateFactorialConditionTableData({ tableData })); } - setUpdatePayloadTableEditModeDetails(rowIndex: number | null): void { + setUpdatePayloadTableEditModeDetails(rowIndex: number | null, isNgDestroyCall: boolean): void { this.store$.dispatch( experimentDesignStepperAction.actionToggleSimpleExperimentPayloadTableEditMode({ simpleExperimentPayloadTableEditIndex: rowIndex, + isNgDestroyCall: isNgDestroyCall, }) ); } diff --git a/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.actions.ts b/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.actions.ts index fc43bad1f5..1fc9533777 100644 --- a/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.actions.ts +++ b/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.actions.ts @@ -46,6 +46,7 @@ export const actionToggleSimpleExperimentPayloadTableEditMode = createAction( '[Experiment-Design-Stepper] Update Simple Experiment Payload Table Edit Mode Details', props<{ simpleExperimentPayloadTableEditIndex: number | null; + isNgDestroyCall: boolean; }>() ); diff --git a/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.reducer.ts b/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.reducer.ts index b78d2666ec..0cfa8f05b5 100644 --- a/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.reducer.ts +++ b/frontend/projects/upgrade/src/app/core/experiment-design-stepper/store/experiment-design-stepper.reducer.ts @@ -73,9 +73,12 @@ const reducer = createReducer( })), on( experimentDesignStepperAction.actionToggleSimpleExperimentPayloadTableEditMode, - (state, { simpleExperimentPayloadTableEditIndex }): ExperimentDesignStepperState => { + (state, { simpleExperimentPayloadTableEditIndex, isNgDestroyCall }): ExperimentDesignStepperState => { // toggle edit mode - const editMode = !state.isSimpleExperimentPayloadTableEditMode; + let editMode: boolean; + if (!isNgDestroyCall) { + editMode = !state.isSimpleExperimentPayloadTableEditMode; + } // if not in edit mode, use null for row-index const editIndex = editMode ? simpleExperimentPayloadTableEditIndex : null; diff --git a/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-design/payloads-table/payloads-table.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-design/payloads-table/payloads-table.component.ts index e48749492b..9d9e83b7f9 100644 --- a/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-design/payloads-table/payloads-table.component.ts +++ b/frontend/projects/upgrade/src/app/features/dashboard/home/components/experiment-design/payloads-table/payloads-table.component.ts @@ -50,7 +50,8 @@ export class PayloadsTableComponent implements OnInit, OnDestroy { } ngOnDestroy(): void { - this.experimentDesignStepperService.setUpdatePayloadTableEditModeDetails(null); + this.experimentDesignStepperService.clearSimpleExperimentDesignStepperData(); + this.experimentDesignStepperService.setUpdatePayloadTableEditModeDetails(null, true); this.subscriptions.unsubscribe(); } @@ -118,7 +119,7 @@ export class PayloadsTableComponent implements OnInit, OnDestroy { } this.currentPayloadInput$.next(rowData.payload); - this.experimentDesignStepperService.setUpdatePayloadTableEditModeDetails(rowIndex); + this.experimentDesignStepperService.setUpdatePayloadTableEditModeDetails(rowIndex, false); this.experimentDesignStepperService.setNewSimpleExperimentPayloadTableData(payloadTableData); }