diff --git a/.env.development b/.env.development index 51e62e442..c2138dc69 100644 --- a/.env.development +++ b/.env.development @@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=true NEXT_PUBLIC_BASE_PATH=/talas5 # Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH= # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.312 +NEXT_PUBLIC_APP_VERSION=1.1.313 diff --git a/.env.production b/.env.production index 2a812a925..b382fa16f 100644 --- a/.env.production +++ b/.env.production @@ -26,4 +26,4 @@ NEXT_PUBLIC_BASE_PATH=/talas5 # Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH= # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.312 +NEXT_PUBLIC_APP_VERSION=1.1.313 diff --git a/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js b/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js index 5cea2371d..f10b87907 100644 --- a/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js +++ b/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js @@ -31,7 +31,7 @@ function MapLayersControlPanel() { console.log("🎯 kabelstreckenVisible state changed to:", kabelstreckenVisible); }, [kabelstreckenVisible]); - // Prüfen, ob TALAS (IdSystem 1) erlaubt ist + // Prüfen, ob TALAS (IdSystem 1) erlaubt & sichtbar auf Karte (Allow + Map) const isTalasAllowed = Array.isArray(GisSystemStatic) ? GisSystemStatic.some( system => system.IdSystem === 1 && system.Allow === 1 && system.Map === 1 @@ -134,18 +134,23 @@ function MapLayersControlPanel() { dispatch(setLayerVisibility({ layer: key, visibility: parsedVisibility[key] })); }); } else { - // Initialisiere mapLayersVisibility basierend auf GisSystemStatic Allow-Werten - console.log("🚀 No stored mapLayersVisibility found, initializing based on Allow values..."); + // Initialisiere mapLayersVisibility basierend auf Allow & Map (nur Systeme mit Map===1 anzeigen) + console.log( + "🚀 No stored mapLayersVisibility found, initializing based on Allow && Map values..." + ); if (Array.isArray(GisSystemStatic)) { const initialVisibility = {}; GisSystemStatic.forEach(system => { const systemKey = `system-${system.IdSystem}`; - const visibility = system.Allow === 1; - initialVisibility[systemKey] = visibility; - dispatch(setLayerVisibility({ layer: systemKey, visibility })); - console.log( - `🎯 Setting ${systemKey} (${system.Name}) visibility to ${visibility} (Allow=${system.Allow})` - ); + const visibility = system.Allow === 1 && system.Map === 1; // <— angepasst + if (visibility) { + // nur speichern wenn grundsätzlich sichtbar + initialVisibility[systemKey] = visibility; + dispatch(setLayerVisibility({ layer: systemKey, visibility })); + console.log( + `🎯 Setting ${systemKey} (${system.Name}) visibility to ${visibility} (Allow=${system.Allow}, Map=${system.Map})` + ); + } }); localStorage.setItem(mapStorageKey, JSON.stringify(initialVisibility)); console.log(`💾 Saved initial mapLayersVisibility to ${mapStorageKey}:`, initialVisibility); @@ -159,9 +164,6 @@ function MapLayersControlPanel() { setLocalStorageLoaded(true); }, []); // Läuft nur beim Mount - // Entferne den komplexen Konsistenz-Check useEffect - nicht mehr nötig - // da wir direkt mit localStorage arbeiten - const handleAreaChange = event => { const selectedIndex = event.target.options.selectedIndex; const areaName = event.target.options[selectedIndex].text; @@ -169,8 +171,13 @@ function MapLayersControlPanel() { }; useEffect(() => { + // Allowed systems jetzt nach Allow && Map filtern const allowedSystems = Array.isArray(GisSystemStatic) - ? new Set(GisSystemStatic.filter(system => system.Allow === 1).map(system => system.IdSystem)) + ? new Set( + GisSystemStatic.filter(system => system.Allow === 1 && system.Map === 1).map( + system => system.IdSystem + ) + ) : new Set(); const seenNames = new Set(); @@ -194,7 +201,7 @@ function MapLayersControlPanel() { const seenSystemNames = new Set(); const filteredSystems = Array.isArray(GisSystemStatic) ? GisSystemStatic.filter(item => { - const isUnique = !seenSystemNames.has(item.Name) && item.Allow === 1; + const isUnique = !seenSystemNames.has(item.Name) && item.Allow === 1 && item.Map === 1; // <— Map Bedingung hinzugefügt if (isUnique) { seenSystemNames.add(item.Name); } @@ -205,8 +212,8 @@ function MapLayersControlPanel() { setSystemListing( filteredSystems.map((system, index) => ({ id: index + 1, - name: system.Name, // Verwende den Originalnamen für die Anzeige - key: `system-${system.IdSystem}`, // Internen Schlüssel für die MapLayersVisibility-Logik + name: system.Name, // Anzeige + key: `system-${system.IdSystem}`, // interner Schlüssel })) ); }, [GisStationsStaticDistrict, GisSystemStatic]); @@ -328,13 +335,14 @@ function MapLayersControlPanel() { style={{ minWidth: "150px", maxWidth: "200px" }} > - {[ + {/* ...new Map( (GisStationsStaticDistrict.Points || []) .filter(p => !!p.Area_Name) .map(p => [p.Area_Name, p]) ).values(), - ].map((item, index) => ( + */} + {GisStationsStaticDistrict.Points.filter(p => !!p.Area_Name).map((item, index) => ( @@ -399,25 +407,6 @@ function MapLayersControlPanel() { POIs - - {/* Areas -
- - -
- */} - - {/* Standorte -
- - -
- - */} diff --git a/package-lock.json b/package-lock.json index 782a0d684..bc74f81db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.312", + "version": "1.1.313", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.312", + "version": "1.1.313", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 107287c6d..cab789aea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.312", + "version": "1.1.313", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/redux/slices/mapLayersSlice.js b/redux/slices/mapLayersSlice.js index 07f673346..cacfbf79c 100644 --- a/redux/slices/mapLayersSlice.js +++ b/redux/slices/mapLayersSlice.js @@ -15,12 +15,11 @@ const mapLayersSlice = createSlice({ }, setLayerVisibility: (state, action) => { const { layer, visibility } = action.payload; - state[layer] = visibility; // Entferne die Bedingung, um sicherzustellen, dass Werte gesetzt werden + state[layer] = visibility; // Sicher setzen }, setInitialLayers: (state, action) => { const systems = action.payload; // Array of GisSystem - // Versuche kartenspezifische localStorage-Werte zu laden const mapId = typeof localStorage !== "undefined" ? localStorage.getItem("currentMapId") : null; const userId = @@ -33,25 +32,47 @@ const mapLayersSlice = createSlice({ try { const stored = localStorage.getItem(mapStorageKey); if (stored) { - existingVisibility = JSON.parse(stored); + existingVisibility = JSON.parse(stored) || {}; } } catch (error) { console.error("Error loading stored visibility:", error); } } - systems.forEach(system => { - const key = `system-${system.IdSystem}`; + // Baue ein Set der gültigen Keys (nur Systeme mit Map===1) + const validKeys = new Set(); - // Prüfe ob bereits ein localStorage-Wert existiert - if (existingVisibility.hasOwnProperty(key)) { - // Verwende gespeicherten Wert (Benutzer-Einstellung hat Priorität) + systems.forEach(system => { + if (system.Map !== 1) return; // Komplett überspringen, wenn Map==0 + const key = `system-${system.IdSystem}`; + validKeys.add(key); + + if (Object.prototype.hasOwnProperty.call(existingVisibility, key)) { state[key] = existingVisibility[key]; } else { - // Verwende Allow-Wert als Standard (nur für neue Systeme) - state[key] = system.Allow === 1 && system.Map === 1; + state[key] = system.Allow === 1 && system.Map === 1; // Allow + Map Bedingung } }); + + // Entferne aus dem State alle Keys, die nicht mehr gültig sind (Map wurde evtl. auf 0 gesetzt) + Object.keys(state).forEach(k => { + if (!validKeys.has(k)) { + delete state[k]; + } + }); + + // Bereinige auch den gespeicherten localStorage-Eintrag + if (typeof localStorage !== "undefined") { + const cleaned = {}; + Object.keys(state).forEach(k => { + cleaned[k] = state[k]; + }); + try { + localStorage.setItem(mapStorageKey, JSON.stringify(cleaned)); + } catch (e) { + console.warn("Could not persist cleaned map layer visibility", e); + } + } }, }, });