Systeme mit Map === 0 vollständig ausgeblenden
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
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})`
|
||||
`🎯 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" }}
|
||||
>
|
||||
<option value="Station wählen">Station wählen</option>
|
||||
{[
|
||||
{/*
|
||||
...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) => (
|
||||
<option key={item.Area_Name} value={item.IdLD}>
|
||||
{item.Area_Name}
|
||||
</option>
|
||||
@@ -399,25 +407,6 @@ function MapLayersControlPanel() {
|
||||
POIs
|
||||
</label>
|
||||
</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>
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user