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

@@ -4,6 +4,31 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
--- ---
## [1.1.164] 2025-05-23
### 🐞 Fixed
- POI-Typ wurde beim Öffnen des Modals nicht korrekt im Dropdown angezeigt
- Ursache: `idPoiTyp` fehlte in `marker.options`
- Lösung: `idPoiTyp` im `setupPOIs.js` an Marker übergeben und in `handleEditPoi()` verwendet
### ✅ Clean
- `poiUtils.js` und `setupPOIs.js` um konsistente Übergabe von Marker-Metadaten erweitert
- Berechtigungsprüfung in `handleEditPoi()` auf `.some(r => r.IdRight === 56)` umgestellt
- `PoiUpdateModal.js` vollständig refaktoriert mit klarer Zustandstrennung
### 🧠 Architektur
- POI-Typ Auswahl basiert nun vollständig auf Redux-Daten (`poiTypSlice`)
- keine hartcodierten Dropdown-Initialwerte mehr vollständig datengetrieben
### 🔧 Version
- 📦 Version erhöht auf **1.1.164**
---
## [1.1.162] 2025-05-23 ## [1.1.162] 2025-05-23
### ♻️ Refactor ### ♻️ Refactor

View File

@@ -1,2 +1,2 @@
// /config/appVersion // /config/appVersion
export const APP_VERSION = "1.1.164"; export const APP_VERSION = "1.1.165";

View File

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