fix: POI-Typ wird beim Öffnen des Modals korrekt vorausgewählt

- idPoiTyp an Marker übergeben und in handleEditPoi verwendet
- Dropdown-Zuweisung in PoiUpdateModal.js über Redux poiTypData
- Version erhöht auf 1.1.164
This commit is contained in:
Ismail Ali
2025-05-25 11:41:23 +02:00
parent 0d59fff439
commit dd0cad47ae
4 changed files with 46 additions and 18 deletions

View File

@@ -113,10 +113,12 @@ export const handleEditPoi = (
name: marker.options.name,
description: marker.options.description,
idLD: marker.options.idLD,
idPoiTyp: marker.options.idPoiTyp,
});
fetchPoiData(marker.options.id);
setShowPoiUpdateModal(true);
console.log("POI option idPoiTyp:", marker.options.idPoiTyp);
};
//-------------------------------------------------------------------

View File

@@ -15,7 +15,7 @@ import { useDispatch } from "react-redux";
export const setupPOIs = async (
map,
locations,
pois,
poiData,
poiTypMap,
userRights,
@@ -39,13 +39,13 @@ export const setupPOIs = async (
map.removeLayer(poiLayerRef.current);
poiLayerRef.current = new L.LayerGroup().addTo(map);
for (const location of locations) {
for (const poi of pois) {
try {
const { latitude, longitude } = parsePoint(location.position);
const poiTypName = poiTypMap.get(location.idPoiTyp) || "Unbekannt";
const { latitude, longitude } = parsePoint(poi.position);
const poiTypName = poiTypMap.get(poi.idPoiTyp) || "Unbekannt";
const canDrag = userRights ? userRights.some((r) => r.IdRight === 56) : false;
const matchingIcon = poiData.find((poi) => poi.idPoi === location.idPoi);
const matchingIcon = poiData.find((poi) => poi.idPoi === poi.idPoi);
const iconUrl = matchingIcon ? `/img/icons/pois/${matchingIcon.path}` : "/img/icons/pois/default-icon.png";
const marker = L.marker([latitude, longitude], {
@@ -56,11 +56,12 @@ export const setupPOIs = async (
popupAnchor: [1, -34],
}),
draggable: canDrag,
id: location.idPoi,
name: location.name,
description: location.description,
idLD: location.idLD,
link: location.link,
id: poi.idPoi,
name: poi.name,
description: poi.description,
idLD: poi.idLD,
idPoiTyp: poi.idPoiTyp,
link: poi.link,
});
// Nur das Kontextmenü "POI Bearbeiten" hinzufügen, wenn editMode true ist
@@ -80,7 +81,7 @@ export const setupPOIs = async (
marker.bindPopup(`
<div>
<b class="text-xl text-black-700">${location.description || "Unbekannt"}</b><br>
<b class="text-xl text-black-700">${poi.description || "Unbekannt"}</b><br>
${deviceName || "unbekannt"} <br>
${poiTypName}<br>
</div>
@@ -88,16 +89,16 @@ export const setupPOIs = async (
marker.on("mouseover", function () {
console.log("Device Name in setupPOIs.js :", marker); // Debugging
dispatch(setSelectedPoi(location)); // POI in Redux setzen
dispatch(setSelectedPoi(poi)); // POI in Redux setzen
handlePoiSelect(
{
id: location.idPoi,
deviceId: location.idLD,
idPoiTyp: location.idPoiTyp,
id: poi.idPoi,
deviceId: poi.idLD,
idPoiTyp: poi.idPoiTyp,
typ: poiTypName,
description: location.description,
idLD: location.idLD,
description: poi.description,
idLD: poi.idLD,
},
setSelectedPoi,
setLocationDeviceData,