Files
nodeMap/redux/slices/mapLayersSlice.js
ISA 4755cefdd7 feat: implement device filtering based on GisSystemStatic Allow property
- Add Allow=1 filter in createAndSetDevices.js to hide devices with Allow=0
- Update mapLayersSlice.js setInitialLayers to respect Allow values for visibility
- Modify MapLayersControlPanel.js localStorage initialization to set visibility based on Allow property
- Only systems with Allow=1 are now visible by default, Allow=0 systems are hidden
- Ensures consistent filtering across device markers and layer visibility controls

This change addresses the requirement to hide stations/devices when their corresponding
IdSystem in GisSystemStatic.json has Allow=0, improving the map display by showing
only authorized/allowed systems to users.
2025-07-29 08:11:31 +02:00

35 lines
1.1 KiB
JavaScript

// redux/slices/mapLayersSlice.js
import { createSlice } from "@reduxjs/toolkit";
const initialState = {};
const mapLayersSlice = createSlice({
name: "mapLayers",
initialState,
reducers: {
toggleLayer: (state, action) => {
const layer = action.payload;
if (state[layer] !== undefined) {
state[layer] = !state[layer]; // Toggle Sichtbarkeit
}
},
setLayerVisibility: (state, action) => {
const { layer, visibility } = action.payload;
if (state[layer] !== undefined) {
state[layer] = visibility;
}
},
setInitialLayers: (state, action) => {
const systems = action.payload; // Array of GisSystem
systems.forEach(system => {
const key = `system-${system.IdSystem}`;
state[key] = system.Allow === 1; // true wenn Allow=1, false wenn Allow=0
});
},
},
});
export const { toggleLayer, setLayerVisibility, setInitialLayers } = mapLayersSlice.actions;
export const selectMapLayersState = state => state.mapLayers || initialState;
export default mapLayersSlice.reducer;