@eeacms/volto-eea-map 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/package.json +1 -1
- package/src/components/Blocks/EmbedEEAMap/Edit.jsx +70 -18
- package/src/components/Blocks/EmbedEEAMap/Schema.js +0 -9
- package/src/components/Blocks/EmbedEEAMap/helpers.js +29 -25
- package/src/components/MoreInfoLink.jsx +1 -1
- package/src/components/Share.jsx +1 -1
- package/src/components/widgets/DataQueryWidget.jsx +2 -1
- package/src/components/widgets/LayerSelectWidget.jsx +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,12 +4,28 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [3.2.0](https://github.com/eea/volto-eea-map/compare/3.1.0...3.2.0) - 13 December 2023
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat: use data_query from connected_data_parameters defined in volto-datablocks [Miu Razvan - [`e755c7d`](https://github.com/eea/volto-eea-map/commit/e755c7d3f3076d751cbace7ac69c19d7fcf37ba9)]
|
|
12
|
+
|
|
13
|
+
#### :bug: Bug Fixes
|
|
14
|
+
|
|
15
|
+
- fix: Invalid DOM property class. Did you mean className [Alin Voinea - [`2c02e99`](https://github.com/eea/volto-eea-map/commit/2c02e99a2d9bb4bf456710d7045af0a8842de952)]
|
|
16
|
+
|
|
17
|
+
#### :hammer_and_wrench: Others
|
|
18
|
+
|
|
19
|
+
- merge develop [andreiggr - [`eba7e68`](https://github.com/eea/volto-eea-map/commit/eba7e6883481bd863d659f7904fb1bc8023689f8)]
|
|
20
|
+
- updates on data_query_parameters [andreiggr - [`06744e4`](https://github.com/eea/volto-eea-map/commit/06744e460398b72a9a6abd065d5ba76bf729588d)]
|
|
21
|
+
- Release 3.2.0 [Alin Voinea - [`deae811`](https://github.com/eea/volto-eea-map/commit/deae811cf402d59ec8d7408c6b9278bc480b07df)]
|
|
22
|
+
- clean up [Miu Razvan - [`21edc9e`](https://github.com/eea/volto-eea-map/commit/21edc9eb5c38d063420743be1e50e376f81cb620)]
|
|
23
|
+
- get unsaved queries from connected data params [andreiggr - [`6833dcd`](https://github.com/eea/volto-eea-map/commit/6833dcdb78404704776aff17439d9058e6d4fd39)]
|
|
7
24
|
### [3.1.0](https://github.com/eea/volto-eea-map/compare/3.0.3...3.1.0) - 8 December 2023
|
|
8
25
|
|
|
9
26
|
#### :hammer_and_wrench: Others
|
|
10
27
|
|
|
11
28
|
- Release 3.1.0 [Alin Voinea - [`2fad87e`](https://github.com/eea/volto-eea-map/commit/2fad87e5a8013b80183797df45ba6494e7ca396d)]
|
|
12
|
-
- use internal url [Miu Razvan - [`c2b56f5`](https://github.com/eea/volto-eea-map/commit/c2b56f5395a79225d09c64c92720f23e74b17c88)]
|
|
13
29
|
### [3.0.3](https://github.com/eea/volto-eea-map/compare/3.0.2...3.0.3) - 29 November 2023
|
|
14
30
|
|
|
15
31
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -12,13 +12,24 @@ import ExtraViews from '@eeacms/volto-eea-map/components/ExtraViews';
|
|
|
12
12
|
|
|
13
13
|
import { Schema } from './Schema';
|
|
14
14
|
import { applyQueriesToMapLayers } from '@eeacms/volto-eea-map/utils';
|
|
15
|
-
|
|
16
|
-
import {
|
|
15
|
+
import { deepUpdateDataQueryParams, getMapVisualizationData } from './helpers';
|
|
16
|
+
import { isEqual } from 'lodash';
|
|
17
17
|
|
|
18
18
|
const Edit = (props) => {
|
|
19
|
-
const { id, block, onChangeBlock, selected, data, getContent } = props;
|
|
20
19
|
const {
|
|
21
|
-
|
|
20
|
+
id,
|
|
21
|
+
block,
|
|
22
|
+
onChangeBlock,
|
|
23
|
+
selected,
|
|
24
|
+
data,
|
|
25
|
+
getContent,
|
|
26
|
+
connected_data_parameters, // page level queries live from widget
|
|
27
|
+
data_query, // page level queries
|
|
28
|
+
mapContent,
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
data_query_params, //block level queries
|
|
22
33
|
enable_queries,
|
|
23
34
|
show_legend = true,
|
|
24
35
|
show_note = true,
|
|
@@ -28,14 +39,30 @@ const Edit = (props) => {
|
|
|
28
39
|
dataprotection = { enabled: true },
|
|
29
40
|
height = '',
|
|
30
41
|
} = data;
|
|
42
|
+
|
|
31
43
|
const schema = Schema(props);
|
|
32
44
|
const [mapData, setMapData] = React.useState('');
|
|
33
45
|
|
|
34
46
|
const vis_url = useMemo(() => flattenToAppURL(data.vis_url), [data.vis_url]);
|
|
35
47
|
|
|
36
|
-
const map_visualization_data = useMemo(
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
const map_visualization_data = useMemo(
|
|
49
|
+
() => getMapVisualizationData({ mapContent, data }),
|
|
50
|
+
[mapContent, data],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const effectiveQueryParams =
|
|
54
|
+
connected_data_parameters && connected_data_parameters.length > 0
|
|
55
|
+
? connected_data_parameters
|
|
56
|
+
: data_query;
|
|
57
|
+
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
deepUpdateDataQueryParams(
|
|
60
|
+
block,
|
|
61
|
+
props.data,
|
|
62
|
+
effectiveQueryParams,
|
|
63
|
+
onChangeBlock,
|
|
64
|
+
);
|
|
65
|
+
}, [block, props.data, effectiveQueryParams, onChangeBlock]);
|
|
39
66
|
|
|
40
67
|
useEffect(() => {
|
|
41
68
|
const mapVisId = flattenToAppURL(map_visualization_data['@id'] || '');
|
|
@@ -47,21 +74,42 @@ const Edit = (props) => {
|
|
|
47
74
|
}
|
|
48
75
|
}, [id, getContent, vis_url, map_visualization_data]);
|
|
49
76
|
|
|
50
|
-
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const mergedQueries =
|
|
79
|
+
connected_data_parameters &&
|
|
80
|
+
connected_data_parameters.length > 0 &&
|
|
81
|
+
connected_data_parameters.map((unsavedQuery, index) => {
|
|
82
|
+
const correspondingQuery =
|
|
83
|
+
data_query_params && data_query_params[index];
|
|
84
|
+
return { ...unsavedQuery, alias: correspondingQuery?.alias };
|
|
85
|
+
});
|
|
86
|
+
const queriesToUse =
|
|
87
|
+
mergedQueries && mergedQueries.length > 0
|
|
88
|
+
? mergedQueries
|
|
89
|
+
: data_query_params;
|
|
90
|
+
|
|
51
91
|
const updatedMapData = applyQueriesToMapLayers(
|
|
52
92
|
map_visualization_data,
|
|
53
|
-
|
|
93
|
+
queriesToUse,
|
|
54
94
|
enable_queries,
|
|
55
95
|
);
|
|
56
|
-
|
|
57
|
-
|
|
96
|
+
|
|
97
|
+
if (!isEqual(mapData, updatedMapData)) {
|
|
98
|
+
setMapData(updatedMapData);
|
|
99
|
+
}
|
|
100
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
+
}, [
|
|
102
|
+
map_visualization_data,
|
|
103
|
+
data_query_params,
|
|
104
|
+
enable_queries,
|
|
105
|
+
connected_data_parameters,
|
|
106
|
+
]);
|
|
58
107
|
|
|
59
108
|
return (
|
|
60
109
|
<>
|
|
61
110
|
{!vis_url && (
|
|
62
111
|
<Message>Please select a visualization from block editor.</Message>
|
|
63
112
|
)}
|
|
64
|
-
|
|
65
113
|
{!!vis_url && mapData && (
|
|
66
114
|
<div>
|
|
67
115
|
<Webmap data={mapData} height={height} isEdit={true} />
|
|
@@ -99,12 +147,16 @@ const Edit = (props) => {
|
|
|
99
147
|
|
|
100
148
|
export default compose(
|
|
101
149
|
connect(
|
|
102
|
-
(state, props) =>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
150
|
+
(state, props) => {
|
|
151
|
+
const pathname = flattenToAppURL(state.content.data['@id']);
|
|
152
|
+
return {
|
|
153
|
+
mapContent: state.content.subrequests?.[props.id]?.data,
|
|
154
|
+
data_query: state.content.data.data_query,
|
|
155
|
+
connected_data_parameters:
|
|
156
|
+
state?.connected_data_parameters?.byContextPath &&
|
|
157
|
+
state.connected_data_parameters?.byContextPath[pathname],
|
|
158
|
+
};
|
|
108
159
|
},
|
|
160
|
+
{ getContent },
|
|
109
161
|
),
|
|
110
162
|
)(Edit);
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { deepUpdateDataQueryParams } from './helpers';
|
|
3
|
-
|
|
4
1
|
const ProtectionSchema = () => ({
|
|
5
2
|
title: 'Data Protection',
|
|
6
3
|
|
|
@@ -68,12 +65,6 @@ const ProtectionSchema = () => ({
|
|
|
68
65
|
});
|
|
69
66
|
|
|
70
67
|
export const Schema = (props) => {
|
|
71
|
-
const { block, onChangeBlock } = props;
|
|
72
|
-
|
|
73
|
-
const dataQuery = React.useMemo(() => props.data_query, [props.data_query]);
|
|
74
|
-
const data = React.useMemo(() => props.data, [props.data]);
|
|
75
|
-
|
|
76
|
-
deepUpdateDataQueryParams(block, data, dataQuery, onChangeBlock);
|
|
77
68
|
return {
|
|
78
69
|
title: 'Embed Map layers (ArcGis)',
|
|
79
70
|
fieldsets: [
|
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
2
|
-
import { updateBlockQueryFromPageQuery } from '@eeacms/volto-eea-map/utils';
|
|
2
|
+
// import { updateBlockQueryFromPageQuery } from '@eeacms/volto-eea-map/utils';
|
|
3
3
|
|
|
4
|
-
const deepUpdateDataQueryParams = (
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const deepUpdateDataQueryParams = (
|
|
5
|
+
block,
|
|
6
|
+
data,
|
|
7
|
+
effectiveQueryParams,
|
|
8
|
+
onChangeBlock,
|
|
9
|
+
) => {
|
|
10
|
+
const updatedQueryParams =
|
|
11
|
+
effectiveQueryParams &&
|
|
12
|
+
effectiveQueryParams.length > 0 &&
|
|
13
|
+
effectiveQueryParams.map((param) => {
|
|
14
|
+
// Find the matching query in the block's current data_query_params
|
|
15
|
+
const existingParam =
|
|
16
|
+
data?.data_query_params &&
|
|
17
|
+
data.data_query_params.find((p) => p.i === param.i);
|
|
18
|
+
|
|
19
|
+
// If found, merge it with the effective query parameter, preserving the alias
|
|
20
|
+
return existingParam ? { ...param, alias: existingParam.alias } : param;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Update the block data if there are changes
|
|
24
|
+
if (
|
|
25
|
+
JSON.stringify(data.data_query_params) !==
|
|
26
|
+
JSON.stringify(updatedQueryParams)
|
|
27
|
+
) {
|
|
7
28
|
onChangeBlock(block, {
|
|
8
29
|
...data,
|
|
9
|
-
data_query_params:
|
|
30
|
+
data_query_params: updatedQueryParams,
|
|
10
31
|
});
|
|
11
32
|
}
|
|
12
|
-
|
|
13
|
-
// If block data_query_params exist, deep check them then change them in block data
|
|
14
|
-
if (data_query && data?.data_query_params) {
|
|
15
|
-
const newDataQuery = updateBlockQueryFromPageQuery(
|
|
16
|
-
data_query,
|
|
17
|
-
data?.data_query_params,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
JSON.stringify(newDataQuery) !== JSON.stringify(data.data_query_params)
|
|
22
|
-
) {
|
|
23
|
-
onChangeBlock(block, {
|
|
24
|
-
...data,
|
|
25
|
-
data_query_params: [...newDataQuery],
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
function getMapVisualizationData(
|
|
32
|
-
const content =
|
|
35
|
+
function getMapVisualizationData({ mapContent, data }) {
|
|
36
|
+
const content = mapContent || {};
|
|
33
37
|
const map_visualization_data =
|
|
34
|
-
content.map_visualization_data ||
|
|
38
|
+
content.map_visualization_data || data?.map_visualization_data || {};
|
|
35
39
|
return {
|
|
36
40
|
...pickMetadata(content),
|
|
37
41
|
...map_visualization_data,
|
|
@@ -13,7 +13,7 @@ const MoreInfoLink = ({ contentTypeLink }) => {
|
|
|
13
13
|
return (
|
|
14
14
|
<Link href={contentTypeLink}>
|
|
15
15
|
<button className={cx('eea-map-more-info-button')}>
|
|
16
|
-
More info <i
|
|
16
|
+
More info <i className="ri-external-link-line"></i>
|
|
17
17
|
</button>
|
|
18
18
|
</Link>
|
|
19
19
|
);
|
package/src/components/Share.jsx
CHANGED
|
@@ -34,7 +34,7 @@ const Share = ({ contentTypeLink = '' }) => {
|
|
|
34
34
|
<div className="eea-map-share-container">
|
|
35
35
|
<button className={cx('eea-map-share-button', { expanded })}>
|
|
36
36
|
<span>Share</span>
|
|
37
|
-
<i
|
|
37
|
+
<i className="ri-share-fill"></i>
|
|
38
38
|
</button>
|
|
39
39
|
</div>
|
|
40
40
|
}
|
|
@@ -26,7 +26,8 @@ const DataQueryWidget = (props) => {
|
|
|
26
26
|
<Accordion.Content active={true}>
|
|
27
27
|
<Segment>
|
|
28
28
|
<p className="data-param-title">
|
|
29
|
-
<strong>{param
|
|
29
|
+
<strong>{param?.i}:</strong>{' '}
|
|
30
|
+
{param?.v && param.v.join(', ')}
|
|
30
31
|
</p>
|
|
31
32
|
<Field
|
|
32
33
|
id={i}
|
|
@@ -4,6 +4,7 @@ import { Input, Select, Button, Grid, Checkbox } from 'semantic-ui-react';
|
|
|
4
4
|
import { QueryBuilder } from 'react-querybuilder';
|
|
5
5
|
import 'react-querybuilder/dist/query-builder.css';
|
|
6
6
|
|
|
7
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
7
8
|
import RichTextWidget from '@plone/volto-slate/widgets/RichTextWidget';
|
|
8
9
|
|
|
9
10
|
import { connect } from 'react-redux';
|
|
@@ -442,10 +443,13 @@ const LayerSelectWidget = (props) => {
|
|
|
442
443
|
|
|
443
444
|
export default compose(
|
|
444
445
|
connect(
|
|
445
|
-
(state
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
446
|
+
(state) => {
|
|
447
|
+
const pathname = flattenToAppURL(state.content.data['@id']);
|
|
448
|
+
return {
|
|
449
|
+
content: state.content.data,
|
|
450
|
+
data_query: state.connected_data_parameters.byContextPath[pathname],
|
|
451
|
+
};
|
|
452
|
+
},
|
|
449
453
|
{
|
|
450
454
|
getContent,
|
|
451
455
|
},
|