From afe6782fd0f919b70300820d78e4a97934edd8f7 Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Fri, 17 Nov 2023 10:12:04 +0100 Subject: [PATCH 1/3] [Regulatory] set layer name --- .../src/features/layersSelector/search/LayerFilters.tsx | 1 + frontend/src/features/map/layers/Regulatory/index.ts | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/features/layersSelector/search/LayerFilters.tsx b/frontend/src/features/layersSelector/search/LayerFilters.tsx index 1b51654a73..94115607e7 100644 --- a/frontend/src/features/layersSelector/search/LayerFilters.tsx +++ b/frontend/src/features/layersSelector/search/LayerFilters.tsx @@ -59,6 +59,7 @@ export function LayerFilters({ > + const layerRef = useRef() as MutableRefObject & { name?: string }> useEffect(() => { function getLayer() { if (!layerRef.current) { layerRef.current = new Vector({ - properties: { - name: Layers.REGULATORY_ENV_PREVIEW.code - }, renderBuffer: 4, renderOrder: (a, b) => b.get('area') - a.get('area'), source: getVectorSource(), @@ -44,6 +41,7 @@ export function RegulatoryLayers({ map }: BaseMapChildrenProps) { updateWhileAnimating: true, updateWhileInteracting: true }) + layerRef.current.name = Layers.AMP.code } return layerRef.current From b78b3d2a982ecaa01652734f7ce4790cca6426ff Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Fri, 17 Nov 2023 11:05:06 +0100 Subject: [PATCH 2/3] [Regulatory] add geoserverApi middleware in store --- .../src/features/map/layers/Regulatory/index.ts | 6 ++++-- frontend/src/store/index.ts | 4 ++-- frontend/src/store/reducers.ts | 16 ---------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/frontend/src/features/map/layers/Regulatory/index.ts b/frontend/src/features/map/layers/Regulatory/index.ts index 252d1c2412..9fa8de7a49 100644 --- a/frontend/src/features/map/layers/Regulatory/index.ts +++ b/frontend/src/features/map/layers/Regulatory/index.ts @@ -28,12 +28,15 @@ export function RegulatoryLayers({ map }: BaseMapChildrenProps) { return vectorSourceRef.current } - const layerRef = useRef() as MutableRefObject & { name?: string }> + const layerRef = useRef() as MutableRefObject> useEffect(() => { function getLayer() { if (!layerRef.current) { layerRef.current = new Vector({ + properties: { + name: Layers.REGULATORY_ENV_PREVIEW.code + }, renderBuffer: 4, renderOrder: (a, b) => b.get('area') - a.get('area'), source: getVectorSource(), @@ -41,7 +44,6 @@ export function RegulatoryLayers({ map }: BaseMapChildrenProps) { updateWhileAnimating: true, updateWhileInteracting: true }) - layerRef.current.name = Layers.AMP.code } return layerRef.current diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index 596dea02d4..8ad8623d08 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -3,7 +3,7 @@ import { setupListeners } from '@reduxjs/toolkit/query' import { FLUSH, PAUSE, PERSIST, PURGE, REGISTER, REHYDRATE } from 'redux-persist' import { homeReducers } from './reducers' -import { monitorenvPrivateApi, monitorenvPublicApi } from '../api/api' +import { monitorenvPrivateApi, monitorenvPublicApi, geoserverApi } from '../api/api' import { regulatoryActionSanitizer } from '../domain/shared_slices/Regulatory' const homeStore = configureStore({ @@ -20,7 +20,7 @@ const homeStore = configureStore({ isSerializable: (value: any) => isPlain(value) || value instanceof Date || value instanceof Error, serializableCheck: false } - }).concat(monitorenvPrivateApi.middleware, monitorenvPublicApi.middleware), + }).concat(monitorenvPrivateApi.middleware, monitorenvPublicApi.middleware, geoserverApi.middleware), reducer: combineReducers(homeReducers) as unknown as typeof homeReducers }) diff --git a/frontend/src/store/reducers.ts b/frontend/src/store/reducers.ts index 596d67e25b..5a427fd3e2 100644 --- a/frontend/src/store/reducers.ts +++ b/frontend/src/store/reducers.ts @@ -1,12 +1,4 @@ -import { ampsAPI } from '../api/ampsAPI' import { geoserverApi, monitorenvPrivateApi, monitorenvPublicApi } from '../api/api' -import { controlThemesAPI } from '../api/controlThemesAPI' -import { infractionsAPI } from '../api/infractionsAPI' -import { legacyControlUnitsAPI } from '../api/legacyControlUnitsAPI' -import { missionsAPI } from '../api/missionsAPI' -import { regulatoryLayersAPI } from '../api/regulatoryLayersAPI' -import { reportingsAPI } from '../api/reportingsAPI' -import { semaphoresAPI } from '../api/semaphoresAPI' import { administrativeSlicePersistedReducer } from '../domain/shared_slices/Administrative' import { drawReducer } from '../domain/shared_slices/Draw' import { globalReducer } from '../domain/shared_slices/Global' @@ -60,15 +52,7 @@ export const homeReducers = { regulatoryMetadata: regulatoryMetadataSliceReducer, reporting: reportingSliceReducer, [layerSidebarSlice.name]: layerSidebarSlice.reducer, - [ampsAPI.reducerPath]: ampsAPI.reducer, - [regulatoryLayersAPI.reducerPath]: regulatoryLayersAPI.reducer, - [missionsAPI.reducerPath]: missionsAPI.reducer, - [controlThemesAPI.reducerPath]: controlThemesAPI.reducer, - [legacyControlUnitsAPI.reducerPath]: legacyControlUnitsAPI.reducer, - [infractionsAPI.reducerPath]: infractionsAPI.reducer, - [semaphoresAPI.reducerPath]: semaphoresAPI.reducer, reportingFilters: reportingFiltersPersistedReducer, - [reportingsAPI.reducerPath]: reportingsAPI.reducer, selectedAmp: selectedAmpSlicePersistedReducer, semaphoresSlice: semaphoresPersistedReducer, sideWindow: sideWindowReducer, From a00e36a960d8f8b49fa2b49bb6bf27eaf2d6bca7 Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Fri, 17 Nov 2023 11:45:47 +0100 Subject: [PATCH 3/3] [Map] fix handleMapClick function and get layer name --- frontend/src/features/map/BaseMap.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/features/map/BaseMap.tsx b/frontend/src/features/map/BaseMap.tsx index 6df8b6a4f4..0e061c6943 100644 --- a/frontend/src/features/map/BaseMap.tsx +++ b/frontend/src/features/map/BaseMap.tsx @@ -67,7 +67,9 @@ export function BaseMap({ children }: { children: Array { const typedLayer = layer as VectorLayerWithName - return !!typedLayer.name && SelectableLayers.includes(typedLayer.name) + const layerName = typedLayer.name || typedLayer.get('name') + + return !!layerName && SelectableLayers.includes(layerName) } } )