From 75666baccbd7f61f1835217e856b982b1d93d6ec Mon Sep 17 00:00:00 2001 From: mahmoud adel <58145645+mahmoudadel54@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:58:35 +0300 Subject: [PATCH] #10489: Fix 10438: Problems with GeoStory map configurations merge process (#10516) --- web/client/components/geostory/common/MapEditor.jsx | 11 ++++++++++- .../components/geostory/common/enhancers/map.jsx | 4 ++-- web/client/utils/__tests__/GeoStoryUtils-test.js | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/web/client/components/geostory/common/MapEditor.jsx b/web/client/components/geostory/common/MapEditor.jsx index 7313d692db4..d618232cdb1 100644 --- a/web/client/components/geostory/common/MapEditor.jsx +++ b/web/client/components/geostory/common/MapEditor.jsx @@ -31,6 +31,7 @@ import Message from '../../I18N/Message'; import MapConfiguratorTabs from './map/MapConfiguratorTabs'; import withMapConfiguratorTabs from './enhancers/withMapConfiguratorTabs'; +import set from 'lodash/fp/set'; const StepHeader = ({title, description}) => ( @@ -102,7 +103,15 @@ const MapEditor = ({ closeNodeEditor={closeNodeEditor} editNode={editNode} map={map} - onChange={onChange}/> + onChange={(path, value) => { + const config = set(path, value, { map }); + const { layers, groups } = config?.map || {}; + if (path.includes('map.layers[')) { + onChangeMap('layers', layers, "replace"); + } else { + onChangeMap('groups', groups, "replace"); + } + }}/> ] || [ - (path, value) => { - update(`${focusedContent.path}.map.${path}`, value, "merge"); + (path, value, mode = "merge") => { + update(`${focusedContent.path}.map.${path}`, value, mode); }, onChange: ({update, focusedContent = {}}) => (path, value, mode = 'merge') => { diff --git a/web/client/utils/__tests__/GeoStoryUtils-test.js b/web/client/utils/__tests__/GeoStoryUtils-test.js index c1c3fcf569b..1a774edeb8e 100644 --- a/web/client/utils/__tests__/GeoStoryUtils-test.js +++ b/web/client/utils/__tests__/GeoStoryUtils-test.js @@ -823,3 +823,4 @@ describe("GeoStory Utils", () => { }); }); }); +