git commit -m "refactor: Gerätelayer dynamisch über IdSystem initialisiert

BREAKING CHANGE: Sichtbarkeit der Gerätegruppen basiert nun auf 'system-<IdSystem>' statt auf Namen wie 'SMSFunkmodem'. Statische Layer-Konfiguration im Redux-Slice entfernt."
This commit is contained in:
ISA
2025-06-02 09:00:49 +02:00
parent fda7476872
commit be2da8414c
12 changed files with 76 additions and 33 deletions

View File

@@ -1,24 +1,7 @@
// redux/slices/mapLayersSlice.js
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
TALAS: true,
ECI: true,
ULAF: true,
GSMModem: true,
CiscoRouter: true,
WAGO: true,
Siemens: true,
OTDR: true,
WDM: true,
GMA: true,
Messstellen: true,
TALASICL: true,
DAUZ: true,
SMSFunkmodem: true, // ✅ Hier sicherstellen, dass es existiert
TKKomponenten: true, // ✅ Hier sicherstellen, dass es existiert
Sonstige: true,
};
const initialState = {};
const mapLayersSlice = createSlice({
name: "mapLayers",
@@ -36,9 +19,16 @@ const mapLayersSlice = createSlice({
state[layer] = visibility;
}
},
setInitialLayers: (state, action) => {
const systems = action.payload; // Array of GisSystem
systems.forEach((system) => {
const key = `system-${system.IdSystem}`;
state[key] = true; // oder false, je nach Default
});
},
},
});
export const { toggleLayer, setLayerVisibility } = mapLayersSlice.actions;
export const { toggleLayer, setLayerVisibility, setInitialLayers } = mapLayersSlice.actions;
export const selectMapLayersState = (state) => state.mapLayers || initialState;
export default mapLayersSlice.reducer;