Re-enable button, add setting to choose how to add new features

This commit is contained in:
Pieter Vander Vennet 2024-06-21 02:36:36 +02:00
parent 25ff4b3a8c
commit 1acb645beb
12 changed files with 124 additions and 110 deletions

View file

@ -12,6 +12,7 @@
import Delete_icon from "../../assets/svg/Delete_icon.svelte"
import BackButton from "../Base/BackButton.svelte"
import TagRenderingEditableDynamic from "../Popup/TagRendering/TagRenderingEditableDynamic.svelte"
import { LastClickFeatureSource } from "../../Logic/FeatureSource/Sources/LastClickFeatureSource"
export let state: SpecialVisualizationState
export let selectedElement: Feature
@ -25,7 +26,7 @@
if (properties.id === "settings") {
return UserRelatedState.usersettingsConfig
}
if (properties.id === "new_point_dialog") {
if (properties.id.startsWith(LastClickFeatureSource.newPointElementId)) {
return state.layout.layers.find((l) => l.id === "last_click")
}
if (properties.id === "location_track") {

View file

@ -148,10 +148,8 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
map.on("click", (e) => {
handleClick(e)
})
map.on("contextmenu", (e) => {
// This one only works on desktop
handleClick(e, "right")
})
// map.on("contextmenu", ...) only works on desktop, hence we listen to the container:
map._container.addEventListener("contextmenu", (e) => {
const lngLat = map.unproject([e.x, e.y])

View file

@ -108,7 +108,7 @@
if (element.properties.id.startsWith("current_view")) {
return currentViewLayer
}
if (element.properties.id === "new_point_dialog") {
if (element.properties.id.startsWith(LastClickFeatureSource.newPointElementId)) {
return layout.layers.find((l) => l.id === "last_click")
}
if (element.properties.id === "location_track") {
@ -206,6 +206,7 @@
}
let openFilterButton: UIEventSource<HTMLElement> = new UIEventSource<HTMLElement>(undefined)
let openBackgroundButton: UIEventSource<HTMLElement> = new UIEventSource<HTMLElement>(undefined)
let addNewFeatureMode = state.userRelatedState.addNewFeatureMode
</script>
<main>
@ -306,7 +307,7 @@
<div class="flex w-full items-end justify-between px-4">
<div class="flex flex-col">
<If condition={featureSwitches.featureSwitchEnableLogin}>
{#if (state.layout.hasPresets() && state.layout.enableAddNewPoints) || state.layout.hasNoteLayer()}
{#if $addNewFeatureMode.indexOf("button") >= 0 && ((state.layout.hasPresets() && state.layout.enableAddNewPoints) || state.layout.hasNoteLayer())}
<button
class="low-interaction pointer-events-auto w-fit"
class:disabled={$currentZoom < Constants.minZoomLevelToAddNewPoint}