Fix for diffrent action on feature select on map
FarmMaps.Develop/FarmMapsLib/develop This commit looks good Details

feature/MinimizeSolution
Willem Dantuma 2020-02-21 11:06:16 +01:00
parent c341b3e42f
commit a1d7f6d4d2
1 changed files with 24 additions and 2 deletions

View File

@ -115,7 +115,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
handleFeaturesSelected(feature: Feature) {
if (feature) {
let newQuery = tassign(mapReducers.initialQueryState, { itemCode: feature.get('code') });
let newQuery = tassign(mapReducers.initialQueryState, { parentCode: feature.get('parentCode'), itemCode: feature.get('code'),itemType:feature.get('itemType') });
this.store.dispatch(new mapActions.DoQuery(newQuery));
}
}
@ -129,7 +129,29 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
this.selectedFeatures$.next({x:0,y:0,features:[]});
this.selectedFeatures$.next(null);
this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe((state) => {
if(state[1]>0) this.replaceUrl(state[0][1], state[0][0],false);
let queryState = state[0][0];
let mapState = state[0][1];
let urlparts=[];
// TODO: fix this properly move the action to a separte column in itemtypes
if(queryState.itemType && queryState.itemCode) {
let itemType = this.itemTypeService.itemTypes[queryState.itemType];
if (itemType.viewer == "edit_in_editor" && itemType.editor) {
urlparts.push('/editor');
urlparts.push(itemType.editor);
urlparts.push('item');
urlparts.push(queryState.itemCode);
}
if (itemType.viewer == "show_as_featurelist" ) {
queryState.parentCode=queryState.itemCode;
queryState.itemCode=null;
}
}
if(urlparts.length>0) {
this.router.navigate(urlparts);
} else {
if(state[1]>0) this.replaceUrl(mapState, queryState,false);
}
});
}