feat: implement map-specific localStorage and TALAS-Kabelstrecken dependency logic

- Add map-specific localStorage keys using URL parameters (m=mapId, u=userId)
- Implement kartenspezifische Sichtbarkeitseinstellungen per Map/User
- Fix localStorage priority over GisSystemStatic Allow values to preserve user settings
- Add bidirectional TALAS ↔ Kabelstrecken dependency logic:
  * Kabelstrecken aktiviert → TALAS automatisch aktiviert
  * TALAS deaktiviert → Kabelstrecken automatisch deaktiviert
- Update mapLayersSlice.js to respect existing localStorage values over system defaults
- Modify MapComponent.js to load map-specific visibility settings on mount
- Update MapLayersControlPanel.js with kartenspezifische localStorage handling
- Fix useDynamicDeviceLayers.js visibility logic (corrected boolean conditions)
- Update useAreaMarkersLayer.js for map-specific localStorage keys

BREAKING CHANGES:
- localStorage structure changed from "mapLayersVisibility" to "mapLayersVisibility_m{mapId}_u{userId}"
- User visibility preferences now have priority over GisSystemStatic Allow values
- TALAS and Kabelstrecken are now logically linked (dependency relationship)

This resolves issues with:
- Map switching losing visibility settings
- Browser reload overriding user preferences with system defaults
- Missing logical connection between TALAS stations and their cable routes
This commit is contained in:
ISA
2025-07-29 10:12:56 +02:00
parent 6d33be56c0
commit d8567a9928
10 changed files with 158 additions and 38 deletions

View File

@@ -22,7 +22,13 @@ const useAreaMarkersLayer = (map, oms, apiUrl, onUpdateSuccess) => {
const updateMarkersVisibility = () => {
if (!map || areaMarkers.length === 0) return;
const mapLayersVisibility = JSON.parse(localStorage.getItem("mapLayersVisibility")) || {};
// Kartenspezifischer localStorage-Key verwenden
const mapId = localStorage.getItem("currentMapId");
const userId = localStorage.getItem("currentUserId");
const mapStorageKey =
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
const mapLayersVisibility = JSON.parse(localStorage.getItem(mapStorageKey)) || {};
const areAllLayersInvisible = Object.values(mapLayersVisibility).every(v => !v);
if (areAllLayersInvisible === prevVisibility.current) return;
@@ -42,7 +48,8 @@ const useAreaMarkersLayer = (map, oms, apiUrl, onUpdateSuccess) => {
updateMarkersVisibility();
const handleStorageChange = event => {
if (event.key === "mapLayersVisibility") {
// Überwache sowohl den alten als auch kartenspezifische Keys
if (event.key === "mapLayersVisibility" || event.key?.startsWith("mapLayersVisibility_")) {
updateMarkersVisibility();
}
};