From ef81b04f4e0bed0423ed2402dcba4d1423bafee2 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Tue, 21 Apr 2020 14:54:13 +0200 Subject: [PATCH] More refactoring --- .../feature-list/feature-list.component.ts | 2 +- .../src/fm-map/components/map/map.component.ts | 13 +++++++------ .../common-map/src/fm-map/effects/map.effects.ts | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts b/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts index f24c7bf..241de46 100644 --- a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts @@ -28,7 +28,7 @@ export abstract class AbstractFeatureListComponent { } getAction(feature:Feature):Action { - var newQuery: any = tassign(mapReducers.initialState.query); + var newQuery: any = tassign(mapReducers.initialState.queryState); newQuery.parentCode = feature.get('parentCode'); newQuery.itemCode = feature.get('code'); newQuery.itemType = feature.get('itemType'); diff --git a/projects/common-map/src/fm-map/components/map/map.component.ts b/projects/common-map/src/fm-map/components/map/map.component.ts index be31c0c..3657f42 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.ts +++ b/projects/common-map/src/fm-map/components/map/map.component.ts @@ -252,14 +252,14 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { queryStateChanged = this.serializeService.serialize(state.queryState) != this.serializeService.serialize(urlQueryState); } - if(queryStateChanged || mapStateChanged) { + if(queryStateChanged && mapStateChanged && state.setStateCount ==0) { return of(new mapActions.SetState(newMapState,newQueryState)); - } else { - return of(null); - } + window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(newMapState)); + } else if(queryStateChanged) { + return of(new mapActions.SetQueryState(newQueryState)); + } return of(null) })).subscribe((action) => { - if(action) { - window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(action.mapState)); + if(action) { console.debug("Url to state"); this.store.dispatch(action); } @@ -353,6 +353,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { } handleOnMouseDown(event: MouseEvent) { + event.stopPropagation(); this.zone.run(() =>{ this.store.dispatch(new mapActions.CollapseSearch()); }); diff --git a/projects/common-map/src/fm-map/effects/map.effects.ts b/projects/common-map/src/fm-map/effects/map.effects.ts index b6e5bda..3a9a501 100644 --- a/projects/common-map/src/fm-map/effects/map.effects.ts +++ b/projects/common-map/src/fm-map/effects/map.effects.ts @@ -269,7 +269,7 @@ export class MapEffects { })); getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable|[] { - if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemType)) { + if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode)) { var newAction:Action; if (queryState.itemCode && queryState.itemCode != "") { newAction= new mapActions.SelectItem(queryState.itemCode); @@ -278,7 +278,7 @@ export class MapEffects { } return of(newAction); } else { - return []; + return of(new commonActions.Escape(true,false)); } }