@eeacms/volto-eea-map 0.1.9 → 0.1.10

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,8 +4,16 @@ 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
+ #### [0.1.10](https://github.com/eea/volto-eea-map/compare/0.1.9...0.1.10)
8
+
9
+ - EEA core metadata adaptation for map block to [`5fb5724`](https://github.com/eea/volto-eea-map/commit/5fb5724164e1e9b1ae5143f9bd565c28118be253)
10
+ - EEA core metadata adaptation [`03b62a3`](https://github.com/eea/volto-eea-map/commit/03b62a35165670743d649282ae697dbf71c56a56)
11
+
7
12
  #### [0.1.9](https://github.com/eea/volto-eea-map/compare/0.1.8...0.1.9)
8
13
 
14
+ > 12 August 2022
15
+
16
+ - Query builder for map layers queries [`#9`](https://github.com/eea/volto-eea-map/pull/9)
9
17
  - pinpoint query builder [`6184b0e`](https://github.com/eea/volto-eea-map/commit/6184b0e1dcee48e7d34bf56bc1c878438d07f987)
10
18
  - build query widget [`7a9d74a`](https://github.com/eea/volto-eea-map/commit/7a9d74a6fdac32a8b424c5ca97edd42df436cbe2)
11
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
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",
@@ -7,26 +7,20 @@ export const Schema = (props) => {
7
7
  title: 'Default',
8
8
  fields: [
9
9
  'map_data',
10
- //...(use_visualization ? ['vis_url'] : ['map_data']),
11
10
  'description',
12
11
  'height',
13
12
  'show_legend',
14
13
  'show_download',
15
14
  'show_viewer',
15
+ 'show_sources',
16
16
  ],
17
17
  },
18
18
  ],
19
19
  properties: {
20
- // use_visualization: {
21
- // title: 'Use visualization',
22
- // description:
23
- // 'This setting will enable importing the map data from a visualization. If is enabled, editing the map manually will not be possible',
24
- // type: 'boolean',
25
- // },
26
- // vis_url: {
27
- // widget: 'object_by_path',
28
- // title: 'Visualization',
29
- // },
20
+ show_sources: {
21
+ title: 'Show sources',
22
+ type: 'boolean',
23
+ },
30
24
  height: {
31
25
  title: 'Height',
32
26
  type: 'number',
@@ -1,21 +1,43 @@
1
1
  import React from 'react';
2
2
 
3
+ import { connect } from 'react-redux';
4
+ import { compose } from 'redux';
5
+
3
6
  import Webmap from './components/Webmap';
4
7
  import ExtraViews from './components/widgets/ExtraViews';
5
8
  import { PrivacyProtection } from '@eeacms/volto-embed';
9
+ import { getContent } from '@plone/volto/actions';
6
10
 
7
11
  const View = (props) => {
8
- const { data, id } = props || {};
12
+ const { data, id, path, data_provenance } = props || {};
9
13
  const { map_data = {}, height = '' } = data;
10
14
 
15
+ React.useEffect(() => {
16
+ // get content from document
17
+ if (path) {
18
+ props.getContent(path, null, id);
19
+ }
20
+ // eslint-disable-next-line react-hooks/exhaustive-deps
21
+ }, [path]);
22
+
11
23
  return (
12
24
  <div>
13
25
  <PrivacyProtection data={data} {...props}>
14
26
  <Webmap data={map_data} height={height} id={id} />
15
- <ExtraViews data={data} />
27
+ <ExtraViews data={{ ...data, data_provenance }} />
16
28
  </PrivacyProtection>
17
29
  </div>
18
30
  );
19
31
  };
20
32
 
21
- export default View;
33
+ export default compose(
34
+ connect(
35
+ (state, props) => ({
36
+ data_provenance:
37
+ state.content.subrequests?.[props.id]?.data?.data_provenance,
38
+ }),
39
+ {
40
+ getContent,
41
+ },
42
+ ),
43
+ )(View);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Button } from 'semantic-ui-react';
3
- import { Icon } from '@plone/volto/components';
3
+ import { Icon, UniversalLink } from '@plone/volto/components';
4
4
 
5
5
  import LegendWidget from './LegendWidget';
6
6
  import { serializeNodes } from 'volto-slate/editor/render';
@@ -15,46 +15,69 @@ const ExtraViews = ({ data }) => {
15
15
  show_legend,
16
16
  show_download,
17
17
  show_viewer,
18
+ show_sources,
19
+ data_provenance = {},
18
20
  } = data;
19
-
20
21
  return (
21
22
  <div className="extra-eea-map-content">
22
- {map_data.layers?.map_layers[0] && (show_download || show_viewer) && (
23
- <div
24
- style={{ display: 'flex', justifyContent: 'end', margin: '10px 0' }}
25
- >
26
- {show_download && (
27
- <a
28
- target="_blank"
29
- rel="noreferrer"
30
- href={`${map_data.layers.map_layers[0].map_layer.map_service_url}?f=lyr&v=9.3`}
31
- >
32
- <Button size="tiny">
33
- <Button.Content>
34
- <Icon name={downloadSVG} title="Download" size="25px" />
35
- </Button.Content>
36
- </Button>
37
- </a>
38
- )}
39
- {show_viewer && (
40
- <a
41
- target="_blank"
42
- rel="noreferrer"
43
- href={
44
- `https://www.arcgis.com/home/webmap/viewer.html?url=` +
45
- `${map_data.layers.map_layers[0].map_layer.map_service_url}&source=sd`
46
- }
47
- >
48
- <Button size="tiny">
49
- <Button.Content>
50
- <Icon name={worldSVG} title="View map" size="25px" />
51
- </Button.Content>
52
- </Button>
53
- </a>
23
+ {map_data &&
24
+ map_data.layers?.map_layers[0] &&
25
+ (show_download || show_viewer) && (
26
+ <div
27
+ style={{ display: 'flex', justifyContent: 'end', margin: '10px 0' }}
28
+ >
29
+ {show_download && (
30
+ <a
31
+ target="_blank"
32
+ rel="noreferrer"
33
+ href={`${map_data.layers.map_layers[0].map_layer.map_service_url}?f=lyr&v=9.3`}
34
+ >
35
+ <Button size="tiny">
36
+ <Button.Content>
37
+ <Icon name={downloadSVG} title="Download" size="25px" />
38
+ </Button.Content>
39
+ </Button>
40
+ </a>
41
+ )}
42
+ {show_viewer && (
43
+ <a
44
+ target="_blank"
45
+ rel="noreferrer"
46
+ href={
47
+ `https://www.arcgis.com/home/webmap/viewer.html?url=` +
48
+ `${map_data.layers.map_layers[0].map_layer.map_service_url}&source=sd`
49
+ }
50
+ >
51
+ <Button size="tiny">
52
+ <Button.Content>
53
+ <Icon name={worldSVG} title="View map" size="25px" />
54
+ </Button.Content>
55
+ </Button>
56
+ </a>
57
+ )}
58
+ </div>
59
+ )}
60
+ {show_legend && map_data && <LegendWidget data={map_data} />}
61
+ {show_sources && (
62
+ <>
63
+ {data_provenance &&
64
+ data_provenance.data &&
65
+ data_provenance.data.length > 0 ? (
66
+ <div>
67
+ <h3>Sources:</h3>
68
+ {data_provenance.data.map((data, i) => (
69
+ <div key={i}>
70
+ <p className="map_source_title">{data.title}</p>
71
+ <p className="map_source_description">{data.organisation}</p>
72
+ <UniversalLink href={data.link}>{data.link} </UniversalLink>
73
+ </div>
74
+ ))}
75
+ </div>
76
+ ) : (
77
+ <p>Data provenance is not set for visualization used or page</p>
54
78
  )}
55
- </div>
79
+ </>
56
80
  )}
57
- {show_legend && <LegendWidget data={map_data} />}
58
81
  {description && serializeNodes(description)}
59
82
  </div>
60
83
  );
@@ -3,10 +3,6 @@ import { Icon } from '@plone/volto/components';
3
3
  import { Input, Select, Button, Grid } from 'semantic-ui-react';
4
4
  import { QueryBuilder } from 'react-querybuilder';
5
5
  import 'react-querybuilder/dist/query-builder.css';
6
- // import {
7
- // bootstrapControlClassnames,
8
- // bootstrapControlElements,
9
- // } from 'react-querybuilder/bootstrap';
10
6
 
11
7
  import checkSVG from '@plone/volto/icons/check.svg';
12
8
  import closeSVG from '@plone/volto/icons/clear.svg';
@@ -37,7 +33,6 @@ const LayerSelectWidget = (props) => {
37
33
  const [availableLayers, setAvailableLayers] = React.useState(
38
34
  available_layers,
39
35
  );
40
- //const [layerQuery, setLayerQuery] = React.useState(query);
41
36
 
42
37
  const [builtQuery, setBuiltQuery] = React.useState(query);
43
38
 
@@ -188,14 +183,6 @@ const LayerSelectWidget = (props) => {
188
183
  <h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>
189
184
  Query Layer
190
185
  </h5>
191
- <Grid.Row stretched>
192
- {/* <Input
193
- type="text"
194
- style={{ width: '100%' }}
195
- onChange={(e, { value }) => setLayerQuery(value)}
196
- value={layerQuery}
197
- ></Input> */}
198
- </Grid.Row>
199
186
  <Grid.Row>
200
187
  <QueryBuilder
201
188
  fields={fields.map((fi, i) => {
@@ -204,8 +191,6 @@ const LayerSelectWidget = (props) => {
204
191
  query={builtQuery}
205
192
  onQueryChange={(q) => setBuiltQuery(q)}
206
193
  enableDragAndDrop={false}
207
- //controlElements={bootstrapControlElements}
208
- //controlClassnames={bootstrapControlClassnames}
209
194
  />
210
195
  </Grid.Row>
211
196
  {builtQuery && (
@@ -103,6 +103,18 @@
103
103
  cursor: pointer;
104
104
  }
105
105
 
106
+ .map_source_title {
107
+ margin-top: 15px !important;
108
+ margin-bottom: 5px !important;
109
+ font-size: 18px;
110
+ font-weight: bold;
111
+ }
112
+
113
+ .map_source_description {
114
+ margin: 5px 0 !important;
115
+ font-size: 14px;
116
+ }
117
+
106
118
  @keyframes fadeDown {
107
119
  from {
108
120
  opacity: 0;
@@ -7,12 +7,12 @@ import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
7
7
  import './styles/map.css';
8
8
 
9
9
  const Edit = (props) => {
10
- const { block, data, onChangeBlock, selected } = props;
10
+ const { block, data, onChangeBlock, selected, id } = props;
11
11
  const schema = React.useMemo(() => Schema(props), [props]);
12
12
 
13
13
  return (
14
14
  <div>
15
- <View data={data} />
15
+ <View data={data} id={id} />
16
16
  <SidebarPortal selected={selected}>
17
17
  <BlockDataForm
18
18
  block={block}
@@ -12,6 +12,7 @@ export const Schema = (props) => {
12
12
  'show_legend',
13
13
  'show_download',
14
14
  'show_viewer',
15
+ 'show_sources',
15
16
  ],
16
17
  },
17
18
  ],
@@ -28,6 +29,10 @@ export const Schema = (props) => {
28
29
  title: 'Description',
29
30
  widget: 'slate',
30
31
  },
32
+ show_sources: {
33
+ title: 'Show sources',
34
+ type: 'boolean',
35
+ },
31
36
  show_legend: {
32
37
  title: 'Show legend',
33
38
  type: 'boolean',
@@ -6,15 +6,18 @@ import { compose } from 'redux';
6
6
  import { PrivacyProtection } from '@eeacms/volto-embed';
7
7
  import Webmap from '../EEAMap/components/Webmap';
8
8
  import ExtraViews from '../EEAMap/components/widgets/ExtraViews';
9
- import { getVisualization } from '@eeacms/volto-eea-map/actions';
9
+ import { getContent } from '@plone/volto/actions';
10
10
 
11
11
  const View = (props) => {
12
- const { data, map_visualization } = props || {};
12
+ const { data, viz_content = {}, id } = props || {};
13
13
  const { height = '', vis_url = '' } = data;
14
14
 
15
+ const { map_visualization_data = '', data_provenance = {} } =
16
+ viz_content || {};
17
+
15
18
  React.useEffect(() => {
16
19
  if (vis_url) {
17
- props.getVisualization(vis_url);
20
+ props.getContent(vis_url, null, id);
18
21
  }
19
22
  // eslint-disable-next-line react-hooks/exhaustive-deps
20
23
  }, [vis_url]);
@@ -22,13 +25,19 @@ const View = (props) => {
22
25
  return (
23
26
  <div>
24
27
  <PrivacyProtection data={data} {...props}>
25
- {map_visualization && (
28
+ {map_visualization_data && (
26
29
  <div>
27
- <Webmap data={map_visualization.data} height={height} />
28
- <ExtraViews data={{ ...data, map_data: map_visualization.data }} />
30
+ <Webmap data={map_visualization_data} height={height} />
31
+ <ExtraViews
32
+ data={{
33
+ ...data,
34
+ data_provenance,
35
+ map_data: map_visualization_data,
36
+ }}
37
+ />
29
38
  </div>
30
39
  )}
31
- {!map_visualization && (
40
+ {!map_visualization_data && (
32
41
  <p>No map view to show. Set visualization in block configuration.</p>
33
42
  )}
34
43
  </PrivacyProtection>
@@ -39,10 +48,10 @@ const View = (props) => {
39
48
  export default compose(
40
49
  connect(
41
50
  (state, props) => ({
42
- map_visualization: state.map_visualizations.data[props.data.vis_url],
51
+ viz_content: state.content.subrequests?.[props.id]?.data,
43
52
  }),
44
53
  {
45
- getVisualization,
54
+ getContent,
46
55
  },
47
56
  ),
48
57
  )(View);