Feature: add possibility to have a title when opening the popup as FloatOver

This commit is contained in:
Pieter Vander Vennet 2024-04-12 15:03:45 +02:00
parent 58dfb93818
commit 5424932f1a
4 changed files with 21 additions and 11 deletions

View file

@ -219,12 +219,13 @@ export interface LayerConfigJson {
* *
* If set, open the selectedElementView in a floatOver instead of on the right. * If set, open the selectedElementView in a floatOver instead of on the right.
* *
* iftrue: show the infobox in the splashscreen floating over the entire UI * iftrue: show the infobox in the splashscreen floating over the entire UI; hide the title bar
* iffalse: show the infobox in a sidebar on the right * iffalse: show the infobox in a sidebar on the right
* suggestions: return [{if: "value=title", then: "Show in a floatover and show the title bar"}]
* group: advanced * group: advanced
* default: sidebar * default: sidebar
*/ */
popupInFloatover?: boolean popupInFloatover?: boolean | "title" | string
/** /**
* Small icons shown next to the title. * Small icons shown next to the title.

View file

@ -66,7 +66,7 @@ export default class LayerConfig extends WithContextLoader {
public readonly syncSelection: (typeof LayerConfig.syncSelectionAllowed)[number] // this is a trick to conver a constant array of strings into a type union of these values public readonly syncSelection: (typeof LayerConfig.syncSelectionAllowed)[number] // this is a trick to conver a constant array of strings into a type union of these values
public readonly _needsFullNodeDatabase: boolean public readonly _needsFullNodeDatabase: boolean
public readonly popupInFloatover public readonly popupInFloatover: boolean | string
constructor(json: LayerConfigJson, context?: string, official: boolean = true) { constructor(json: LayerConfigJson, context?: string, official: boolean = true) {
context = context + "." + json.id context = context + "." + json.id

View file

@ -65,6 +65,8 @@
</div> </div>
{/if} {/if}
</div> </div>
<slot name="close-button">
<button <button
class="mt-2 h-fit shrink-0 rounded-full border-none p-0" class="mt-2 h-fit shrink-0 rounded-full border-none p-0"
on:click={() => state.selectedElement.setData(undefined)} on:click={() => state.selectedElement.setData(undefined)}
@ -73,6 +75,7 @@
> >
<XCircleIcon aria-hidden={true} class="h-8 w-8" /> <XCircleIcon aria-hidden={true} class="h-8 w-8" />
</button> </button>
</slot>
</div> </div>
<style> <style>

View file

@ -18,7 +18,7 @@
EyeIcon, EyeIcon,
HeartIcon, HeartIcon,
MenuIcon, MenuIcon,
XCircleIcon, XCircleIcon
} from "@rgossiaux/svelte-heroicons/solid" } from "@rgossiaux/svelte-heroicons/solid"
import Tr from "./Base/Tr.svelte" import Tr from "./Base/Tr.svelte"
import CommunityIndexView from "./BigComponents/CommunityIndexView.svelte" import CommunityIndexView from "./BigComponents/CommunityIndexView.svelte"
@ -102,14 +102,14 @@
if (element.properties.id.startsWith("current_view")) { if (element.properties.id.startsWith("current_view")) {
return currentViewLayer return currentViewLayer
} }
if(element.properties.id === "new_point_dialog"){ if (element.properties.id === "new_point_dialog") {
return layout.layers.find(l => l.id === "last_click") return layout.layers.find(l => l.id === "last_click")
} }
if(element.properties.id === "location_track"){ if (element.properties.id === "location_track") {
return layout.layers.find(l => l.id === "gps_track") return layout.layers.find(l => l.id === "gps_track")
} }
return state.layout.getMatchingLayer(element.properties) return state.layout.getMatchingLayer(element.properties)
}, }
) )
let currentZoom = state.mapProperties.zoom let currentZoom = state.mapProperties.zoom
let showCrosshair = state.userRelatedState.showCrosshair let showCrosshair = state.userRelatedState.showCrosshair
@ -117,8 +117,9 @@
let viewport: UIEventSource<HTMLDivElement> = new UIEventSource<HTMLDivElement>(undefined) let viewport: UIEventSource<HTMLDivElement> = new UIEventSource<HTMLDivElement>(undefined)
let mapproperties: MapProperties = state.mapProperties let mapproperties: MapProperties = state.mapProperties
state.mapProperties.installCustomKeyboardHandler(viewport) state.mapProperties.installCustomKeyboardHandler(viewport)
let canZoomIn = mapproperties.maxzoom.map(mz => mapproperties.zoom.data < mz, [mapproperties.zoom] ) let canZoomIn = mapproperties.maxzoom.map(mz => mapproperties.zoom.data < mz, [mapproperties.zoom])
let canZoomOut = mapproperties.minzoom.map(mz => mapproperties.zoom.data > mz, [mapproperties.zoom] ) let canZoomOut = mapproperties.minzoom.map(mz => mapproperties.zoom.data > mz, [mapproperties.zoom])
function updateViewport() { function updateViewport() {
const rect = viewport.data?.getBoundingClientRect() const rect = viewport.data?.getBoundingClientRect()
if (!rect) { if (!rect) {
@ -132,7 +133,7 @@
const bottomRight = mlmap.unproject([rect.right, rect.bottom]) const bottomRight = mlmap.unproject([rect.right, rect.bottom])
const bbox = new BBox([ const bbox = new BBox([
[topLeft.lng, topLeft.lat], [topLeft.lng, topLeft.lat],
[bottomRight.lng, bottomRight.lat], [bottomRight.lng, bottomRight.lat]
]) ])
state.visualFeedbackViewportBounds.setData(bbox) state.visualFeedbackViewportBounds.setData(bbox)
} }
@ -419,7 +420,12 @@
state.selectedElement.setData(undefined) state.selectedElement.setData(undefined)
}} }}
> >
<div class="flex h-full w-full"> <div class="flex flex-col h-full w-full">
{#if $selectedLayer.popupInFloatover === "title"}
<SelectedElementTitle {state} layer={$selectedLayer} selectedElement={$selectedElement} >
<span slot="close-button"/>
</SelectedElementTitle>
{/if}
<SelectedElementView {state} layer={$selectedLayer} selectedElement={$selectedElement} /> <SelectedElementView {state} layer={$selectedLayer} selectedElement={$selectedElement} />
</div> </div>
</FloatOver> </FloatOver>