@eeacms/volto-eea-map 3.0.3 → 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 CHANGED
@@ -4,6 +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)]
24
+ ### [3.1.0](https://github.com/eea/volto-eea-map/compare/3.0.3...3.1.0) - 8 December 2023
25
+
26
+ #### :hammer_and_wrench: Others
27
+
28
+ - Release 3.1.0 [Alin Voinea - [`2fad87e`](https://github.com/eea/volto-eea-map/commit/2fad87e5a8013b80183797df45ba6494e7ca396d)]
7
29
  ### [3.0.3](https://github.com/eea/volto-eea-map/compare/3.0.2...3.0.3) - 29 November 2023
8
30
 
9
31
  #### :hammer_and_wrench: Others
@@ -31,8 +53,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
31
53
  - fix prettier [Dobricean Ioan Dorian - [`78fc2ba`](https://github.com/eea/volto-eea-map/commit/78fc2baa2f5264ca1bba61b70bc0bdc5b2788e67)]
32
54
  - Fix Sonorqube [dobri1408 - [`e04011a`](https://github.com/eea/volto-eea-map/commit/e04011aa811422f865d0bbb1e66af558a4310e77)]
33
55
  - adapt embedeeamap to use serialized data [Dobricean Ioan Dorian - [`005965c`](https://github.com/eea/volto-eea-map/commit/005965c6793a9a9977fef52c08ba9a3173eec348)]
34
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`de2f4f6`](https://github.com/eea/volto-eea-map/commit/de2f4f6f516c2c9f7c2b4ea84373f4b1a21cd0af)]
35
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`4722984`](https://github.com/eea/volto-eea-map/commit/47229842132b406101c340ab200c193925b784ad)]
36
56
  ### [2.0.7](https://github.com/eea/volto-eea-map/compare/2.0.6...2.0.7) - 10 November 2023
37
57
 
38
58
  #### :rocket: New Features
@@ -49,7 +69,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
49
69
 
50
70
  #### :house: Internal changes
51
71
 
52
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`7afd81a`](https://github.com/eea/volto-eea-map/commit/7afd81a76bf407b07a94228daf3ab0415fbe4621)]
53
72
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`0ee38a7`](https://github.com/eea/volto-eea-map/commit/0ee38a7bee84694a5e0230e2d17083fbc071f0c8)]
54
73
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`8efeb44`](https://github.com/eea/volto-eea-map/commit/8efeb4423da70e421a88cabdeb559eb3613fb96e)]
55
74
  - chore: display legend for content type item, fix case when no note is set [dana-cfc4 - [`ae630a8`](https://github.com/eea/volto-eea-map/commit/ae630a88cffa2a8ef60e0bbfead392508b015497)]
@@ -59,10 +78,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
59
78
 
60
79
  #### :hammer_and_wrench: Others
61
80
 
62
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`335133d`](https://github.com/eea/volto-eea-map/commit/335133dc5186a53c1077bbead36100101bd9af45)]
63
81
  - Refs #260203: make background_image required [laszlocseh - [`baa5c4f`](https://github.com/eea/volto-eea-map/commit/baa5c4fa2fe618af51df12d48b4512ecafc357a8)]
64
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`4874649`](https://github.com/eea/volto-eea-map/commit/48746492a2b32a82d33d1c6415eab8a6f6b9f5be)]
65
- - test: [JENKINS] Improve cypress time [valentinab25 - [`7fa0b83`](https://github.com/eea/volto-eea-map/commit/7fa0b837b24f41a01285fd1b17daeefde99a9c76)]
66
82
  - use toolbar from volto-embed [Miu Razvan - [`29b73fb`](https://github.com/eea/volto-eea-map/commit/29b73fb8378ca56b3634bf1f7d57ce69a242b18e)]
67
83
  ### [2.0.6](https://github.com/eea/volto-eea-map/compare/2.0.5...2.0.6) - 29 September 2023
68
84
 
@@ -79,7 +95,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
79
95
 
80
96
  - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`4c6d141`](https://github.com/eea/volto-eea-map/commit/4c6d1413b67ffc3fe27a7d09dcc99ef98867cec9)]
81
97
  - test: Fix package.json scripts to use makefile [Alin Voinea - [`1cd6751`](https://github.com/eea/volto-eea-map/commit/1cd675118165d8631c41d35c00a8c902c7edd803)]
82
- - test: Fix eslint and yarn i18n [Alin Voinea - [`0184641`](https://github.com/eea/volto-eea-map/commit/018464116ba5b86b2c1e0a4ebc9b2fd95b772b66)]
83
98
  - i18n: Add en [Alin Voinea - [`1d29304`](https://github.com/eea/volto-eea-map/commit/1d293049a21e138fa933cd5ed9a04cceac1a5cff)]
84
99
  ### [2.0.5](https://github.com/eea/volto-eea-map/compare/2.0.4...2.0.5) - 23 August 2023
85
100
 
@@ -136,14 +151,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
136
151
  #### :hammer_and_wrench: Others
137
152
 
138
153
  - Release 2.0.0 [Alin Voinea - [`7be280d`](https://github.com/eea/volto-eea-map/commit/7be280d4809186e663f422687aca3c33dd732904)]
139
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`ba6ed22`](https://github.com/eea/volto-eea-map/commit/ba6ed22118406db979457384d4739cced2096137)]
140
154
  ### [1.0.2](https://github.com/eea/volto-eea-map/compare/1.0.1...1.0.2) - 21 July 2023
141
155
 
142
156
  #### :hammer_and_wrench: Others
143
157
 
144
158
  - Allow blocks in content type [Tiberiu Ichim - [`2ac09a6`](https://github.com/eea/volto-eea-map/commit/2ac09a613aba07f6cbaf42c386660f2d7d09bd13)]
145
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`403b4c0`](https://github.com/eea/volto-eea-map/commit/403b4c009e5aaded58203bc292ba3baa4631488b)]
146
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`aedb654`](https://github.com/eea/volto-eea-map/commit/aedb6544fd45b147a3385425aba46ffba108f5ca)]
147
159
  ### [1.0.1](https://github.com/eea/volto-eea-map/compare/1.0.0...1.0.1) - 22 June 2023
148
160
 
149
161
  #### :rocket: New Features
@@ -204,7 +216,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
204
216
 
205
217
  - chore: clear unused #254131 [andreiggr - [`ccec2ea`](https://github.com/eea/volto-eea-map/commit/ccec2eaab173c905cd4ea0190a9c6cfd630250f9)]
206
218
  - chore: clear block style #254131 [andreiggr - [`af500bc`](https://github.com/eea/volto-eea-map/commit/af500bc10a5f280eff0335f45bae1596d66a7e6b)]
207
- - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`76b29e5`](https://github.com/eea/volto-eea-map/commit/76b29e510f5156590723831a524bc39dfba6deba)]
208
219
 
209
220
  #### :hammer_and_wrench: Others
210
221
 
@@ -214,7 +225,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
214
225
  - * versions [andreiggr - [`6d9ff2b`](https://github.com/eea/volto-eea-map/commit/6d9ff2b26a236b6445678e3d84698d1c3c0826f4)]
215
226
  - add razzle-plugin-scss dep [andreiggr - [`d74cee5`](https://github.com/eea/volto-eea-map/commit/d74cee51d30c866afe55730e5b25e0bf11d2caea)]
216
227
  - volto-object-widget [andreiggr - [`18d0ed7`](https://github.com/eea/volto-eea-map/commit/18d0ed72c1ba7b0f7159a0eefc09ccea9acee5cb)]
217
- - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`5911d01`](https://github.com/eea/volto-eea-map/commit/5911d01f7f3bc79a2c834fab75a9a4ac05d2d042)]
218
228
  ### [0.1.32](https://github.com/eea/volto-eea-map/compare/0.1.31...0.1.32) - 20 February 2023
219
229
 
220
230
  #### :hammer_and_wrench: Others
@@ -222,7 +232,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
222
232
  - remove console.log [tedw87 - [`3aeb3e8`](https://github.com/eea/volto-eea-map/commit/3aeb3e8ec5474387f3cd22eb9b387c6681e17120)]
223
233
  - refactor code [tedw87 - [`6d7830e`](https://github.com/eea/volto-eea-map/commit/6d7830eb934f56c255eea5642bdefba30d892946)]
224
234
  - add Blossom basemap layer [tedw87 - [`5226ee2`](https://github.com/eea/volto-eea-map/commit/5226ee218df3401cf467afbc7a4d720dc30719e1)]
225
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`1dad5c6`](https://github.com/eea/volto-eea-map/commit/1dad5c6617096ff85223165a6dd2b1d5d7deea6a)]
226
235
  ### [0.1.31](https://github.com/eea/volto-eea-map/compare/0.1.30...0.1.31) - 11 November 2022
227
236
 
228
237
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "3.0.3",
3
+ "version": "3.2.0",
4
4
  "description": "@eeacms/volto-eea-map: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -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 { getMapVisualizationData } from './helpers';
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
- data_query_params,
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(() => getMapVisualizationData(props), [
37
- props,
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
- React.useEffect(() => {
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
- data_query_params,
93
+ queriesToUse,
54
94
  enable_queries,
55
95
  );
56
- setMapData(updatedMapData);
57
- }, [map_visualization_data, data_query_params, enable_queries]);
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
- mapContent: state.content.subrequests?.[props.id]?.data,
104
- data_query: state.content.data.data_query,
105
- }),
106
- {
107
- getContent,
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: [
@@ -107,7 +98,7 @@ export const Schema = (props) => {
107
98
  ],
108
99
  properties: {
109
100
  vis_url: {
110
- widget: 'object_by_path',
101
+ widget: 'internal_url',
111
102
  title: 'Visualization',
112
103
  },
113
104
  height: {
@@ -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 = (block, data, data_query, onChangeBlock) => {
5
- // If block data_query_params do not exist, init them
6
- if (!data?.data_query_params && data_query) {
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: [...data_query],
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(props) {
32
- const content = props.mapContent || {};
35
+ function getMapVisualizationData({ mapContent, data }) {
36
+ const content = mapContent || {};
33
37
  const map_visualization_data =
34
- content.map_visualization_data || props.data?.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 class="ri-external-link-line"></i>
16
+ More info <i className="ri-external-link-line"></i>
17
17
  </button>
18
18
  </Link>
19
19
  );
@@ -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 class="ri-share-fill"></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.i}:</strong> {param.v.join(', ')}
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, props) => ({
446
- content: state.content.data,
447
- data_query: state.content.data.data_query,
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
  },