Fix: addnewpoint-dialog works again

This commit is contained in:
Pieter Vander Vennet 2023-05-21 23:27:01 +02:00
parent 61c417c546
commit 8ed0a32d15
4 changed files with 24 additions and 16 deletions

View file

@ -45,8 +45,8 @@
visible.setData(false)
}
function getPref(type: CategoryType): UIEventSource<string> {
return userstate.osmConnection.GetPreference("preferred-layer-" + type)
function getPref(type: CategoryType): undefined | UIEventSource<string> {
return userstate?.osmConnection?.GetPreference("preferred-layer-" + type)
}
</script>

View file

@ -17,7 +17,7 @@
let dispatch = createEventDispatcher<{appliedLayer}>()
export let favourite : UIEventSource<string> = undefined
export let favourite : UIEventSource<string> | undefined = undefined
let rasterLayer = new UIEventSource<RasterLayerPolygon>(availableLayers.data?.[0])
@ -39,11 +39,11 @@
}
rasterLayer.setData(fav)
}))
}
onDestroy(rasterLayer.addCallbackAndRunD(selected => {
favourite?.setData(selected.properties.id)
}))
onDestroy(rasterLayer.addCallbackAndRunD(selected => {
favourite?.setData(selected.properties.id)
}))
}
let rasterLayerOnMap = UIEventSource.feedFrom(rasterLayer)

View file

@ -31,7 +31,8 @@
import BackButton from "../../Base/BackButton.svelte";
import ToSvelte from "../../Base/ToSvelte.svelte";
import Svg from "../../../Svg";
import RasterLayerOverview from "../../Map/RasterLayerOverview.svelte";
import MapControlButton from "../../Base/MapControlButton.svelte";
import {Square3Stack3dIcon} from "@babeard/svelte-heroicons/solid";
export let coordinate: { lon: number, lat: number };
export let state: SpecialVisualizationState;
@ -197,7 +198,8 @@
<EyeOffIcon class="w-12"/>
<Tr t={Translations.t.general.add.disableFilters}/>
</button>
<button class="flex w-full gap-x-1" on:click={() => {abort();state.guistate.openFilterView(selectedPreset.layer)}}>
<button class="flex w-full gap-x-1"
on:click={() => {abort();state.guistate.openFilterView(selectedPreset.layer)}}>
<ToSvelte construct={Svg.layers_svg().SetClass("w-12")}/>
<Tr t={Translations.t.general.add.openLayerControl}/>
</button>
@ -263,11 +265,16 @@
<Tr slot="message" t={Translations.t.general.cancel}/>
</SubtleButton>
{:else if !creating}
<div class="w-full p-1">
<div class="relative w-full p-1">
<div class="w-full h-96 max-h-screen rounded-xl overflow-hidden">
<NewPointLocationInput value={preciseCoordinate} snappedTo={snappedToObject} {state} {coordinate}
targetLayer={selectedPreset.layer}
snapToLayers={selectedPreset.preset.preciseInput.snapToLayers}/>
<NewPointLocationInput value={preciseCoordinate} snappedTo={snappedToObject} {state} {coordinate}
targetLayer={selectedPreset.layer}
snapToLayers={selectedPreset.preset.preciseInput.snapToLayers}/>
</div>
<div class="absolute bottom-0 left-0 p-4">
<MapControlButton on:click={() => state.guistate.backgroundLayerSelectionIsOpened.setData(true)}>
<Square3Stack3dIcon class="w-6 h-6"/>
</MapControlButton>
</div>
</div>
<div class="flex flex-wrap-reverse md:flex-nowrap">
@ -282,9 +289,7 @@
</div>
</NextButton>
</div>
<RasterLayerOverview />
{:else}
<Loading>Creating point...</Loading>
{/if}

View file

@ -14,6 +14,7 @@ import LayerConfig from "../Models/ThemeConfig/LayerConfig";
import FeatureSwitchState from "../Logic/State/FeatureSwitchState";
import { MenuState } from "../Models/MenuState";
import OsmObjectDownloader from "../Logic/Osm/OsmObjectDownloader";
import {RasterLayerPolygon} from "../Models/RasterLayers";
/**
* The state needed to render a special Visualisation.
@ -69,6 +70,8 @@ export interface SpecialVisualizationState {
readonly preferencesAsTags: Store<Record<string, string>>
}
readonly lastClickObject: WritableFeatureSource
readonly availableLayers: Store<RasterLayerPolygon[]>
}
export interface SpecialVisualization {