From f792671ae247a931f34d902e9276202b5016ef9a Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Sun, 7 Jul 2019 19:23:03 +0300 Subject: Merge from ecomp 718fd196 - Modern UI Issue-ID: VID-378 Change-Id: I2736b98426e324ec3aa233b034229ba84d99839f Signed-off-by: Ittay Stern --- .../storeUtil/utils/global/global.actions.ts | 73 ++++++++++++++- .../storeUtil/utils/global/global.reducers.spec.ts | 102 ++++++++++++++++++++- .../storeUtil/utils/global/global.reducers.ts | 62 ++++++++++++- 3 files changed, 233 insertions(+), 4 deletions(-) (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/global') 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 609ec69f4..4af0243e6 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 @@ -3,7 +3,15 @@ import {Action, ActionCreator} from "redux"; export enum GlobalActions { UPDATE_NAME = 'UPDATE_NAME', UPDATE_FLAGS = 'UPDATE_FLAGS', - UPDATE_DRAWING_BOARD_STATUS = 'UPDATE_DRAWING_BOARD_STATUS' + UPDATE_DRAWING_BOARD_STATUS = 'UPDATE_DRAWING_BOARD_STATUS', + UPDATE_GENERIC_MODAL_CRITERIA = 'UPDATE_GENERIC_MODAL_CRITERIA', + UPDATE_GENERIC_MODAL_HELPER = 'UPDATE_GENERIC_MODAL_HELPER', + DELETE_GENERIC_MODAL_HELPER = 'DELETE_GENERIC_MODAL_HELPER', + CLEAR_ALL_GENERIC_MODAL_HELPER = 'CLEAR_ALL_GENERIC_MODAL_HELPER', + 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' } export interface UpdateGlobalAction extends Action { @@ -18,6 +26,33 @@ export interface UpdateDrawingBoardStatusAction extends Action{ drawingBoardStatus?: any; } +export interface UpdateGenericModalCriteria extends Action { + field: any; + values: any; +} + +export interface UpdateGenericModalTableDataHelper extends Action { + field: any; + values: any; +} +export interface UpdateGenericModalHelper extends Action { + field: any; + values: any; + uniqObjectField : string; +} + +export interface DeleteGenericModalHelper extends Action { + field: any; + uniqObjectField : string; +} + +export interface DeleteGenericModalTabelDataHelper extends Action { + field: any; +} + + +export interface ClearGenericModalHelper extends Action {} + export const updateName: ActionCreator = (name) => ({ type: GlobalActions.UPDATE_NAME, @@ -35,3 +70,39 @@ export const updateDrawingBoardStatus: ActionCreator = (field, values) => ({ + type : GlobalActions.UPDATE_GENERIC_MODAL_CRITERIA, + field: field, + values: values +}); + +export const updateGenericModalhelper: ActionCreator = (field, values, uniqObjectField) => ({ + type : GlobalActions.UPDATE_GENERIC_MODAL_HELPER, + field: field, + values: values, + uniqObjectField : uniqObjectField +}); + +export const deleteGenericModalhelper: ActionCreator = (field, uniqObjectField) => ({ + type : GlobalActions.DELETE_GENERIC_MODAL_HELPER, + field: field, + uniqObjectField : uniqObjectField +}); + + +export const updateGenericModalTableDataHelper: ActionCreator = (field, values) => ({ + type : GlobalActions.UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER, + field: field, + values: values, +}); + +export const deleteGenericModalTableDataHelper: ActionCreator = (field) => ({ + type : GlobalActions.DELETE_GENERIC_MODAL_TABLE_DATA_HELPER, + field: field, +}); + +export const clearAllGenericModalhelper: ActionCreator = (field, uniqObjectField) => ({ + type : GlobalActions.CLEAR_ALL_GENERIC_MODAL_HELPER +}); 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 4fc80863a..c8aecdd57 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 @@ -1,4 +1,14 @@ -import {GlobalActions, UpdateFlagsAction, UpdateGlobalAction, UpdateDrawingBoardStatusAction} from "./global.actions"; +import { + GlobalActions, + UpdateFlagsAction, + UpdateGlobalAction, + UpdateDrawingBoardStatusAction, + UpdateGenericModalCriteria, + UpdateGenericModalHelper, + DeleteGenericModalHelper, + ClearGenericModalHelper, + UpdateGenericModalTableDataHelper +} from "./global.actions"; import {globalReducer} from "./global.reducers"; @@ -42,6 +52,96 @@ describe('globalReducer', () => { expect(globalDrawingBoardState).toBeDefined(); expect(globalDrawingBoardState.drawingBoardStatus).toEqual(drawingBoardStatus); }); + + test('#UPDATE_GENERIC_MODAL_CRITERIA : should update updateGenericModalCriteria object', ()=> { + const values = ["value1", "value2"]; + const fieldName = "someFieldName"; + let globalDrawingBoardState = globalReducer({global : {},genericModalCriteria : {}}, + { + type: GlobalActions.UPDATE_GENERIC_MODAL_CRITERIA, + field : fieldName, + values : values + }); + expect(globalDrawingBoardState).toBeDefined(); + expect(globalDrawingBoardState.genericModalCriteria[fieldName]).toEqual(values); + }); + + test('#UPDATE_GENERIC_MODAL_HELPER : should update updateGenericModalHelper object', ()=> { + const uniqObjectField = "uniqObjectField"; + const values = {name : "value1", uniqObjectField: uniqObjectField}; + const fieldName = "someFieldName"; + + let globalDrawingBoardState = globalReducer({global : {},genericModalHelper : {}}, + { + type: GlobalActions.UPDATE_GENERIC_MODAL_HELPER, + field : fieldName, + values : values, + uniqObjectField : uniqObjectField + }); + expect(globalDrawingBoardState).toBeDefined(); + expect(globalDrawingBoardState.genericModalHelper[fieldName][uniqObjectField]).toEqual({"name": "value1", "uniqObjectField": "uniqObjectField"}); + }); + + test('#DELETE_GENERIC_MODAL_HELPER : should delete exist ', ()=> { + const uniqObjectField = "uniqObjectField"; + const fieldName = "someFieldName"; + + let globalDrawingBoardState = globalReducer({global : {},genericModalHelper : { + "someFieldName" : { + "uniqObjectField" : true + } + }}, + { + type: GlobalActions.DELETE_GENERIC_MODAL_HELPER, + field : fieldName, + uniqObjectField : uniqObjectField + }); + expect(globalDrawingBoardState).toBeDefined(); + expect(globalDrawingBoardState.genericModalHelper[fieldName][uniqObjectField]).toBeUndefined(); + }); + + test('#CLEAR_ALL_GENERIC_MODAL_HELPER : should clear generic modal object', ()=> { + + let globalDrawingBoardState = globalReducer({global : {},genericModalHelper : { + "someFieldName" : { + "uniqObjectField" : true + } + }}, + { + type: GlobalActions.CLEAR_ALL_GENERIC_MODAL_HELPER + }); + expect(globalDrawingBoardState.genericModalHelper).toEqual({}); + }); + + test('#UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER : should update table data with some values', ()=> { + const keyName: string = 'VPN_DATA'; + const someValue: string = 'SOME_VALUE'; + + let globalDrawingBoardState = globalReducer({global : {},genericModalHelper : { + + }}, + { + type: GlobalActions.UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER, + field : keyName, + values : someValue + }); + expect(globalDrawingBoardState.genericModalHelper[keyName]).toEqual(someValue); + }); + + test('#DELETE_GENERIC_MODAL_TABLE_DATA_HELPER : should delete table data', ()=> { + const keyName: string = 'VPN_DATA'; + const someValue: string = 'SOME_VALUE'; + + let globalDrawingBoardState = globalReducer({global : {},genericModalHelper : { + [keyName] : someValue + }}, + { + type: GlobalActions.DELETE_GENERIC_MODAL_TABLE_DATA_HELPER, + field : keyName + }); + expect(globalDrawingBoardState.genericModalHelper[keyName]).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 f9e083414..aedcce24b 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 @@ -1,16 +1,34 @@ import {Action} from 'redux'; -import {GlobalActions, UpdateFlagsAction, UpdateGlobalAction, UpdateDrawingBoardStatusAction} from "./global.actions"; +import { + GlobalActions, + UpdateFlagsAction, + UpdateGlobalAction, + UpdateDrawingBoardStatusAction, + UpdateGenericModalCriteria, + UpdateGenericModalHelper, + DeleteGenericModalHelper, + DeleteGenericModalTabelDataHelper, + UpdateGenericModalTableDataHelper +} from "./global.actions"; +import * as _ from "lodash"; export interface GlobalState { name : string; flags : { [key: string]: boolean }; drawingBoardStatus : string; + genericModalCriteria : { [key: string]: any }; + genericModalHelper : { [key: string]: any }; + } const initialState: GlobalState = { name : null, flags : null, - drawingBoardStatus : null + drawingBoardStatus : null, + genericModalCriteria : { + roles : [] + }, + genericModalHelper : {} }; export const globalReducer = @@ -23,6 +41,46 @@ export const globalReducer = return Object.assign({}, state); case GlobalActions.UPDATE_DRAWING_BOARD_STATUS: return Object.assign(state, state, (action)); + case GlobalActions.UPDATE_GENERIC_MODAL_CRITERIA : { + const updateGenericModalCriteria = action; + let newState = _.cloneDeep(state); + if(_.isNil(newState.genericModalCriteria)){ + newState.genericModalCriteria = {}; + } + newState.genericModalCriteria[updateGenericModalCriteria.field] = updateGenericModalCriteria.values; + return newState; + } + case GlobalActions.UPDATE_GENERIC_MODAL_HELPER : { + const updateGenericModalHelper= action; + let newState = _.cloneDeep(state); + if(_.isNil(newState.genericModalHelper) ){newState.genericModalHelper = {}; } + if(_.isNil(newState.genericModalHelper[updateGenericModalHelper.field])){ + newState.genericModalHelper[updateGenericModalHelper.field] = {}; + } + newState.genericModalHelper[updateGenericModalHelper.field][updateGenericModalHelper.values[updateGenericModalHelper.uniqObjectField]] = updateGenericModalHelper.values; + return newState; + } + case GlobalActions.DELETE_GENERIC_MODAL_HELPER : { + const deleteGenericModalHelper= action; + let newState = _.cloneDeep(state); + delete newState.genericModalHelper[deleteGenericModalHelper.field][deleteGenericModalHelper.uniqObjectField]; + return newState; + } + case GlobalActions.CLEAR_ALL_GENERIC_MODAL_HELPER : { + let newState = _.cloneDeep(state); + newState.genericModalHelper = {}; + return newState; + } + case GlobalActions.DELETE_GENERIC_MODAL_TABLE_DATA_HELPER : { + let newState = _.cloneDeep(state); + delete newState.genericModalHelper[(action).field]; + return newState; + } + case GlobalActions.UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER : { + let newState = _.cloneDeep(state); + newState.genericModalHelper[(action).field] = (action).values ; + return newState; + } default: return state; } -- cgit 1.2.3-korg