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
### ♻️ Refactor

View File

@@ -1,2 +1,2 @@
// /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,
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,