From 2066cbb9e8a3beccd5de93c757283ee14f2f4af5 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 21 Aug 2025 08:23:36 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Area-Marker=20(Bereiche)=20k=C3=B6nnen?= =?UTF-8?q?=20jetzt=20nur=20noch=20verschoben=20werden,=20wenn=20in=20loca?= =?UTF-8?q?lStorage=20der=20Wert=20"editMode"=20auf=20"true"=20gesetzt=20i?= =?UTF-8?q?st.=20Andernfalls=20sind=20sie=20nicht=20verschiebbar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- .env.production | 2 +- components/area/hooks/useAreaMarkersLayer.js | 39 +++++++++++--------- package-lock.json | 4 +- package.json | 2 +- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.env.development b/.env.development index e8255d536..aa1a85841 100644 --- a/.env.development +++ b/.env.development @@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=true # z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.331 +NEXT_PUBLIC_APP_VERSION=1.1.332 diff --git a/.env.production b/.env.production index 455b96b44..bff09ed9e 100644 --- a/.env.production +++ b/.env.production @@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=false # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.331 +NEXT_PUBLIC_APP_VERSION=1.1.332 diff --git a/components/area/hooks/useAreaMarkersLayer.js b/components/area/hooks/useAreaMarkersLayer.js index bf42cf60a..7d891e1c9 100644 --- a/components/area/hooks/useAreaMarkersLayer.js +++ b/components/area/hooks/useAreaMarkersLayer.js @@ -71,10 +71,11 @@ const useAreaMarkersLayer = (map, oms, apiUrl, onUpdateSuccess) => { const data = await response.json(); + const editMode = localStorage.getItem("editMode") === "true"; const markers = data.map(item => { const marker = L.marker([item.x, item.y], { icon: customIcon, - draggable: true, + draggable: editMode, customType: "areaMarker", }); @@ -88,24 +89,26 @@ const useAreaMarkersLayer = (map, oms, apiUrl, onUpdateSuccess) => { } ); - marker.on("dragend", async e => { - const { lat, lng } = e.target.getLatLng(); - try { - await dispatch( - updateAreaThunk({ - idLocation: item.idLocation, - idMap: item.idMaps, - newCoords: { x: lat, y: lng }, - }) - ).unwrap(); - if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { - console.log("✔️ Koordinaten erfolgreich aktualisiert:", { lat, lng }); + if (editMode) { + marker.on("dragend", async e => { + const { lat, lng } = e.target.getLatLng(); + try { + await dispatch( + updateAreaThunk({ + idLocation: item.idLocation, + idMap: item.idMaps, + newCoords: { x: lat, y: lng }, + }) + ).unwrap(); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("✔️ Koordinaten erfolgreich aktualisiert:", { lat, lng }); + } + onUpdateSuccess?.(); // optionaler Callback + } catch (error) { + console.error("❌ Fehler beim Aktualisieren der Koordinaten:", error); } - onUpdateSuccess?.(); // optionaler Callback - } catch (error) { - console.error("❌ Fehler beim Aktualisieren der Koordinaten:", error); - } - }); + }); + } return marker; }); diff --git a/package-lock.json b/package-lock.json index 43382901c..f87265f7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.331", + "version": "1.1.332", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.331", + "version": "1.1.332", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 01361bcc2..25a2b96a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.331", + "version": "1.1.332", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0",