fix: POI-Bearbeiten-Rechte geprüft, Kontextmenü & Modal korrigiert
- Rechteprüfung auf .some(r => r.IdRight === 56) umgestellt - Bug in PoiUpdateModal behoben (falscher fetchLocationDevices Import) - Modal öffnet sich nur mit gültigem Bearbeitungsrecht - Version auf 1.1.159 erhöht
This commit is contained in:
30
CHANGELOG.md
30
CHANGELOG.md
@@ -4,6 +4,36 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
|
||||
|
||||
---
|
||||
|
||||
## [1.1.159] – 2025-05-23
|
||||
|
||||
### 🐞 Fixed
|
||||
|
||||
- Fehler behoben: `userRights.includes(56)` schlug fehl, da Rechteobjekte `{ IdRight }` enthalten – ersetzt durch `.some(r => r.IdRight === 56)`
|
||||
- Kontextmenü „POI bearbeiten“ wird jetzt korrekt angezeigt
|
||||
- Modal öffnet sich nur noch bei gültiger Berechtigung (56)
|
||||
|
||||
### ✅ Clean
|
||||
|
||||
- Rechteprüfung in `setupPOIs.js` und `poiUtils.js` vereinheitlicht
|
||||
- `handleEditPoi(...)` überprüft jetzt korrekt mit `.some(...)`
|
||||
|
||||
### 💥 Bugfix
|
||||
|
||||
- Fehler `TypeError: fetchLocationDevicesFromDB is not a function` in `PoiUpdateModal.js` behoben
|
||||
- Ursache: falscher Import aus Slice statt Thunk
|
||||
- Lösung: Import auf `fetchLocationDevicesThunk` geändert
|
||||
|
||||
### 🧠 Architektur
|
||||
|
||||
- POI-Rechte über Webservice vollständig in Redux geladen
|
||||
- `PoiUpdateModal.js` verwendet Redux Thunk zur Initialisierung von Location Devices
|
||||
|
||||
### 🔧 Version
|
||||
|
||||
- 📦 Version erhöht auf **1.1.159**
|
||||
|
||||
---
|
||||
|
||||
## [1.1.158] – 2025-05-23
|
||||
|
||||
### ✨ Feature
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// /components/pois/PoiUpdateModal.js
|
||||
import React, { useState, useEffect } from "react";
|
||||
import Select from "react-select"; // Importiere react-select
|
||||
import { fetchLocationDevicesFromDB } from "../../redux/slices/database/locationDevicesFromDBSlice";
|
||||
import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { selectMapLayersState } from "../../redux/slices/mapLayersSlice";
|
||||
|
||||
@@ -40,7 +40,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
||||
const devices = useSelector((state) => state.locationDevicesFromDB.devices);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchLocationDevicesFromDB());
|
||||
dispatch(fetchLocationDevicesThunk());
|
||||
}, [dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.158";
|
||||
export const APP_VERSION = "1.1.160";
|
||||
|
||||
@@ -7,7 +7,8 @@ export const fetchUserRightsService = async () => {
|
||||
const idMap = params.get("m");
|
||||
const idUser = params.get("u");
|
||||
|
||||
const url = `${apiBaseUrl}/GetUserRights?idMap=${idMap}&idUser=${idUser}`;
|
||||
const url = `${apiBaseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`;
|
||||
console.log("🔍 Rechte-Fetch URL:", url);
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
@@ -21,5 +22,6 @@ export const fetchUserRightsService = async () => {
|
||||
}
|
||||
|
||||
const json = await response.json();
|
||||
console.log("👤 Rechte-Response JSON:", json);
|
||||
return json.Rights || [];
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ export const handleEditPoi = (
|
||||
console.log("User Rights includes 56:", userRights.includes(56));
|
||||
|
||||
// Prüfung, ob der Benutzer die notwendigen Rechte hat
|
||||
if (!userRights.includes(56)) {
|
||||
if (!userRights.some((r) => r.IdRight === 56)) {
|
||||
toast.error("Benutzer hat keine Berechtigung zum Bearbeiten.", {
|
||||
position: "top-center",
|
||||
autoClose: 5000,
|
||||
|
||||
@@ -43,7 +43,8 @@ export const setupPOIs = async (
|
||||
try {
|
||||
const { latitude, longitude } = parsePoint(location.position);
|
||||
const poiTypName = poiTypMap.get(location.idPoiTyp) || "Unbekannt";
|
||||
const canDrag = userRights ? userRights.includes(56) : false;
|
||||
const canDrag = userRights ? userRights.some((r) => r.IdRight === 56) : false;
|
||||
|
||||
const matchingIcon = poiData.find((poi) => poi.idPoi === location.idPoi);
|
||||
const iconUrl = matchingIcon ? `/img/icons/pois/${matchingIcon.path}` : "/img/icons/pois/default-icon.png";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user