Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10489 Problems with GeoStory map configurations merge process #10438

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions web/client/components/geostory/common/enhancers/map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ export default compose(
}))),
withProps(
({ resources, resourceId, map = {}}) => {
const cleanedMap = {...map, layers: (map.layers || []).map(l => l ? l : undefined)};
const resource = find(resources, { id: resourceId }) || {};
return { map: createMapObject(omit(resource.data, ['context']), cleanedMap)};
const baseMap = omit(resource.data, ['context']);
const cleanedMap = {...map, layers: (map.layers || baseMap?.layers || []).map(l => l ? l : undefined)}; // for better intiating cleanedMap layers in case 'map.layers = undefined' -> baseMap.layers check is added in fallBack
return { map: createMapObject(baseMap, cleanedMap)};
}
));
/**
Expand Down
4 changes: 2 additions & 2 deletions web/client/plugins/TOC/components/StyleBasedWMSJsonLegend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ class StyleBasedWMSJsonLegend extends React.Component {
return '';
}
renderRules = (rules) => {
const isLegendFilterIncluded = this.props?.layer?.layerFilter?.filters?.find(f=>f.id === 'interactiveLegend');
const legendFilters = isLegendFilterIncluded ? isLegendFilterIncluded?.filters : [];
return (rules || []).map((rule) => {
const isLegendFilterIncluded = this.props?.layer?.layerFilter?.filters?.find(f=>f.id === 'interactiveLegend');
const legendFilters = isLegendFilterIncluded ? isLegendFilterIncluded?.filters : [];
const isFilterExistBefore = legendFilters?.find(f => f.id === rule.filter);
const isFilterDisabled = this.props?.layer?.layerFilter?.disabled;
const activeFilter = rule.filter && isFilterExistBefore;
Expand Down
69 changes: 69 additions & 0 deletions web/client/utils/__tests__/GeoStoryUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,82 @@ describe("GeoStory Utils", () => {
};
const res = createMapObject(DEFAULT_MAP_OPTIONS, {
mapOptions: {
scrollWheelZoom: false,
interactions: {
mouseClick: false
}
}
});
expect(res).toEqual(merged);
});
it('test override layers in createMapObject', () => {
// initial baseMap layer is empty array
const merged1 = {
zoomControl: true,
mapInfoControl: false,
mapOptions: {
scrollWheelZoom: false,
interactions: {
mouseWheelZoom: false,
mouseClick: false,
dragPan: true
}
},
layers: [{
name: "layer01", center: {x: 1, y: 1, crs: 'EPSG:4326'}, zoom: 1
}, {
name: "layer02", center: {x: 2, y: 2, crs: 'EPSG:4326'}, zoom: 2
}]
};
const res1 = createMapObject({...DEFAULT_MAP_OPTIONS, layers: []}, {
mapOptions: {
scrollWheelZoom: false,
interactions: {
mouseClick: false
}
},
layers: [{
name: "layer01", center: {x: 1, y: 1, crs: 'EPSG:4326'}, zoom: 1
}, {
name: "layer02", center: {x: 2, y: 2, crs: 'EPSG:4326'}, zoom: 2
}]
});
expect(res1).toEqual(merged1);
// initial baseMap layer not empty array
const merged2 = {
zoomControl: true,
mapInfoControl: false,
mapOptions: {
scrollWheelZoom: false,
interactions: {
mouseWheelZoom: false,
mouseClick: false,
dragPan: true
}
},
layers: [{
name: "layer01", center: {x: 1.5, y: 1.5, crs: 'EPSG:4326'}, zoom: 1.5
}, {
name: "layer02", center: {x: 2, y: 2, crs: 'EPSG:4326'}, zoom: 2
}]
};
const res2 = createMapObject({...DEFAULT_MAP_OPTIONS, layers: [{
name: "layer01", center: {x: 1, y: 1, crs: 'EPSG:4326'}, zoom: 1
}]}, {
mapOptions: {
scrollWheelZoom: false,
interactions: {
mouseClick: false
}
},
layers: [{
name: "layer01", center: {x: 1.5, y: 1.5, crs: 'EPSG:4326'}, zoom: 1.5
}, {
name: "layer02", center: {x: 2, y: 2, crs: 'EPSG:4326'}, zoom: 2
}]
});
expect(res2).toEqual(merged2);
});
it('test testRegex', () => {
const title = "title";
expect(testRegex(title, "it")).toBe(true);
Expand Down
Loading