AW-1419
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2020-08-04 16:09:22 +02:00
parent 309b320534
commit ee7d1cb9a2
2 changed files with 26 additions and 6 deletions

View File

@ -74,6 +74,12 @@ export class InitUserSuccess implements Action {
constructor(public user:IUser,public userinfo:UserInfo ) { } constructor(public user:IUser,public userinfo:UserInfo ) { }
} }
export class InitUserPackages implements Action {
readonly type = INITUSERPACKAGES;
constructor() {}
}
export class InitUserPackagesSuccess implements Action { export class InitUserPackagesSuccess implements Action {
readonly type = INITUSERPACKAGESSUCCESS; readonly type = INITUSERPACKAGESSUCCESS;
@ -301,6 +307,7 @@ export type Actions = OpenModal
| DeviceUpdateEvent | DeviceUpdateEvent
| ToggleMenu | ToggleMenu
| SetMenuVisible | SetMenuVisible
| InitUserPackages
| InitUserPackagesSuccess | InitUserPackagesSuccess
| ToggleAccountMenu | ToggleAccountMenu
| CloseAll | CloseAll

View File

@ -58,23 +58,36 @@ export class AppCommonEffects {
} }
)); ));
@Effect() @Effect()
initUserPackages$:Observable<Action> = this.actions$.pipe( initUserPackages$:Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.INITUSERSUCCESS), ofType(appCommonActions.INITUSERPACKAGES),
switchMap((action) => { withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
let a = action as appCommonActions.InitUserSuccess; switchMap(([action,user]) => {
return this.itemService$.getChildItemList(a.user.code+":USER_PACKAGES","vnd.farmmaps.itemtype.package").pipe( return this.itemService$.getChildItemList(user.code+":USER_PACKAGES","vnd.farmmaps.itemtype.package").pipe(
switchMap((items) => of(new appCommonActions.InitUserPackagesSuccess(items))), switchMap((items) => of(new appCommonActions.InitUserPackagesSuccess(items))),
catchError(error => of(new appCommonActions.Fail(error))) catchError(error => of(new appCommonActions.Fail(error)))
) )
}) })
); );
@Effect()
userPackagesChanged$:Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.ITEMCHANGEDEVENT),
switchMap((action) => {
let a = action as appCommonActions.ItemChangedEvent;
if(a.itemCode.endsWith(":USER_PACKAGES"))
return of(new appCommonActions.InitUserPackages());
else
return of(undefined);
})
);
@Effect() @Effect()
initUserSuccess$: Observable<Action> = this.actions$.pipe( initUserSuccess$: Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.INITUSERSUCCESS), ofType(appCommonActions.INITUSERSUCCESS),
switchMap(() => { switchMap(() => {
return of(new appCommonActions.InitRoot()); return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages()];
} }
)); ));