From c28958d9c7d3b732700e9a91c764e75822913519 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 17 Jul 2026 18:37:40 +0200 Subject: [PATCH] Select usable Flanders theme by default --- ...t_sprint237_flanders_thematic_on_demand.py | 2 ++ frontend/src/components/map/MapWorkspace.tsx | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/backend/tests/test_sprint237_flanders_thematic_on_demand.py b/backend/tests/test_sprint237_flanders_thematic_on_demand.py index 383e3d3c..3eb3132c 100644 --- a/backend/tests/test_sprint237_flanders_thematic_on_demand.py +++ b/backend/tests/test_sprint237_flanders_thematic_on_demand.py @@ -17,6 +17,8 @@ def test_flanders_workspace_exposes_governed_thematic_products_on_demand() -> No assert "activeScopeProject?.name === FLANDERS_WORKSPACE_PROJECT_NAME" in workspace assert "new Map" in workspace assert "'Op aanvraag'" in workspace + assert "theme.id === 'space_occupation'" in workspace + assert "setActiveThemeId(fallbackTheme.id)" in workspace assert "thematicProductKey: thematicProduct.key" in workspace assert "datasetsApi.listThematicRasterProducts" in product_hook assert "datasetsApi.acquireThematicRaster" in selection_hook diff --git a/frontend/src/components/map/MapWorkspace.tsx b/frontend/src/components/map/MapWorkspace.tsx index 088076c7..c779ddc4 100644 --- a/frontend/src/components/map/MapWorkspace.tsx +++ b/frontend/src/components/map/MapWorkspace.tsx @@ -790,6 +790,40 @@ export function MapWorkspace({ const onDemandThematicThemeActive = analysisMode === 'current' && Boolean(activeOnDemandThematicProduct) const regionalOnDemandThematicThemeActive = regionalScopeSelected && onDemandThematicThemeActive const activeThemeAvailable = Boolean(activeThemeDataset) || onDemandThematicThemeActive + + useEffect(() => { + if ( + !flandersScopeSelected + || analysisMode !== 'current' + || activeThemeAvailable + || (onDemandThematicProductMap.size === 0 && !thematicRasterProductsError) + ) { + return + } + const fallbackTheme = DATA_THEMES.find((theme) => + theme.id === 'space_occupation' + && Boolean(themeDatasetMap[theme.id] || onDemandThematicProductMap.get(theme.id)), + ) ?? DATA_THEMES.find((theme) => + Boolean(themeDatasetMap[theme.id] || onDemandThematicProductMap.get(theme.id)), + ) + if (!fallbackTheme) { + return + } + setActiveThemeId(fallbackTheme.id) + const fallbackDataset = themeDatasetMap[fallbackTheme.id] + if (fallbackDataset) { + onOpenDatasetInMap(fallbackDataset) + } + }, [ + activeThemeAvailable, + analysisMode, + flandersScopeSelected, + onDemandThematicProductMap, + onOpenDatasetInMap, + thematicRasterProductsError, + themeDatasetMap, + ]) + const terrainImageOverlays = useMemo( () => activeTheme.id === 'elevation' && selectedProjectId