Fix: use proper selected element

This commit is contained in:
Pieter Vander Vennet 2024-09-02 03:39:40 +02:00
parent 8dd7f34ad7
commit dbff953096

View file

@ -14,7 +14,7 @@
import Geosearch from "./BigComponents/Geosearch.svelte" import Geosearch from "./BigComponents/Geosearch.svelte"
import Translations from "./i18n/Translations" import Translations from "./i18n/Translations"
import { import {
MenuIcon MenuIcon,
} from "@rgossiaux/svelte-heroicons/solid" } from "@rgossiaux/svelte-heroicons/solid"
import Tr from "./Base/Tr.svelte" import Tr from "./Base/Tr.svelte"
import FloatOver from "./Base/FloatOver.svelte" import FloatOver from "./Base/FloatOver.svelte"
@ -46,10 +46,12 @@
import SelectedElementPanel from "./Base/SelectedElementPanel.svelte" import SelectedElementPanel from "./Base/SelectedElementPanel.svelte"
import MenuDrawer from "./BigComponents/MenuDrawer.svelte" import MenuDrawer from "./BigComponents/MenuDrawer.svelte"
import DrawerLeft from "./Base/DrawerLeft.svelte" import DrawerLeft from "./Base/DrawerLeft.svelte"
import Hash from "../Logic/Web/Hash"
export let state: ThemeViewState export let state: ThemeViewState
let layout = state.layout let layout = state.layout
let maplibremap: UIEventSource<MlMap> = state.map let maplibremap: UIEventSource<MlMap> = state.map
let state_selectedElement = state.selectedElement
let selectedElement: UIEventSource<Feature> = new UIEventSource<Feature>(undefined) let selectedElement: UIEventSource<Feature> = new UIEventSource<Feature>(undefined)
let compass = Orientation.singleton.alpha let compass = Orientation.singleton.alpha
let compassLoaded = Orientation.singleton.gotMeasurement let compassLoaded = Orientation.singleton.gotMeasurement
@ -71,6 +73,7 @@
}) })
}) })
let selectedLayer: Store<LayerConfig> = state.selectedElement.mapD((element) => { let selectedLayer: Store<LayerConfig> = state.selectedElement.mapD((element) => {
const id = element.properties.id const id = element.properties.id
if (id.startsWith("current_view")) { if (id.startsWith("current_view")) {
@ -97,11 +100,11 @@
state.mapProperties.installCustomKeyboardHandler(viewport) state.mapProperties.installCustomKeyboardHandler(viewport)
let canZoomIn = mapproperties.maxzoom.map( let canZoomIn = mapproperties.maxzoom.map(
(mz) => mapproperties.zoom.data < mz, (mz) => mapproperties.zoom.data < mz,
[mapproperties.zoom] [mapproperties.zoom],
) )
let canZoomOut = mapproperties.minzoom.map( let canZoomOut = mapproperties.minzoom.map(
(mz) => mapproperties.zoom.data > mz, (mz) => mapproperties.zoom.data > mz,
[mapproperties.zoom] [mapproperties.zoom],
) )
function updateViewport() { function updateViewport() {
@ -117,7 +120,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)
} }
@ -137,7 +140,7 @@
onDestroy( onDestroy(
rasterLayer.addCallbackAndRunD((l) => { rasterLayer.addCallbackAndRunD((l) => {
rasterLayerName = l.properties.name rasterLayerName = l.properties.name
}) }),
) )
let previewedImage = state.previewedImage let previewedImage = state.previewedImage
let addNewFeatureMode = state.userRelatedState.addNewFeatureMode let addNewFeatureMode = state.userRelatedState.addNewFeatureMode
@ -166,6 +169,7 @@
animation?.cameraAnimation(mlmap) animation?.cameraAnimation(mlmap)
} }
let hash = Hash.hash
</script> </script>
<main> <main>
@ -217,6 +221,11 @@
</MapControlButton> </MapControlButton>
</div> </div>
{#if $debug && $hash}
<div class="alert">
{$hash}
</div>
{/if}
<If condition={state.featureSwitches.featureSwitchSearch}> <If condition={state.featureSwitches.featureSwitchSearch}>
<div class="w-full sm:w-64 my-2 sm:mt-0"> <div class="w-full sm:w-64 my-2 sm:mt-0">
@ -415,11 +424,11 @@
<!-- right modal with the selected element view --> <!-- right modal with the selected element view -->
<ModalRight <ModalRight
on:close={() => { on:close={() => {
selectedElement.setData(undefined) state.selectedElement.setData(undefined)
}} }}
> >
<div slot="close-button" /> <div slot="close-button" />
<SelectedElementPanel {state} selected={$selectedElement} /> <SelectedElementPanel {state} selected={$state_selectedElement} />
</ModalRight> </ModalRight>
{/if} {/if}
@ -433,7 +442,7 @@
}} }}
> >
<span slot="close-button" /> <span slot="close-button" />
<SelectedElementPanel absolute={false} {state} selected={$selectedElement} /> <SelectedElementPanel absolute={false} {state} selected={$state_selectedElement} />
</FloatOver> </FloatOver>
{:else} {:else}
<FloatOver <FloatOver
@ -441,7 +450,7 @@
state.selectedElement.setData(undefined) state.selectedElement.setData(undefined)
}} }}
> >
<SelectedElementView {state} layer={$selectedLayer} selectedElement={$selectedElement} /> <SelectedElementView {state} layer={$selectedLayer} selectedElement={$state_selectedElement} />
</FloatOver> </FloatOver>
{/if} {/if}
{/if} {/if}