Add action logging and some refactoring

This commit is contained in:
Willem Dantuma
2020-04-17 13:26:50 +02:00
parent 3828db341a
commit c6d7f6b0cb
4 changed files with 117 additions and 69 deletions

View File

@@ -129,7 +129,7 @@ export class MapEffects {
),
catchError(error => of(new commonActions.Fail(error))));
} else {
newAction= of(new commonActions.Escape(true,false));
return [];
}
return newAction;
}));
@@ -251,27 +251,39 @@ export class MapEffects {
@Effect()
setQueryState$: Observable<Action> = this.actions$.pipe(
ofType(mapActions.SETQUERYSTATE),
switchMap((action: mapActions.SetQueryState) => {
var newAction:Action;
if (action.queryState.itemCode && action.queryState.itemCode != "") {
newAction= new mapActions.SelectItem(action.queryState.itemCode);
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
switchMap(([action,inSearch]) => {
if(!inSearch) {
let a = action as mapActions.SetQueryState;
var newAction:Action;
if (a.queryState.itemCode && a.queryState.itemCode != "") {
newAction= new mapActions.SelectItem(a.queryState.itemCode);
} else {
newAction= new mapActions.StartSearch(a.queryState);
}
return of(newAction);
} else {
newAction= new mapActions.StartSearch(action.queryState);
return [];
}
return of(newAction);
}));
@Effect()
setState$: Observable<Action> = this.actions$.pipe(
ofType(mapActions.SETSTATE),
switchMap((action: mapActions.SetState) => {
var newAction:Action;
if (action.queryState.itemCode && action.queryState.itemCode != "") {
newAction= new mapActions.SelectItem(action.queryState.itemCode);
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
switchMap(([action,inSearch]) => {
if(!inSearch) {
let a = action as mapActions.SetQueryState;
var newAction:Action;
if (a.queryState.itemCode && a.queryState.itemCode != "") {
newAction= new mapActions.SelectItem(a.queryState.itemCode);
} else {
newAction= new mapActions.StartSearch(a.queryState);
}
return of(newAction);
} else {
newAction= new mapActions.StartSearch(action.queryState);
return [];
}
return of(newAction);
}));
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService) {