From 2563cf4718d1456b69f66202765f632a0b2c6182 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 26 Apr 2024 12:31:59 +0200 Subject: [PATCH] =?UTF-8?q?filteredAreas:=20Filtert=20Bereiche,=20die=20zu?= =?UTF-8?q?=20den=20erlaubten=20Systemen=20geh=C3=B6ren.=20Das=20sorgt=20d?= =?UTF-8?q?af=C3=BCr,=20dass=20nur=20relevante=20Bereiche=20im=20Dropdown-?= =?UTF-8?q?Men=C3=BC=20erscheinen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/DataSheet.js | 31 +++++++++++++++++++++---------- config/config.js | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/components/DataSheet.js b/components/DataSheet.js index 41aba4398..429e88066 100644 --- a/components/DataSheet.js +++ b/components/DataSheet.js @@ -15,17 +15,35 @@ function DataSheet() { const GisSystemStatic = useRecoilValue(gisSystemStaticState); useEffect(() => { - // Filter unique areas + // Identify allowed system IDs + const allowedSystems = new Set( + GisSystemStatic.filter((system) => system.Allow === 1).map( + (system) => system.IdSystem + ) + ); + + // Filter unique areas that belong to allowed systems const seenNames = new Set(); const filteredAreas = GisStationsStaticDistrict.filter((item) => { - const isUnique = !seenNames.has(item.Area_Name); + const isUnique = + !seenNames.has(item.Area_Name) && allowedSystems.has(item.System); if (isUnique) { seenNames.add(item.Area_Name); + console.log("Unique area:", item.Area_Name); } return isUnique; }); + console.log("GisStationsStaticDistrict:", GisStationsStaticDistrict); - // Filter unique systems where Allow is 1 + // Set the station listings + setStationListing( + filteredAreas.map((area, index) => ({ + id: index + 1, + name: area.Area_Name, + })) + ); + + // Prepare system listings as before const seenSystemNames = new Set(); const filteredSystems = GisSystemStatic.filter((item) => { const isUnique = !seenSystemNames.has(item.Name) && item.Allow === 1; @@ -35,13 +53,6 @@ function DataSheet() { return isUnique; }); - setStationListing( - filteredAreas.map((area, index) => ({ - id: index + 1, - name: area.Area_Name, - })) - ); - setSystemListing( filteredSystems.map((system, index) => ({ id: index + 1, diff --git a/config/config.js b/config/config.js index b9dfb72d9..99ea75628 100644 --- a/config/config.js +++ b/config/config.js @@ -28,7 +28,7 @@ if (typeof window !== "undefined") { url_string = window.location.href; // Die vollständige URL als String url = new URL(url_string); // Die URL als URL-Objekt, um Teile der URL einfacher zu handhaben c = url.searchParams.get("m") || "10"; // Ein Parameter aus der URL, Standardwert ist '10' - user = url.searchParams.get("u") || "484"; // Ein weiterer Parameter aus der URL, Standardwert ist '487 oder 484 oder 485 zu testen von Stationen ausblenden und einblenden in der Card' + user = url.searchParams.get("u") || "484"; // Ein weiterer Parameter aus der URL, Standardwert ist '484 admin zu testen von Stationen ausblenden und einblenden in der Card' // Konstruktion von URLs, die auf spezifische Ressourcen auf dem Server zeigen mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict?idMap=${c}&idUser=${user}`;