AW-1431 Add InitUserSettingsRoot
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
ad1d40cdd1
commit
4d67a656f5
@ -12,6 +12,9 @@ export const INITUSERSUCCESS = '[AppCommon] InitUserSuccess';
|
||||
export const INITUSERPACKAGES = '[AppCommon] InitUserPackages';
|
||||
export const INITUSERPACKAGESSUCCESS = '[AppCommon] InitUserPackagesSuccess';
|
||||
|
||||
export const INITUSERSETTINGSROOT = '[AppCommon] InitUserSettingsRoot';
|
||||
export const INITUSERSETTINGSROOTSUCCESS = '[AppCommon] InitUserSettingsRootSuccess';
|
||||
|
||||
export const INITROOT = '[Explorer] InitRoot';
|
||||
export const INITROOTSUCCESS = '[Explorer] InitRootSuccess';
|
||||
|
||||
@ -87,6 +90,18 @@ export class InitUserPackagesSuccess implements Action {
|
||||
constructor(public items:IItem[] ) { }
|
||||
}
|
||||
|
||||
export class InitUserSettingsRoot implements Action {
|
||||
readonly type = INITUSERSETTINGSROOT;
|
||||
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
export class InitUserSettingsRootSuccess implements Action {
|
||||
readonly type = INITUSERSETTINGSROOTSUCCESS;
|
||||
|
||||
constructor(public item: IItem ) { }
|
||||
}
|
||||
|
||||
export class InitRoot implements Action {
|
||||
readonly type = INITROOT;
|
||||
|
||||
@ -317,6 +332,8 @@ export type Actions = OpenModal
|
||||
| SetMenuVisible
|
||||
| InitUserPackages
|
||||
| InitUserPackagesSuccess
|
||||
| InitUserSettingsRoot
|
||||
| InitUserSettingsRootSuccess
|
||||
| ToggleAccountMenu
|
||||
| CloseAll
|
||||
| Online
|
||||
|
@ -82,11 +82,35 @@ export class AppCommonEffects {
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
initUserSettingsRoot$:Observable<Action> = this.actions$.pipe(
|
||||
ofType(appCommonActions.INITUSERSETTINGSROOT),
|
||||
withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
|
||||
switchMap(([, user]) => {
|
||||
return this.itemService$.getItem(user.code + ':USER_SETTINGS').pipe(
|
||||
switchMap((item) => of(new appCommonActions.InitUserSettingsRootSuccess(item))),
|
||||
catchError(error => of(new appCommonActions.Fail(error)))
|
||||
)
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
initUserSettingsRootChanged$:Observable<Action> = this.actions$.pipe(
|
||||
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
||||
switchMap((action) => {
|
||||
let a = action as appCommonActions.ItemChangedEvent;
|
||||
if(a.itemCode.endsWith(":USER_SETTINGS"))
|
||||
return of(new appCommonActions.InitUserSettingsRoot());
|
||||
else
|
||||
return [];
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
initUserSuccess$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(appCommonActions.INITUSERSUCCESS),
|
||||
switchMap(() => {
|
||||
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages()];
|
||||
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages(),new appCommonActions.InitUserSettingsRoot()];
|
||||
}
|
||||
));
|
||||
|
||||
|
@ -7,6 +7,7 @@ import * as appCommonActions from '../actions/app-common.actions';
|
||||
import { createSelector, createFeatureSelector, ActionReducerMap } from '@ngrx/store';
|
||||
|
||||
import { MODULE_NAME } from '../module-name';
|
||||
import { IItem } from '../models/item';
|
||||
|
||||
export interface State {
|
||||
openedModalName: string,
|
||||
@ -18,6 +19,7 @@ export interface State {
|
||||
routeLoading:boolean,
|
||||
menuVisible: boolean,
|
||||
userPackages: IPackages,
|
||||
userSettingsRoot: IItem,
|
||||
accountMenuVisible: boolean,
|
||||
isOnline: boolean
|
||||
}
|
||||
@ -32,6 +34,7 @@ export const initialState: State = {
|
||||
routeLoading: false,
|
||||
menuVisible: false,
|
||||
userPackages: {},
|
||||
userSettingsRoot: null,
|
||||
accountMenuVisible: false,
|
||||
isOnline: true
|
||||
}
|
||||
@ -111,6 +114,10 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
||||
|
||||
return tassign(state,{userPackages:packages});
|
||||
}
|
||||
case appCommonActions.INITUSERSETTINGSROOTSUCCESS:{
|
||||
let a = action as appCommonActions.InitUserSettingsRootSuccess;
|
||||
return tassign(state, { userSettingsRoot : a.item });
|
||||
}
|
||||
case appCommonActions.LOGOUT:{
|
||||
return tassign(state,{user:null,initialized:false});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user