From 69f8184dfef03ac7d5b49a11567e8dc1fe774d05 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Fri, 26 Jun 2020 08:22:31 +0200 Subject: [PATCH] add closeall action --- projects/common/src/fm/actions/app-common.actions.ts | 10 +++++++++- projects/common/src/fm/reducers/app-common.reducer.ts | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/projects/common/src/fm/actions/app-common.actions.ts b/projects/common/src/fm/actions/app-common.actions.ts index ee26994..180f355 100644 --- a/projects/common/src/fm/actions/app-common.actions.ts +++ b/projects/common/src/fm/actions/app-common.actions.ts @@ -20,6 +20,7 @@ export const CLOSEMODAL = '[AppCommon] CloseModal'; export const LOGIN = '[AppCommon] Login'; export const LOGOUT = '[AppCommon] Logout'; export const ESCAPE = '[AppCommon] Escape'; +export const CLOSEALL = '[AppCommon] CloseAll'; export const LOADITEMTYPES = '[AppCommon] LoadItemTypes'; export const LOADITEMTYPESSUCCESS = '[AppCommon] LoadItemTypesSuccess'; @@ -99,6 +100,12 @@ export class CloseModal implements Action { constructor() { } } +export class CloseAll implements Action { + readonly type = CLOSEALL; + + constructor() { } +} + export class StartRouteLoading implements Action { readonly type = STARTROUTELOADING; @@ -279,6 +286,7 @@ export type Actions = OpenModal | ToggleMenu | SetMenuVisible | InitUserPackagesSuccess - | ToggleAccountMenu; + | ToggleAccountMenu + | CloseAll; diff --git a/projects/common/src/fm/reducers/app-common.reducer.ts b/projects/common/src/fm/reducers/app-common.reducer.ts index 635d230..09d23ec 100644 --- a/projects/common/src/fm/reducers/app-common.reducer.ts +++ b/projects/common/src/fm/reducers/app-common.reducer.ts @@ -85,7 +85,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) }); } case appCommonActions.TOGGLEMENU: { - return tassign(state, { menuVisible: !state.menuVisible }); + return tassign(state, { menuVisible: !state.menuVisible,accountMenuVisible:!state.menuVisible?false:state.accountMenuVisible }); } case appCommonActions.TOGGLEACCOUNTMENU: { return tassign(state, { accountMenuVisible: !state.accountMenuVisible }); @@ -95,7 +95,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) } case appCommonActions.SETMENUVISIBLE: { let a = action as appCommonActions.SetMenuVisible; - return tassign(state, { menuVisible: a.visible }); + return tassign(state, { menuVisible: a.visible,accountMenuVisible:a.visible?false:state.accountMenuVisible }); } case appCommonActions.INITUSERPACKAGESSUCCESS:{ let a = action as appCommonActions.InitUserPackagesSuccess; @@ -109,6 +109,9 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) case appCommonActions.LOGOUT:{ return tassign(state,{user:null,initialized:false}); } + case appCommonActions.CLOSEALL: { + return tassign(state,{accountMenuVisible:false,menuVisible:false }); + } default: { return state; }