From c0f689331ec1a389f045d073488617c00b877481 Mon Sep 17 00:00:00 2001 From: Mark van der Wal Date: Wed, 15 Jul 2020 23:15:31 +0200 Subject: [PATCH] Added parentitem title to geotiff, shape and temporal selected-item components. --- .../src/fm-map/actions/map.actions.ts | 2 +- .../fm-map/components/map/map.component.html | 11 +-- .../fm-map/components/map/map.component.ts | 69 ++++++++++--------- .../selected-item-container.component.ts | 10 +-- .../selected-item-geotiff.component.html | 8 ++- .../selected-item-shape.component.html | 3 +- .../selected-item-temporal.component.html | 1 + .../selected-item/selected-item.component.ts | 5 +- .../src/fm-map/effects/map.effects.ts | 50 +++++++++----- .../src/fm-map/reducers/map.reducer.ts | 48 +++++++------ 10 files changed, 117 insertions(+), 90 deletions(-) diff --git a/projects/common-map/src/fm-map/actions/map.actions.ts b/projects/common-map/src/fm-map/actions/map.actions.ts index 0658192..260e955 100644 --- a/projects/common-map/src/fm-map/actions/map.actions.ts +++ b/projects/common-map/src/fm-map/actions/map.actions.ts @@ -105,7 +105,7 @@ export class SelectItem implements Action { export class SelectItemSuccess implements Action { readonly type = SELECTITEMSUCCESS; - constructor(public item: IItem) { } + constructor(public item: IItem, public parentItem: IItem) { } } export class SelectTemporalItemsSuccess implements Action { diff --git a/projects/common-map/src/fm-map/components/map/map.component.html b/projects/common-map/src/fm-map/components/map/map.component.html index ddead55..2b71672 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.html +++ b/projects/common-map/src/fm-map/components/map/map.component.html @@ -12,6 +12,7 @@ panelCollapsed:panelCollapsed$|async, searchMinified:searchMinified$|async, selectedItem:selectedItem$|async, + parentItem:parentItem$|async, queryState:queryState$|async, searchCollapsed:searchCollapsed$|async, clearEnabled:clearEnabled$|async, @@ -20,9 +21,9 @@ styles:styles$|async, selectedFeature:selectedFeature$|async } as state"> - +
- +
@@ -51,13 +52,13 @@
- +
- +
- +
Cannot find {{state.queryState?.query}}
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 f190621..b7f2d3f 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 @@ -64,6 +64,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { public selectedFeature$: Observable = this.store.select(mapReducers.selectGetSelectedFeature); public clickedFeature: Subject = new Subject(); public selectedItem$: Observable = this.store.select(mapReducers.selectGetSelectedItem); + public parentItem$: Observable =this.store.select(mapReducers.selectGetParentItem); public queryState$: Observable = this.store.select(mapReducers.selectGetQueryState); public state$:Observable<{mapState:IMapState,queryState:IQueryState,setStateCount:number}> = this.store.select(mapReducers.selectGetState); public period$: Observable = this.store.select(mapReducers.selectGetPeriod); @@ -82,14 +83,14 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { private lastUrl = ""; @ViewChild('map') map; - - constructor(private store: Store, - private route: ActivatedRoute, + + constructor(private store: Store, + private route: ActivatedRoute, private router: Router, - private uploadService: ResumableFileUploadService, - private serializeService: StateSerializerService, - public itemTypeService: ItemTypeService, - private location: Location, + private uploadService: ResumableFileUploadService, + private serializeService: StateSerializerService, + public itemTypeService: ItemTypeService, + private location: Location, private geolocationService: GeolocationService, private zone: NgZone, private deviceorientationService:DeviceOrientationService) { @@ -98,29 +99,29 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { let newQueryState = tassign(mapReducers.initialQueryState); console.debug(`Do Query ${setStateCount}`); let urlparts=[]; - if (queryState.itemCode && queryState.itemCode != "") { + if (queryState.itemCode && queryState.itemCode != "") { if(queryState.itemType && queryState.itemType!= "") { let itemType = this.itemTypeService.itemTypes[queryState.itemType]; if (itemType && itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) { urlparts.push('/editor'); urlparts.push(itemType.editor); urlparts.push('item'); - urlparts.push(queryState.itemCode); - } - } + urlparts.push(queryState.itemCode); + } + } } else { newQueryState= queryState; } - if(urlparts.length==0 ) { + if(urlparts.length==0 ) { newQueryState.itemCode = queryState.itemCode; this.zone.run(() => { this.store.dispatch(new mapActions.SetQueryState(newQueryState,false)); }) } else { this.router.navigate(urlparts); - } + } } - }); + }); } @HostListener('document:keyup', ['$event']) @@ -159,7 +160,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { console.debug("Init"); this.store.dispatch(new mapActions.Clear()); this.selectedFeatures$.next({x:0,y:0,features:[]}); - this.selectedFeatures$.next(null); + this.selectedFeatures$.next(null); } initCustomStyles() { @@ -203,8 +204,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { normalizeMapState(mapState:IMapState):IMapState { if(!mapState) return null; - return {zoom: this.round(mapState.zoom,0), - rotation: this.round(mapState.rotation,2), + return {zoom: this.round(mapState.zoom,0), + rotation: this.round(mapState.rotation,2), xCenter: this.round(mapState.xCenter,5), yCenter: this.round(mapState.yCenter,5), baseLayerCode: mapState.baseLayerCode }; @@ -219,7 +220,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { let queryState = params.get("queryState"); var newQueryState = tassign(mapReducers.initialQueryState); if (queryState != "") { - newQueryState = this.serializeService.deserialize(queryState); + newQueryState = this.serializeService.deserialize(queryState); } return newQueryState; } else { @@ -227,16 +228,16 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { } } - ngAfterViewInit() { + ngAfterViewInit() { console.debug("View init"); - this.initCustomStyles(); + this.initCustomStyles(); // url to state this.paramSub = this.route.paramMap.pipe(withLatestFrom(this.state$),switchMap(([params,state]) => { var newMapState: IMapState = state.mapState; var newQueryState: IQueryState = state.queryState; - + var queryStateChanged = false; var mapStateChanged = false; let urlMapState = this.getMapStateFromUrl(params); @@ -250,7 +251,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { newQueryState = urlQueryState; queryStateChanged = this.serializeService.serialize(state.queryState) != this.serializeService.serialize(urlQueryState); } - + if(queryStateChanged && mapStateChanged && state.setStateCount ==0) { return of(new mapActions.SetState(newMapState,newQueryState)); window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(newMapState)); @@ -258,16 +259,16 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { return of(new mapActions.SetQueryState(newQueryState)); } return of(new mapActions.SetReplaceUrl(true)); })).subscribe((action) => { - if(action) { + if(action) { this.zone.run(() => { console.debug("Url to state"); - this.store.dispatch(action); - }); + this.store.dispatch(action); + }); } }); // state to url - + this.stateSub = this.state$.pipe(switchMap((state) => { let newUrl = this.serializeMapState(state.mapState) + "_" + this.serializeService.serialize(state.queryState); if(this.lastUrl!=newUrl && state.setStateCount>0) { @@ -276,13 +277,13 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { } else { return of(null); - } + } })).subscribe((newUrlState) =>{ if(newUrlState) { console.debug(`State to url ${newUrlState.setStateCount}`); this.replaceUrl(newUrlState.mapState,newUrlState.queryState,newUrlState.replaceUrl); } - }); + }); setTimeout(() => { this.map.instance.updateSize(); @@ -315,7 +316,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { event.preventDefault(); var queryState = tassign(mapReducers.initialQueryState, query); this.store.dispatch(new mapActions.DoQuery(queryState)); - } + } replaceUrl(mapState: IMapState, queryState: IQueryState, replace: boolean = true) { let parts =["."]; @@ -328,7 +329,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { parts.push( this.serializeService.serialize(queryState)); console.debug("Replace url",parts); this.router.navigate(parts, { replaceUrl: replace,relativeTo:this.route.parent }); - } + } } handleOnMoveEnd(event) { @@ -350,7 +351,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { this.store.dispatch(new mapActions.SetViewExtent(state.extent)); } }); - }); + }); } handleOnMouseDown(event: MouseEvent) { @@ -366,7 +367,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { handleClearSearch(event) { this.store.dispatch(new commonActions.Escape(true, false)); - } + } handleOnDelete(itemLayer: IItemLayer) { this.store.dispatch(new mapActions.RemoveLayer(itemLayer)); @@ -385,7 +386,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { extend(extent, itemLayer.layer.getExtent()); if (extent) { this.store.dispatch(new mapActions.SetExtent(extent)); - } + } } handleSelectBaseLayer(itemLayer: IItemLayer) { @@ -400,7 +401,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { if (this.paramSub) this.paramSub.unsubscribe(); if (this.itemTypeSub) this.itemTypeSub.unsubscribe(); if (this.stateSub) this.stateSub.unsubscribe(); - if (this.queryStateSub) this.queryStateSub.unsubscribe(); + if (this.queryStateSub) this.queryStateSub.unsubscribe(); if (this.querySub) this.querySub.unsubscribe(); } } diff --git a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts b/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts index f4e1db4..c86b87e 100644 --- a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts +++ b/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts @@ -8,7 +8,7 @@ import { IItemLayer } from '../../models/item.layer'; @Component({ selector: 'fm-map-selected-item-container', templateUrl: './selected-item-container.component.html', - styleUrls: ['./selected-item-container.component.scss'] + styleUrls: ['./selected-item-container.component.scss'] }) export class SelectedItemContainerComponent { @@ -16,10 +16,11 @@ export class SelectedItemContainerComponent { } @Input() item: IItem; + @Input() parentItem: IItem; @Input() itemLayer:IItemLayer; @Input() overlayLayers:Array; - @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; + @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; loadComponent() { let componentFactory: ComponentFactory = this.componentFactoryResolver.resolveComponentFactory(SelectedItemComponent); // default @@ -42,14 +43,14 @@ export class SelectedItemContainerComponent { matches++; } } - + if(criteria==matches && matches > maxMatches) { selected=i; maxMatches = matches; } } if (selected >= 0) { - componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.selectedItemComponents[selected]['constructor'] as any); + componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.selectedItemComponents[selected]['constructor'] as any); } const viewContainerRef = this.widgetHost.viewContainerRef; @@ -57,6 +58,7 @@ export class SelectedItemContainerComponent { const componentRef = viewContainerRef.createComponent(componentFactory); (componentRef.instance).item = this.item; + (componentRef.instance).parentItem = this.parentItem; (componentRef.instance).itemLayer = this.itemLayer; (componentRef.instance).overlayLayers = this.overlayLayers; } diff --git a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html b/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html index 9b1412b..bf71d71 100644 --- a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html +++ b/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html @@ -4,7 +4,8 @@
- +