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:
@@ -15,15 +15,42 @@ const mapLayersSlice = createSlice({
|
||||
},
|
||||
setLayerVisibility: (state, action) => {
|
||||
const { layer, visibility } = action.payload;
|
||||
if (state[layer] !== undefined) {
|
||||
state[layer] = visibility;
|
||||
}
|
||||
state[layer] = visibility; // Entferne die Bedingung, um sicherzustellen, dass Werte gesetzt werden
|
||||
},
|
||||
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 =
|
||||
typeof localStorage !== "undefined" ? localStorage.getItem("currentUserId") : null;
|
||||
const mapStorageKey =
|
||||
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
|
||||
|
||||
let existingVisibility = {};
|
||||
if (typeof localStorage !== "undefined") {
|
||||
try {
|
||||
const stored = localStorage.getItem(mapStorageKey);
|
||||
if (stored) {
|
||||
existingVisibility = JSON.parse(stored);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error loading stored visibility:", error);
|
||||
}
|
||||
}
|
||||
|
||||
systems.forEach(system => {
|
||||
const key = `system-${system.IdSystem}`;
|
||||
state[key] = system.Allow === 1; // true wenn Allow=1, false wenn Allow=0
|
||||
|
||||
// Prüfe ob bereits ein localStorage-Wert existiert
|
||||
if (existingVisibility.hasOwnProperty(key)) {
|
||||
// Verwende gespeicherten Wert (Benutzer-Einstellung hat Priorität)
|
||||
state[key] = existingVisibility[key];
|
||||
} else {
|
||||
// Verwende Allow-Wert als Standard (nur für neue Systeme)
|
||||
state[key] = system.Allow === 1;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user