Systeme mit Map === 0 vollständig ausgeblenden

This commit is contained in:
ISA
2025-08-11 10:17:09 +02:00
parent 7c89d8dae5
commit 5c06abc85e
6 changed files with 62 additions and 52 deletions

View File

@@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=true
NEXT_PUBLIC_BASE_PATH=/talas5 NEXT_PUBLIC_BASE_PATH=/talas5
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH= # Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.1.312 NEXT_PUBLIC_APP_VERSION=1.1.313

View File

@@ -26,4 +26,4 @@ NEXT_PUBLIC_BASE_PATH=/talas5
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH= # Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.1.312 NEXT_PUBLIC_APP_VERSION=1.1.313

View File

@@ -31,7 +31,7 @@ function MapLayersControlPanel() {
console.log("🎯 kabelstreckenVisible state changed to:", kabelstreckenVisible); console.log("🎯 kabelstreckenVisible state changed to:", kabelstreckenVisible);
}, [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) const isTalasAllowed = Array.isArray(GisSystemStatic)
? GisSystemStatic.some( ? GisSystemStatic.some(
system => system.IdSystem === 1 && system.Allow === 1 && system.Map === 1 system => system.IdSystem === 1 && system.Allow === 1 && system.Map === 1
@@ -134,18 +134,23 @@ function MapLayersControlPanel() {
dispatch(setLayerVisibility({ layer: key, visibility: parsedVisibility[key] })); dispatch(setLayerVisibility({ layer: key, visibility: parsedVisibility[key] }));
}); });
} else { } else {
// Initialisiere mapLayersVisibility basierend auf GisSystemStatic Allow-Werten // Initialisiere mapLayersVisibility basierend auf Allow & Map (nur Systeme mit Map===1 anzeigen)
console.log("🚀 No stored mapLayersVisibility found, initializing based on Allow values..."); console.log(
"🚀 No stored mapLayersVisibility found, initializing based on Allow && Map values..."
);
if (Array.isArray(GisSystemStatic)) { if (Array.isArray(GisSystemStatic)) {
const initialVisibility = {}; const initialVisibility = {};
GisSystemStatic.forEach(system => { GisSystemStatic.forEach(system => {
const systemKey = `system-${system.IdSystem}`; const systemKey = `system-${system.IdSystem}`;
const visibility = system.Allow === 1; const visibility = system.Allow === 1 && system.Map === 1; // <— angepasst
initialVisibility[systemKey] = visibility; if (visibility) {
dispatch(setLayerVisibility({ layer: systemKey, visibility })); // nur speichern wenn grundsätzlich sichtbar
console.log( initialVisibility[systemKey] = visibility;
`🎯 Setting ${systemKey} (${system.Name}) visibility to ${visibility} (Allow=${system.Allow})` 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)); localStorage.setItem(mapStorageKey, JSON.stringify(initialVisibility));
console.log(`💾 Saved initial mapLayersVisibility to ${mapStorageKey}:`, initialVisibility); console.log(`💾 Saved initial mapLayersVisibility to ${mapStorageKey}:`, initialVisibility);
@@ -159,9 +164,6 @@ function MapLayersControlPanel() {
setLocalStorageLoaded(true); setLocalStorageLoaded(true);
}, []); // Läuft nur beim Mount }, []); // 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 handleAreaChange = event => {
const selectedIndex = event.target.options.selectedIndex; const selectedIndex = event.target.options.selectedIndex;
const areaName = event.target.options[selectedIndex].text; const areaName = event.target.options[selectedIndex].text;
@@ -169,8 +171,13 @@ function MapLayersControlPanel() {
}; };
useEffect(() => { useEffect(() => {
// Allowed systems jetzt nach Allow && Map filtern
const allowedSystems = Array.isArray(GisSystemStatic) 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(); : new Set();
const seenNames = new Set(); const seenNames = new Set();
@@ -194,7 +201,7 @@ function MapLayersControlPanel() {
const seenSystemNames = new Set(); const seenSystemNames = new Set();
const filteredSystems = Array.isArray(GisSystemStatic) const filteredSystems = Array.isArray(GisSystemStatic)
? GisSystemStatic.filter(item => { ? 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) { if (isUnique) {
seenSystemNames.add(item.Name); seenSystemNames.add(item.Name);
} }
@@ -205,8 +212,8 @@ function MapLayersControlPanel() {
setSystemListing( setSystemListing(
filteredSystems.map((system, index) => ({ filteredSystems.map((system, index) => ({
id: index + 1, id: index + 1,
name: system.Name, // Verwende den Originalnamen für die Anzeige name: system.Name, // Anzeige
key: `system-${system.IdSystem}`, // Internen Schlüssel für die MapLayersVisibility-Logik key: `system-${system.IdSystem}`, // interner Schlüssel
})) }))
); );
}, [GisStationsStaticDistrict, GisSystemStatic]); }, [GisStationsStaticDistrict, GisSystemStatic]);
@@ -328,13 +335,14 @@ function MapLayersControlPanel() {
style={{ minWidth: "150px", maxWidth: "200px" }} style={{ minWidth: "150px", maxWidth: "200px" }}
> >
<option value="Station wählen">Station wählen</option> <option value="Station wählen">Station wählen</option>
{[ {/*
...new Map( ...new Map(
(GisStationsStaticDistrict.Points || []) (GisStationsStaticDistrict.Points || [])
.filter(p => !!p.Area_Name) .filter(p => !!p.Area_Name)
.map(p => [p.Area_Name, p]) .map(p => [p.Area_Name, p])
).values(), ).values(),
].map((item, index) => ( */}
{GisStationsStaticDistrict.Points.filter(p => !!p.Area_Name).map((item, index) => (
<option key={item.Area_Name} value={item.IdLD}> <option key={item.Area_Name} value={item.IdLD}>
{item.Area_Name} {item.Area_Name}
</option> </option>
@@ -399,25 +407,6 @@ function MapLayersControlPanel() {
POIs POIs
</label> </label>
</div> </div>
{/* Areas
<div className="flex items-center">
<input type="checkbox" checked={areaVisible} onChange={handleAreaCheckboxChange} id="area-checkbox" />
<label htmlFor="area-checkbox" className="text-sm ml-2">
Bereiche
</label>
</div>
*/}
{/* Standorte
<div className="flex items-center">
<input type="checkbox" checked={standordVisible} onChange={handleStandorteCheckboxChange} id="area-checkbox" />
<label htmlFor="area-checkbox" className="text-sm ml-2">
Standorte
</label>
</div>
*/}
</div> </div>
</div> </div>
</div> </div>

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "nodemap", "name": "nodemap",
"version": "1.1.312", "version": "1.1.313",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "nodemap", "name": "nodemap",
"version": "1.1.312", "version": "1.1.313",
"dependencies": { "dependencies": {
"@emotion/react": "^11.13.3", "@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0", "@emotion/styled": "^11.13.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "nodemap", "name": "nodemap",
"version": "1.1.312", "version": "1.1.313",
"dependencies": { "dependencies": {
"@emotion/react": "^11.13.3", "@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0", "@emotion/styled": "^11.13.0",

View File

@@ -15,12 +15,11 @@ const mapLayersSlice = createSlice({
}, },
setLayerVisibility: (state, action) => { setLayerVisibility: (state, action) => {
const { layer, visibility } = action.payload; 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) => { setInitialLayers: (state, action) => {
const systems = action.payload; // Array of GisSystem const systems = action.payload; // Array of GisSystem
// Versuche kartenspezifische localStorage-Werte zu laden
const mapId = const mapId =
typeof localStorage !== "undefined" ? localStorage.getItem("currentMapId") : null; typeof localStorage !== "undefined" ? localStorage.getItem("currentMapId") : null;
const userId = const userId =
@@ -33,25 +32,47 @@ const mapLayersSlice = createSlice({
try { try {
const stored = localStorage.getItem(mapStorageKey); const stored = localStorage.getItem(mapStorageKey);
if (stored) { if (stored) {
existingVisibility = JSON.parse(stored); existingVisibility = JSON.parse(stored) || {};
} }
} catch (error) { } catch (error) {
console.error("Error loading stored visibility:", error); console.error("Error loading stored visibility:", error);
} }
} }
systems.forEach(system => { // Baue ein Set der gültigen Keys (nur Systeme mit Map===1)
const key = `system-${system.IdSystem}`; const validKeys = new Set();
// Prüfe ob bereits ein localStorage-Wert existiert systems.forEach(system => {
if (existingVisibility.hasOwnProperty(key)) { if (system.Map !== 1) return; // Komplett überspringen, wenn Map==0
// Verwende gespeicherten Wert (Benutzer-Einstellung hat Priorität) const key = `system-${system.IdSystem}`;
validKeys.add(key);
if (Object.prototype.hasOwnProperty.call(existingVisibility, key)) {
state[key] = existingVisibility[key]; state[key] = existingVisibility[key];
} else { } else {
// Verwende Allow-Wert als Standard (nur für neue Systeme) state[key] = system.Allow === 1 && system.Map === 1; // Allow + Map Bedingung
state[key] = system.Allow === 1 && system.Map === 1;
} }
}); });
// 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);
}
}
}, },
}, },
}); });