Kontextmenü Item "POI Bearbeiten", "POI hinzufügen" und "Stützpunkt hinzufügen" ausblenden wenn localStorage Variable "editMode" false ist

This commit is contained in:
ISA
2024-09-09 11:48:43 +02:00
parent 04e50c30f8
commit e1b51f6802
8 changed files with 886 additions and 103 deletions

View File

@@ -29,8 +29,9 @@ export const setupPOIs = async (
setCurrentPoiData,
deviceName
) => {
const editMode = localStorage.getItem("editMode") === "true";
userRights = editMode ? userRights : undefined;
const editMode = localStorage.getItem("editMode") === "true"; // Prüfen, ob der Bearbeitungsmodus aktiv ist
userRights = editMode ? userRights : undefined; // Nur Berechtigungen anwenden, wenn editMode true ist
if (map && poiLayerRef.current) {
map.removeLayer(poiLayerRef.current);
poiLayerRef.current = new L.LayerGroup().addTo(map);
@@ -55,25 +56,30 @@ export const setupPOIs = async (
name: location.name,
description: location.description,
link: location.link,
}).bindContextMenu({
contextmenu: true,
contextmenuWidth: 140,
contextmenuItems: [
{
text: "POI Bearbeiten",
icon: "/img/poi-edit.png",
callback: () => handleEditPoi(marker, userRights, setCurrentPoiData, setShowPoiUpdateModal, fetchPoiData, toast),
},
],
});
// Nur das Kontextmenü "POI Bearbeiten" hinzufügen, wenn editMode true ist
if (editMode) {
marker.bindContextMenu({
contextmenu: true,
contextmenuWidth: 140,
contextmenuItems: [
{
text: "POI Bearbeiten",
icon: "/img/poi-edit.png",
callback: () => handleEditPoi(marker, userRights, setCurrentPoiData, setShowPoiUpdateModal, fetchPoiData, toast),
},
],
});
}
marker.bindPopup(`
<div>
<b class="text-xl text-black-700">${location.description || "Unbekannt"}</b><br>
${deviceName}<br>
${poiTypName}<br>
</div>
`);
<div>
<b class="text-xl text-black-700">${location.description || "Unbekannt"}</b><br>
${deviceName}<br>
${poiTypName}<br>
</div>
`);
marker.on("mouseover", function () {
handlePoiSelect(
@@ -93,9 +99,6 @@ export const setupPOIs = async (
setCurrentPoi(location);
this.openPopup();
// Deaktiviere Polyline-Ereignisse beim Öffnen des Kontextmenüs des Markers
//disablePolylineEvents(window.polylines);
localStorage.setItem("lastElementType", "marker");
localStorage.setItem("markerLink", this.options.link);
});