More refactoring

This commit is contained in:
Willem Dantuma 2020-04-21 14:54:13 +02:00
parent e41c728fb2
commit ef81b04f4e
3 changed files with 10 additions and 9 deletions

View File

@ -28,7 +28,7 @@ export abstract class AbstractFeatureListComponent {
} }
getAction(feature:Feature):Action { getAction(feature:Feature):Action {
var newQuery: any = tassign(mapReducers.initialState.query); var newQuery: any = tassign(mapReducers.initialState.queryState);
newQuery.parentCode = feature.get('parentCode'); newQuery.parentCode = feature.get('parentCode');
newQuery.itemCode = feature.get('code'); newQuery.itemCode = feature.get('code');
newQuery.itemType = feature.get('itemType'); newQuery.itemType = feature.get('itemType');

View File

@ -252,14 +252,14 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
queryStateChanged = this.serializeService.serialize(state.queryState) != this.serializeService.serialize(urlQueryState); 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)); return of(new mapActions.SetState(newMapState,newQueryState));
} else { window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(newMapState));
return of(null); } else if(queryStateChanged) {
} return of(new mapActions.SetQueryState(newQueryState));
} return of(null)
})).subscribe((action) => { })).subscribe((action) => {
if(action) { if(action) {
window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(action.mapState));
console.debug("Url to state"); console.debug("Url to state");
this.store.dispatch(action); this.store.dispatch(action);
} }
@ -353,6 +353,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
} }
handleOnMouseDown(event: MouseEvent) { handleOnMouseDown(event: MouseEvent) {
event.stopPropagation();
this.zone.run(() =>{ this.zone.run(() =>{
this.store.dispatch(new mapActions.CollapseSearch()); this.store.dispatch(new mapActions.CollapseSearch());
}); });

View File

@ -269,7 +269,7 @@ export class MapEffects {
})); }));
getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable<Action>|[] { getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable<Action>|[] {
if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemType)) { if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode)) {
var newAction:Action; var newAction:Action;
if (queryState.itemCode && queryState.itemCode != "") { if (queryState.itemCode && queryState.itemCode != "") {
newAction= new mapActions.SelectItem(queryState.itemCode); newAction= new mapActions.SelectItem(queryState.itemCode);
@ -278,7 +278,7 @@ export class MapEffects {
} }
return of(newAction); return of(newAction);
} else { } else {
return []; return of(new commonActions.Escape(true,false));
} }
} }