diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils')
3 files changed, 63 insertions, 4 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts index 4af0243e6..d4e6cf287 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts @@ -11,9 +11,15 @@ export enum GlobalActions { UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER = 'UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER', DELETE_GENERIC_MODAL_TABLE_DATA_HELPER = 'DELETE_GENERIC_MODAL_TABLE_DATA_HELPER', UPDATE_GENERIC_CURRNT_VRF_HELPER = 'UPDATE_GENERIC_CURRNT_VRF_HELPER', - DELETE_GENERIC_CURRNT_VRF_HELPER = 'DELETE_GENERIC_CURRNT_VRF_HELPER' + DELETE_GENERIC_CURRNT_VRF_HELPER = 'DELETE_GENERIC_CURRNT_VRF_HELPER', + UPDATE_CURRENT_MODAL_MODE = 'UPDATE_CURRENT_MODAL_MODE' } +export interface UpdateCurrentModalModeAction extends Action { + isUpdateModalMode?: boolean; +} + + export interface UpdateGlobalAction extends Action { name?: string; } @@ -106,3 +112,8 @@ export const deleteGenericModalTableDataHelper: ActionCreator<DeleteGenericModal export const clearAllGenericModalhelper: ActionCreator<ClearGenericModalHelper> = (field, uniqObjectField) => ({ type : GlobalActions.CLEAR_ALL_GENERIC_MODAL_HELPER }); + +export const updateCurrentModalModeAction: ActionCreator<UpdateCurrentModalModeAction> = (isUpdateModalMode? :boolean) => ({ + type : GlobalActions.UPDATE_CURRENT_MODAL_MODE, + isUpdateModalMode +}); diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts index c8aecdd57..47b5e09c5 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts @@ -7,7 +7,7 @@ import { UpdateGenericModalHelper, DeleteGenericModalHelper, ClearGenericModalHelper, - UpdateGenericModalTableDataHelper + UpdateGenericModalTableDataHelper, UpdateCurrentModalModeAction } from "./global.actions"; import {globalReducer} from "./global.reducers"; @@ -142,6 +142,43 @@ describe('globalReducer', () => { expect(globalDrawingBoardState.genericModalHelper[keyName]).toBeUndefined(); }); + + + test('#UPDATE_CURRENT_MODAL_MODE : should update current modal mode: true', ()=> { + let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : { + isUpdateModalMode : null + }}, + <UpdateCurrentModalModeAction>{ + type: GlobalActions.UPDATE_CURRENT_MODAL_MODE, + isUpdateModalMode : true + }); + expect(globalDrawingBoardState.isUpdateModalMode).toBeTruthy(); + }); + + + test('#UPDATE_CURRENT_MODAL_MODE : should update current modal mode: false', ()=> { + let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : { + isUpdateModalMode : true + }}, + <UpdateCurrentModalModeAction>{ + type: GlobalActions.UPDATE_CURRENT_MODAL_MODE, + isUpdateModalMode : false + }); + expect(globalDrawingBoardState.isUpdateModalMode).toBeFalsy(); + }); + + test('#UPDATE_CURRENT_MODAL_MODE : should delete modal mode if value is null', ()=> { + let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : { + isUpdateModalMode : true + }}, + <UpdateCurrentModalModeAction>{ + type: GlobalActions.UPDATE_CURRENT_MODAL_MODE, + isUpdateModalMode : null + }); + expect(globalDrawingBoardState.isUpdateModalMode).toBeUndefined(); + }); + + }); diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts index aedcce24b..49df2088a 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts @@ -8,7 +8,7 @@ import { UpdateGenericModalHelper, DeleteGenericModalHelper, DeleteGenericModalTabelDataHelper, - UpdateGenericModalTableDataHelper + UpdateGenericModalTableDataHelper, UpdateCurrentModalModeAction } from "./global.actions"; import * as _ from "lodash"; @@ -18,6 +18,7 @@ export interface GlobalState { drawingBoardStatus : string; genericModalCriteria : { [key: string]: any }; genericModalHelper : { [key: string]: any }; + isUpdateModalMode?: boolean; } @@ -28,7 +29,8 @@ const initialState: GlobalState = { genericModalCriteria : { roles : [] }, - genericModalHelper : {} + genericModalHelper : {}, + isUpdateModalMode : null }; export const globalReducer = @@ -81,6 +83,15 @@ export const globalReducer = newState.genericModalHelper[(<UpdateGenericModalTableDataHelper>action).field] = (<UpdateGenericModalTableDataHelper>action).values ; return newState; } + case GlobalActions.UPDATE_CURRENT_MODAL_MODE : { + let newState = {...state}; + if ((<UpdateCurrentModalModeAction>action).isUpdateModalMode === null){ + delete newState.isUpdateModalMode; + } else { + newState.isUpdateModalMode = (<UpdateCurrentModalModeAction>action).isUpdateModalMode; + } + return newState; + } default: return state; } |