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 696bf6b..f4b40d0 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 @@ -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); + } }); }