@eeacms/volto-eea-map 0.1.35 → 1.0.1

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,29 @@ 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
+ ### [1.0.1](https://github.com/eea/volto-eea-map/compare/1.0.0...1.0.1) - 19 June 2023
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: use map_viz endpoint in eea.api.dataconnector [andreiggr - [`e6ce6dd`](https://github.com/eea/volto-eea-map/commit/e6ce6dd0a87343be8dae945780ef4b9ace6d830a)]
12
+
13
+ #### :house: Internal changes
14
+
15
+ - chore: useeffect updates improvements & cleanup unused layer wwidget [andreiggr - [`1b30d99`](https://github.com/eea/volto-eea-map/commit/1b30d99b481262d0184c8e5ad10331f0315d4f2a)]
16
+
17
+ ## [1.0.0](https://github.com/eea/volto-eea-map/compare/0.1.35...1.0.0) - 15 June 2023
18
+
19
+ #### :bug: Bug Fixes
20
+
21
+ - fix: fix style #254131 [Andrei Grigore - [`e0d1bf6`](https://github.com/eea/volto-eea-map/commit/e0d1bf6092d07ac0d2f98ff6febc9c01d97ce654)]
22
+ - fix: fix style #254131 [Andrei Grigore - [`2361110`](https://github.com/eea/volto-eea-map/commit/2361110243bc42d15ebcde736a811ad9260b92cb)]
23
+ - fix: fix style #254131 [Andrei Grigore - [`c846eb9`](https://github.com/eea/volto-eea-map/commit/c846eb9cbe1376f3c8c11b77a70dc123230bb6ec)]
24
+ - fix: fix style #254131 [Andrei Grigore - [`a6b962d`](https://github.com/eea/volto-eea-map/commit/a6b962d007d0d32c1ca8e7304ac75ce58e41c173)]
25
+
26
+ #### :house: Internal changes
27
+
28
+ - chore: increase version #254131 [Andrei Grigore - [`ec022cc`](https://github.com/eea/volto-eea-map/commit/ec022cc3b3d0c5e4b9158e7f28cf35edc5654600)]
29
+
7
30
  ### [0.1.35](https://github.com/eea/volto-eea-map/compare/0.1.34...0.1.35) - 14 June 2023
8
31
 
9
32
  #### :rocket: New Features
@@ -41,6 +64,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
41
64
 
42
65
  - chore: clear unused #254131 [andreiggr - [`ccec2ea`](https://github.com/eea/volto-eea-map/commit/ccec2eaab173c905cd4ea0190a9c6cfd630250f9)]
43
66
  - chore: clear block style #254131 [andreiggr - [`af500bc`](https://github.com/eea/volto-eea-map/commit/af500bc10a5f280eff0335f45bae1596d66a7e6b)]
67
+ - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`76b29e5`](https://github.com/eea/volto-eea-map/commit/76b29e510f5156590723831a524bc39dfba6deba)]
44
68
 
45
69
  #### :hammer_and_wrench: Others
46
70
 
@@ -50,6 +74,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
50
74
  - * versions [andreiggr - [`6d9ff2b`](https://github.com/eea/volto-eea-map/commit/6d9ff2b26a236b6445678e3d84698d1c3c0826f4)]
51
75
  - add razzle-plugin-scss dep [andreiggr - [`d74cee5`](https://github.com/eea/volto-eea-map/commit/d74cee51d30c866afe55730e5b25e0bf11d2caea)]
52
76
  - volto-object-widget [andreiggr - [`18d0ed7`](https://github.com/eea/volto-eea-map/commit/18d0ed72c1ba7b0f7159a0eefc09ccea9acee5cb)]
77
+ - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`5911d01`](https://github.com/eea/volto-eea-map/commit/5911d01f7f3bc79a2c834fab75a9a4ac05d2d042)]
53
78
  ### [0.1.32](https://github.com/eea/volto-eea-map/compare/0.1.31...0.1.32) - 20 February 2023
54
79
 
55
80
  #### :hammer_and_wrench: Others
@@ -57,6 +82,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
57
82
  - remove console.log [tedw87 - [`3aeb3e8`](https://github.com/eea/volto-eea-map/commit/3aeb3e8ec5474387f3cd22eb9b387c6681e17120)]
58
83
  - refactor code [tedw87 - [`6d7830e`](https://github.com/eea/volto-eea-map/commit/6d7830eb934f56c255eea5642bdefba30d892946)]
59
84
  - add Blossom basemap layer [tedw87 - [`5226ee2`](https://github.com/eea/volto-eea-map/commit/5226ee218df3401cf467afbc7a4d720dc30719e1)]
85
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`1dad5c6`](https://github.com/eea/volto-eea-map/commit/1dad5c6617096ff85223165a6dd2b1d5d7deea6a)]
60
86
  ### [0.1.31](https://github.com/eea/volto-eea-map/compare/0.1.30...0.1.31) - 11 November 2022
61
87
 
62
88
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "0.1.35",
3
+ "version": "1.0.1",
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",
@@ -4,12 +4,9 @@ import { SidebarPortal } from '@plone/volto/components';
4
4
  import { connect } from 'react-redux';
5
5
  import { compose } from 'redux';
6
6
 
7
- import { getContent } from '@plone/volto/actions';
8
-
9
7
  import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
10
8
  import Webmap from '@eeacms/volto-eea-map/components/Webmap';
11
9
  import ExtraViews from '@eeacms/volto-eea-map/components/ExtraViews';
12
- import '@eeacms/volto-eea-map/styles/map.css';
13
10
 
14
11
  import { Schema } from './Schema';
15
12
  import {
@@ -17,15 +14,10 @@ import {
17
14
  updateBlockQueryFromPageQuery,
18
15
  } from '@eeacms/volto-eea-map/utils';
19
16
 
17
+ import { getVisualization } from '@eeacms/volto-eea-map/actions';
18
+
20
19
  const Edit = (props) => {
21
- const {
22
- block,
23
- data,
24
- onChangeBlock,
25
- selected,
26
- id,
27
- data_provenance = {},
28
- } = props;
20
+ const { block, data, onChangeBlock, selected, data_provenance = {} } = props;
29
21
  const { height = '' } = data;
30
22
  const schema = Schema(props);
31
23
  const [mapData, setMapData] = React.useState('');
@@ -53,7 +45,7 @@ const Edit = (props) => {
53
45
  }, [data.show_legend, data.show_sources, data.dataprotection]);
54
46
 
55
47
  React.useEffect(() => {
56
- props.getContent(props.data.vis_url, null, id);
48
+ props.getVisualization(props.data.vis_url);
57
49
  // eslint-disable-next-line react-hooks/exhaustive-deps
58
50
  }, [props.data.vis_url]);
59
51
 
@@ -92,7 +84,11 @@ const Edit = (props) => {
92
84
  setMapData(updatedMapData);
93
85
 
94
86
  // eslint-disable-next-line react-hooks/exhaustive-deps
95
- }, [props.map_visualization, props.data]);
87
+ }, [
88
+ props.map_visualization,
89
+ props.data.data_query_params,
90
+ props.data.enable_queries,
91
+ ]);
96
92
 
97
93
  return (
98
94
  <>
@@ -133,13 +129,15 @@ export default compose(
133
129
  connect(
134
130
  (state, props) => ({
135
131
  data_query: state.content.data.data_query,
136
- data_provenance:
137
- state.content.subrequests?.[props.id]?.data?.data_provenance,
138
- map_visualization:
139
- state.content.subrequests?.[props.id]?.data?.map_visualization_data,
132
+ map_visualization: props.data.vis_url
133
+ ? state.map_visualizations?.data[props.data.vis_url]?.data
134
+ : '',
135
+ data_provenance: props.data.vis_url
136
+ ? state.map_visualizations?.data[props.data.vis_url]?.data_provenance
137
+ : '',
140
138
  }),
141
139
  {
142
- getContent,
140
+ getVisualization,
143
141
  },
144
142
  ),
145
143
  )(Edit);
@@ -5,19 +5,19 @@ import { compose } from 'redux';
5
5
 
6
6
  import { PrivacyProtection } from '@eeacms/volto-embed';
7
7
 
8
- import { getContent } from '@plone/volto/actions';
9
8
  import Webmap from '@eeacms/volto-eea-map/components/Webmap';
10
9
  import ExtraViews from '@eeacms/volto-eea-map/components/ExtraViews';
11
10
  import { applyQueriesToMapLayers } from '@eeacms/volto-eea-map/utils';
11
+ import { getVisualization } from '@eeacms/volto-eea-map/actions';
12
12
 
13
13
  const View = (props) => {
14
- const { data, id, data_provenance = {} } = props || {};
14
+ const { data, data_provenance = {} } = props || {};
15
15
  const { height = '' } = data;
16
16
 
17
17
  const [mapData, setMapData] = React.useState('');
18
18
 
19
19
  React.useEffect(() => {
20
- props.getContent(props.data.vis_url, null, id);
20
+ props.getVisualization(props.data.vis_url);
21
21
  // eslint-disable-next-line react-hooks/exhaustive-deps
22
22
  }, [props.data.vis_url]);
23
23
 
@@ -30,7 +30,11 @@ const View = (props) => {
30
30
 
31
31
  setMapData(updatedMapData);
32
32
  // eslint-disable-next-line react-hooks/exhaustive-deps
33
- }, [props.map_visualization, props.data]);
33
+ }, [
34
+ props.map_visualization,
35
+ props.data.data_query_params,
36
+ props.data.enable_queries,
37
+ ]);
34
38
 
35
39
  return (
36
40
  <PrivacyProtection data={data} height={height} {...props}>
@@ -56,13 +60,15 @@ const View = (props) => {
56
60
  export default compose(
57
61
  connect(
58
62
  (state, props) => ({
59
- data_provenance:
60
- state.content.subrequests?.[props.id]?.data?.data_provenance,
61
- map_visualization:
62
- state.content.subrequests?.[props.id]?.data?.map_visualization_data,
63
+ map_visualization: props.data.vis_url
64
+ ? state.map_visualizations?.data[props.data.vis_url]?.data
65
+ : '',
66
+ data_provenance: props.data.vis_url
67
+ ? state.map_visualizations?.data[props.data.vis_url]?.data_provenance
68
+ : '',
63
69
  }),
64
70
  {
65
- getContent,
71
+ getVisualization,
66
72
  },
67
73
  ),
68
74
  )(View);
@@ -1,47 +1,7 @@
1
1
  import React from 'react';
2
- import { UniversalLink, Icon } from '@plone/volto/components';
3
-
4
2
  import { serializeNodes } from '@plone/volto-slate/editor/render';
5
-
6
- import rightKeySVG from '@plone/volto/icons/right-key.svg';
7
- import downKeySVG from '@plone/volto/icons/down-key.svg';
8
3
  import LegendView from '@eeacms/volto-eea-map/components/LegendView';
9
-
10
- const SourcesWidget = ({ data }) => {
11
- const [expand, setExpand] = React.useState(true);
12
-
13
- return (
14
- <div>
15
- <button className="legend-action" onClick={() => setExpand(!expand)}>
16
- <h3>
17
- <Icon
18
- name={expand ? downKeySVG : rightKeySVG}
19
- title={expand ? 'Collapse' : 'Expand'}
20
- size="17px"
21
- />
22
- Sources:
23
- </h3>
24
- </button>
25
- {expand && (
26
- <ul>
27
- {data.map((param, i) => (
28
- <li key={i}>
29
- <div className="map_source_param_container">
30
- <UniversalLink className="map_source_title" href={param.link}>
31
- {param.title}
32
- </UniversalLink>
33
- ,
34
- <span className="map_source_description">
35
- {param.organisation}
36
- </span>
37
- </div>
38
- </li>
39
- ))}
40
- </ul>
41
- )}
42
- </div>
43
- );
44
- };
4
+ import Sources from './Sources';
45
5
 
46
6
  const ExtraViews = ({ data }) => {
47
7
  const {
@@ -58,17 +18,7 @@ const ExtraViews = ({ data }) => {
58
18
  {show_legend && map_data && (
59
19
  <LegendView data={map_data} show_viewer={show_viewer} />
60
20
  )}
61
- {show_sources && (
62
- <>
63
- {data_provenance &&
64
- data_provenance.data &&
65
- data_provenance.data.length > 0 ? (
66
- <SourcesWidget data={data_provenance.data} />
67
- ) : (
68
- <p>Data provenance is not set for visualization used or page</p>
69
- )}
70
- </>
71
- )}
21
+ {show_sources && <Sources sources={data_provenance?.data} />}
72
22
  {description && serializeNodes(description)}
73
23
  </div>
74
24
  );
@@ -116,14 +116,14 @@ const LegendView = (props) => {
116
116
  <>
117
117
  <div className="legend-container">
118
118
  <button className="legend-action" onClick={() => setExpand(!expand)}>
119
- <h3 role="presentation" className="legend-title">
120
- <Icon
121
- name={expand ? downKeySVG : rightKeySVG}
122
- title={expand ? 'Collapse' : 'Expand'}
123
- size="17px"
124
- />
125
- Legend:
126
- </h3>
119
+ {/* <h3 role="presentation" className="legend-title"> */}
120
+ <Icon
121
+ name={expand ? downKeySVG : rightKeySVG}
122
+ title={expand ? 'Collapse' : 'Expand'}
123
+ size="17px"
124
+ />
125
+ Legend:
126
+ {/* </h3> */}
127
127
  </button>
128
128
  <Grid columns={legendColumns}>
129
129
  {(!map_layers || map_layers.length === 0) && (
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+ import { Popup } from 'semantic-ui-react';
4
+ import { UniversalLink } from '@plone/volto/components';
5
+
6
+ const Link = ({ children, ...props }) => {
7
+ if (props.href) {
8
+ return <UniversalLink {...props}>{children}</UniversalLink>;
9
+ }
10
+ return <span {...props}>{children}</span>;
11
+ };
12
+
13
+ const Source = ({ source }) => {
14
+ if (source.chart_source_link && source.chart_source) {
15
+ return <Link href={source.chart_source_link}>{source.chart_source}</Link>;
16
+ }
17
+ if (source.chart_source) {
18
+ return <span>{source.chart_source}</span>;
19
+ }
20
+ return (
21
+ <>
22
+ <Link className="embed-sources-param-title" href={source.link}>
23
+ {source.title}
24
+ </Link>
25
+ ,<span style={{ marginLeft: '5px' }}>{source.organisation}</span>
26
+ </>
27
+ );
28
+ };
29
+
30
+ const SourcesWidget = ({ sources }) => {
31
+ const [expanded, setExpanded] = React.useState(false);
32
+ return (
33
+ <div className="eea-map-sources-container">
34
+ <Popup
35
+ content={
36
+ sources?.length ? (
37
+ <ol className="eea-map-sources-list">
38
+ {sources?.map((source, index) => {
39
+ return (
40
+ <li key={index}>
41
+ <Source source={source} />
42
+ </li>
43
+ );
44
+ })}
45
+ </ol>
46
+ ) : (
47
+ <p>Data provenance is not set for this visualization.</p>
48
+ )
49
+ }
50
+ position="bottom left"
51
+ popper={{ id: 'eea-map-sources-popup' }}
52
+ trigger={
53
+ <button className={cx('eea-map-sources-button', { expanded })}>
54
+ Sources
55
+ </button>
56
+ }
57
+ on="click"
58
+ onClose={() => {
59
+ setExpanded(false);
60
+ }}
61
+ onOpen={() => {
62
+ setExpanded(true);
63
+ }}
64
+ />
65
+ </div>
66
+ );
67
+ };
68
+
69
+ export default SourcesWidget;
@@ -30,9 +30,7 @@ const Webmap = (props) => {
30
30
  props.data.layers,
31
31
  ]);
32
32
  const base = React.useMemo(() => props?.data?.base || {}, [props.data.base]);
33
- const legend = React.useMemo(() => props?.data?.legend || {}, [
34
- props.data.legend,
35
- ]);
33
+
36
34
  const general = React.useMemo(() => props?.data?.general || {}, [
37
35
  props.data.general,
38
36
  ]);
@@ -49,10 +47,6 @@ const Webmap = (props) => {
49
47
  .filter(({ map_layer }) => map_layer)
50
48
  .map((l, i) => l.map_layer);
51
49
 
52
- const options = {
53
- css: true,
54
- };
55
-
56
50
  const mapRef = React.useRef();
57
51
  const [modules, setModules] = React.useState({});
58
52
 
@@ -61,7 +55,9 @@ const Webmap = (props) => {
61
55
  React.useEffect(() => {
62
56
  if (!modules_loaded.current) {
63
57
  modules_loaded.current = true;
64
- loadModules(MODULES, options).then((modules) => {
58
+ loadModules(MODULES, {
59
+ css: true,
60
+ }).then((modules) => {
65
61
  const [
66
62
  Map,
67
63
  MapView,
@@ -92,7 +88,7 @@ const Webmap = (props) => {
92
88
  });
93
89
  });
94
90
  }
95
- }, [setModules, options]);
91
+ }, [setModules]);
96
92
 
97
93
  var customFeatureLayerRenderer = {
98
94
  type: 'simple', // autocasts as new SimpleRenderer()
@@ -312,27 +308,6 @@ const Webmap = (props) => {
312
308
  });
313
309
  view.ui.add(zoomWidget, zoomPosition);
314
310
  }
315
-
316
- if (legend?.legend?.show_legend) {
317
- const legendPosition =
318
- legend && legend.legend && legend.legend.position
319
- ? legend.legend.position
320
- : 'top-right';
321
-
322
- const legendWidget = new Expand({
323
- content: new Legend({
324
- view: view,
325
- style: 'classic',
326
- }),
327
- view: view,
328
- expanded: false,
329
- expandIconClass: 'esri-icon-legend',
330
- expandTooltip: 'Legend',
331
- classNames: 'some-cool-expand',
332
- });
333
- view.ui.add(legendWidget, legendPosition);
334
- }
335
-
336
311
  const printPosition =
337
312
  general && general.print_position ? general.print_position : '';
338
313
 
package/src/index.js CHANGED
@@ -14,6 +14,8 @@ import SimpleColorPickerWidget from './components/widgets/SimpleColorPickerWidge
14
14
  import { data_visualizations } from './middlewares';
15
15
  import * as addonReducers from './reducers';
16
16
 
17
+ import './less/global.less';
18
+
17
19
  export default (config) => {
18
20
  config.settings.allowed_cors_destinations = [
19
21
  ...(config.settings.allowed_cors_destinations || []),
@@ -1,3 +1,21 @@
1
+ @import (multiple, reference, optional) '../../theme.config';
2
+
3
+ /* Enables customization of addons */
4
+ .loadAddonOverrides() {
5
+ @import (optional)
6
+ '@{siteFolder}/../addons/@{addon}/@{addontype}s/@{addonelement}.overrides';
7
+ }
8
+
9
+ /* Helper to load variables */
10
+ .loadAddonVariables() {
11
+ @import (optional) '@{addonelement}.variables';
12
+ @import (optional)
13
+ '@{siteFolder}/../addons/@{addon}/@{addontype}s/@{addonelement}.variables';
14
+ }
15
+
16
+ @import './variables.less';
17
+
18
+ // TODO: pull out colors and dimensions into variables
1
19
  .map-edit-container {
2
20
  display: flex;
3
21
  }
@@ -162,6 +180,8 @@
162
180
  }
163
181
 
164
182
  .legend-container {
183
+ display: flex;
184
+ flex-direction: column;
165
185
  margin: 15px 0;
166
186
  }
167
187
 
@@ -179,10 +199,20 @@
179
199
  }
180
200
 
181
201
  .legend-action {
182
- padding: 10px 0;
202
+ z-index: 22;
203
+ display: inline-flex;
204
+ align-items: center;
205
+ padding-bottom: 3px;
183
206
  border: none;
184
207
  background: transparent;
208
+ background-color: transparent;
209
+ color: #3d5265;
185
210
  cursor: pointer;
211
+ font-weight: bold;
212
+
213
+ &:hover {
214
+ color: @secondaryColor;
215
+ }
186
216
  }
187
217
 
188
218
  .map-number-input {
@@ -195,6 +225,46 @@
195
225
  color: green;
196
226
  }
197
227
 
228
+ /* sources */
229
+
230
+ .eea-map-sources-list {
231
+ margin: 0;
232
+ list-style: decimal inside;
233
+ padding-inline-start: 0;
234
+ }
235
+
236
+ #eea-map-sources-popup .ui.popup {
237
+ min-width: 600px;
238
+ background-color: #f9f9f9;
239
+ box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
240
+ }
241
+
242
+ .eea-map-sources-button {
243
+ display: inline-flex;
244
+ align-items: center;
245
+ padding-top: 10px;
246
+ padding-bottom: 3px;
247
+ border: none;
248
+ background-color: transparent;
249
+ color: @textColor;
250
+ cursor: pointer;
251
+ font-weight: bold;
252
+
253
+ .icon {
254
+ margin-left: 0.5rem;
255
+ }
256
+
257
+ &:hover {
258
+ color: @secondaryColor;
259
+ }
260
+
261
+ &.expanded {
262
+ padding-bottom: 0;
263
+ border-bottom: 3px solid @secondaryColor;
264
+ color: @secondaryColor;
265
+ }
266
+ }
267
+
198
268
  @keyframes fadeDown {
199
269
  from {
200
270
  opacity: 0;
@@ -212,4 +282,9 @@
212
282
  max-width: 0.2cm;
213
283
  height: 0.2cm;
214
284
  }
285
+
286
+ .eea-map-sources-container,
287
+ #eea-map-sources-popup {
288
+ display: none;
289
+ }
215
290
  }
@@ -0,0 +1,5 @@
1
+ @type: extra;
2
+
3
+ @element: custom;
4
+
5
+ @grey-1: #f9f9f9;