WIP: Kabelstrecken wird deaktiviert beim neuladen der Seite
This commit is contained in:
@@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=true
|
|||||||
# z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen
|
# z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen
|
||||||
# basePath wird jetzt in public/config.json gepflegt
|
# basePath wird jetzt in public/config.json gepflegt
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.1.336
|
NEXT_PUBLIC_APP_VERSION=1.1.337
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=false
|
|||||||
# basePath wird jetzt in public/config.json gepflegt
|
# basePath wird jetzt in public/config.json gepflegt
|
||||||
|
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.1.336
|
NEXT_PUBLIC_APP_VERSION=1.1.337
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
selectPolylineVisible,
|
selectPolylineVisible,
|
||||||
setPolylineVisible,
|
setPolylineVisible,
|
||||||
|
initializePolylineFromLocalStorageThunk,
|
||||||
} from "@/redux/slices/database/polylines/polylineLayerVisibleSlice.js";
|
} from "@/redux/slices/database/polylines/polylineLayerVisibleSlice.js";
|
||||||
import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice.js";
|
import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice.js";
|
||||||
import {
|
import {
|
||||||
@@ -263,8 +264,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
`📝 Keine gespeicherten Einstellungen für Map ${mapId}/User ${userId} gefunden`
|
`📝 Keine gespeicherten Einstellungen für Map ${mapId}/User ${userId} gefunden`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// Redux Polyline Sichtbarkeit initialisieren (map/user spezifisch)
|
||||||
|
dispatch(initializePolylineFromLocalStorageThunk());
|
||||||
}
|
}
|
||||||
}, []); // Nur einmal beim Mount ausführen useEffect(() => {
|
}, [dispatch]); // Nur einmal beim Mount ausführen
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (linesData && Array.isArray(linesData)) {
|
if (linesData && Array.isArray(linesData)) {
|
||||||
const transformed = linesData.map(item => ({
|
const transformed = linesData.map(item => ({
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { incrementZoomTrigger } from "@/redux/slices/zoomTriggerSlice";
|
|||||||
function MapLayersControlPanel() {
|
function MapLayersControlPanel() {
|
||||||
const [editMode, setEditMode] = useState(false); // Zustand für editMode
|
const [editMode, setEditMode] = useState(false); // Zustand für editMode
|
||||||
const [localStorageLoaded, setLocalStorageLoaded] = useState(false); // Tracking ob localStorage geladen wurde
|
const [localStorageLoaded, setLocalStorageLoaded] = useState(false); // Tracking ob localStorage geladen wurde
|
||||||
const [kabelstreckenVisible, setKabelstreckenVisible] = useState(false); // Lokaler State für Kabelstrecken
|
const kabelstreckenVisible = useSelector(selectPolylineVisible); // Redux State für Kabelstrecken
|
||||||
const poiVisible = useSelector(state => state.poiLayerVisible.visible);
|
const poiVisible = useSelector(state => state.poiLayerVisible.visible);
|
||||||
const setPoiVisible = value => dispatch(setVisible(value));
|
const setPoiVisible = value => dispatch(setVisible(value));
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -40,9 +40,7 @@ function MapLayersControlPanel() {
|
|||||||
|
|
||||||
const handlePolylineCheckboxChange = event => {
|
const handlePolylineCheckboxChange = event => {
|
||||||
const checked = event.target.checked;
|
const checked = event.target.checked;
|
||||||
setKabelstreckenVisible(checked);
|
dispatch(setPolylineVisible(checked));
|
||||||
localStorage.setItem("kabelstreckenVisible", checked.toString());
|
|
||||||
localStorage.setItem("polylineVisible", checked.toString());
|
|
||||||
dispatch(setPolylineVisible(checked));
|
dispatch(setPolylineVisible(checked));
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const event = new Event("polylineVisibilityChanged");
|
const event = new Event("polylineVisibilityChanged");
|
||||||
@@ -75,23 +73,7 @@ function MapLayersControlPanel() {
|
|||||||
const mapStorageKey =
|
const mapStorageKey =
|
||||||
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
|
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
|
||||||
|
|
||||||
// Kabelstrecken-Checkbox initialisieren
|
// Kabelstrecken-Checkbox initialisieren: Redux übernimmt map/user-spezifisch, keine Manipulation von 'polylineVisible' oder 'kabelstreckenVisible' hier mehr!
|
||||||
let storedKabelstreckenVisible = localStorage.getItem("kabelstreckenVisible");
|
|
||||||
const storedPolylineVisible = localStorage.getItem("polylineVisible");
|
|
||||||
if (storedKabelstreckenVisible === null && storedPolylineVisible !== null) {
|
|
||||||
storedKabelstreckenVisible = storedPolylineVisible;
|
|
||||||
localStorage.setItem("kabelstreckenVisible", storedPolylineVisible);
|
|
||||||
}
|
|
||||||
if (storedKabelstreckenVisible !== null) {
|
|
||||||
const shouldBeVisible = storedKabelstreckenVisible === "true";
|
|
||||||
setKabelstreckenVisible(shouldBeVisible);
|
|
||||||
localStorage.setItem("polylineVisible", shouldBeVisible.toString());
|
|
||||||
dispatch(setPolylineVisible(shouldBeVisible));
|
|
||||||
setTimeout(() => {
|
|
||||||
const event = new Event("polylineVisibilityChanged");
|
|
||||||
window.dispatchEvent(event);
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// mapLayersVisibility initialisieren
|
// mapLayersVisibility initialisieren
|
||||||
const storedMapLayersVisibility = localStorage.getItem(mapStorageKey);
|
const storedMapLayersVisibility = localStorage.getItem(mapStorageKey);
|
||||||
@@ -187,8 +169,7 @@ function MapLayersControlPanel() {
|
|||||||
// Wenn TALAS (system-1) deaktiviert wird, Kabelstrecken deaktivieren
|
// Wenn TALAS (system-1) deaktiviert wird, Kabelstrecken deaktivieren
|
||||||
if (key === "system-1" && !checked) {
|
if (key === "system-1" && !checked) {
|
||||||
setKabelstreckenVisible(false);
|
setKabelstreckenVisible(false);
|
||||||
localStorage.setItem("kabelstreckenVisible", "false");
|
// entfernt: keine Manipulation von 'kabelstreckenVisible' oder 'polylineVisible' mehr
|
||||||
localStorage.setItem("polylineVisible", "false");
|
|
||||||
dispatch(setPolylineVisible(false));
|
dispatch(setPolylineVisible(false));
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const polylineEvent = new Event("polylineVisibilityChanged");
|
const polylineEvent = new Event("polylineVisibilityChanged");
|
||||||
@@ -333,7 +314,7 @@ function MapLayersControlPanel() {
|
|||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={kabelstreckenVisible} // Lokaler State statt Redux
|
checked={kabelstreckenVisible} // Redux State
|
||||||
onChange={handlePolylineCheckboxChange}
|
onChange={handlePolylineCheckboxChange}
|
||||||
id="polyline-checkbox"
|
id="polyline-checkbox"
|
||||||
disabled={!isTalasAllowed || editMode}
|
disabled={!isTalasAllowed || editMode}
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.336",
|
"version": "1.1.337",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.336",
|
"version": "1.1.337",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.336",
|
"version": "1.1.337",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
@@ -1,6 +1,29 @@
|
|||||||
// /redux/slices/database7polylines/polylineLayerVisibleSlice.js
|
// /redux/slices/database7polylines/polylineLayerVisibleSlice.js
|
||||||
|
|
||||||
import { createSlice } from "@reduxjs/toolkit";
|
import { createSlice } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
|
// Thunk to initialize polyline visibility from localStorage using mapId/userId from URL
|
||||||
|
export const initializePolylineFromLocalStorageThunk = () => dispatch => {
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const mapId = params.get("m");
|
||||||
|
const userId = params.get("u");
|
||||||
|
if (mapId && userId) {
|
||||||
|
const key = `polylineVisible_m${mapId}_u${userId}`;
|
||||||
|
const stored = localStorage.getItem(key);
|
||||||
|
const visible = stored === "true";
|
||||||
|
dispatch(initializePolylineFromLocalStorage(visible));
|
||||||
|
// Optional: log for debugging
|
||||||
|
console.log(
|
||||||
|
`Redux: Initialized polyline visibility from localStorage key '${key}':`,
|
||||||
|
visible
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error initializing polyline visibility from localStorage:", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
visible: false, // Standardwert - wird in der Komponente aus localStorage überschrieben
|
visible: false, // Standardwert - wird in der Komponente aus localStorage überschrieben
|
||||||
isInitialized: false, // Flag um zu verfolgen, ob der Wert aus localStorage geladen wurde
|
isInitialized: false, // Flag um zu verfolgen, ob der Wert aus localStorage geladen wurde
|
||||||
@@ -13,7 +36,18 @@ const polylineLayerVisibleSlice = createSlice({
|
|||||||
setPolylineVisible: (state, action) => {
|
setPolylineVisible: (state, action) => {
|
||||||
state.visible = action.payload;
|
state.visible = action.payload;
|
||||||
state.isInitialized = true;
|
state.isInitialized = true;
|
||||||
localStorage.setItem("polylineVisible", action.payload.toString());
|
// Save to localStorage using mapId/userId key
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const mapId = params.get("m");
|
||||||
|
const userId = params.get("u");
|
||||||
|
if (mapId && userId) {
|
||||||
|
const key = `polylineVisible_m${mapId}_u${userId}`;
|
||||||
|
localStorage.setItem(key, action.payload.toString());
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// fallback: do nothing
|
||||||
|
}
|
||||||
console.log("💾 Redux: setPolylineVisible called with:", action.payload);
|
console.log("💾 Redux: setPolylineVisible called with:", action.payload);
|
||||||
},
|
},
|
||||||
initializePolylineFromLocalStorage: (state, action) => {
|
initializePolylineFromLocalStorage: (state, action) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user