fix: Systemtyp Berechtigung der User werden nicht beachtet

This commit is contained in:
ISA
2025-07-30 15:19:53 +02:00
parent 53c670feba
commit 4ee6d42a61
6 changed files with 92 additions and 43 deletions

View File

@@ -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;
}
});
},
},