@eeacms/volto-eea-map 0.1.9 → 0.1.12

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,30 @@ 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.12](https://github.com/eea/volto-eea-map/compare/0.1.11...0.1.12)
8
+
9
+ - cleanup [`53a2d89`](https://github.com/eea/volto-eea-map/commit/53a2d897675af2f75d8bd787ed07cdcfac69bdd0)
10
+ - get criteria and map it as query on fresh layers [`51f8087`](https://github.com/eea/volto-eea-map/commit/51f80870764d65140ac0a6408c01c0b63476bbd2)
11
+
12
+ #### [0.1.11](https://github.com/eea/volto-eea-map/compare/0.1.10...0.1.11)
13
+
14
+ > 18 August 2022
15
+
16
+ - Legend for each layer in object list [`#11`](https://github.com/eea/volto-eea-map/pull/11)
17
+ - Legend for all layers [`2d9285e`](https://github.com/eea/volto-eea-map/commit/2d9285e12ea512b7a1f24300ad2f7b3072e334d5)
18
+
19
+ #### [0.1.10](https://github.com/eea/volto-eea-map/compare/0.1.9...0.1.10)
20
+
21
+ > 17 August 2022
22
+
23
+ - EEA core metadata adaptation [`#10`](https://github.com/eea/volto-eea-map/pull/10)
24
+ - EEA core metadata adaptation for map block to [`5fb5724`](https://github.com/eea/volto-eea-map/commit/5fb5724164e1e9b1ae5143f9bd565c28118be253)
25
+
7
26
  #### [0.1.9](https://github.com/eea/volto-eea-map/compare/0.1.8...0.1.9)
8
27
 
28
+ > 12 August 2022
29
+
30
+ - Query builder for map layers queries [`#9`](https://github.com/eea/volto-eea-map/pull/9)
9
31
  - pinpoint query builder [`6184b0e`](https://github.com/eea/volto-eea-map/commit/6184b0e1dcee48e7d34bf56bc1c878438d07f987)
10
32
  - build query widget [`7a9d74a`](https://github.com/eea/volto-eea-map/commit/7a9d74a6fdac32a8b424c5ca97edd42df436cbe2)
11
33
 
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.12",
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",
@@ -1,14 +1,33 @@
1
1
  import React from 'react';
2
+
3
+ import { connect } from 'react-redux';
4
+ import { compose } from 'redux';
5
+
2
6
  import { SidebarPortal } from '@plone/volto/components';
3
7
  import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
8
+
4
9
  import { Schema } from './Schema';
5
10
  import View from './View';
11
+ import { getContent } from '@plone/volto/actions';
12
+
6
13
  import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
7
14
  import './styles/map.css';
8
15
 
9
16
  const Edit = (props) => {
10
17
  const { block, data, onChangeBlock, selected, id } = props;
11
18
  const schema = React.useMemo(() => Schema(props), [props]);
19
+ React.useEffect(() => {
20
+ if (
21
+ !data.data_query_params ||
22
+ props.data_query !== data.data_query_params
23
+ ) {
24
+ onChangeBlock(block, {
25
+ ...data,
26
+ data_query_params: props.data_query,
27
+ });
28
+ }
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ }, [props.data_query, block, data]);
12
31
 
13
32
  return (
14
33
  <div>
@@ -31,4 +50,15 @@ const Edit = (props) => {
31
50
  );
32
51
  };
33
52
 
34
- export default Edit;
53
+ export default compose(
54
+ connect(
55
+ (state, props) => ({
56
+ data_query: state.content.data.data_query,
57
+ data_provenance:
58
+ state.content.subrequests?.[props.id]?.data?.data_provenance,
59
+ }),
60
+ {
61
+ getContent,
62
+ },
63
+ ),
64
+ )(Edit);
@@ -7,26 +7,21 @@ 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
+ 'data_query_params',
16
17
  ],
17
18
  },
18
19
  ],
19
20
  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
- // },
21
+ show_sources: {
22
+ title: 'Show sources',
23
+ type: 'boolean',
24
+ },
30
25
  height: {
31
26
  title: 'Height',
32
27
  type: 'number',
@@ -52,6 +47,10 @@ export const Schema = (props) => {
52
47
  title: 'Show web viewer',
53
48
  type: 'boolean',
54
49
  },
50
+ data_query_params: {
51
+ title: 'Data query parameters',
52
+ widget: 'data_query_widget',
53
+ },
55
54
  },
56
55
  required: [],
57
56
  };
@@ -1,13 +1,24 @@
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 } = props || {};
9
13
  const { map_data = {}, height = '' } = data;
10
14
 
15
+ React.useEffect(() => {
16
+ if (path) {
17
+ props.getContent(path, null, id);
18
+ }
19
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20
+ }, [path]);
21
+
11
22
  return (
12
23
  <div>
13
24
  <PrivacyProtection data={data} {...props}>
@@ -18,4 +29,15 @@ const View = (props) => {
18
29
  );
19
30
  };
20
31
 
21
- export default View;
32
+ export default compose(
33
+ connect(
34
+ (state, props) => ({
35
+ data_query: state.content.subrequests?.[props.id]?.data?.data_query,
36
+ data_provenance:
37
+ state.content.subrequests?.[props.id]?.data?.data_provenance,
38
+ }),
39
+ {
40
+ getContent,
41
+ },
42
+ ),
43
+ )(View);
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { FormFieldWrapper, Field } from '@plone/volto/components';
3
+
4
+ const DataQueryWidget = (props) => {
5
+ const { value, onChange, id } = props;
6
+
7
+ const onChangeAlias = (fieldId, fieldValue) => {
8
+ let altValue = value;
9
+ value[fieldId] = { ...value[fieldId], alias: fieldValue };
10
+ onChange(id, altValue);
11
+ };
12
+
13
+ return (
14
+ <div>
15
+ <FormFieldWrapper {...props} noForInFieldLabel></FormFieldWrapper>
16
+ <div className="data-query-widget-field">
17
+ {value && value.length > 0 ? (
18
+ value.map((param, i) => (
19
+ <div key={i}>
20
+ <h5 style={{ fontWeight: 'bold' }}>{param.i}</h5>
21
+ <Field
22
+ id={i}
23
+ title="Alias"
24
+ type="string"
25
+ description="Data connector parameter alias for matchings. Default is {Key}"
26
+ onChange={onChangeAlias}
27
+ value={param?.alias}
28
+ />
29
+ <Field
30
+ id={param.i}
31
+ title="Values"
32
+ type="string"
33
+ description="Parameter value/s"
34
+ value={param.v.join(',')}
35
+ />
36
+ </div>
37
+ ))
38
+ ) : (
39
+ <p style={{ textAlign: 'center' }}>No parameters set</p>
40
+ )}
41
+ </div>
42
+ </div>
43
+ );
44
+ };
45
+
46
+ export default DataQueryWidget;
@@ -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,11 @@ 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';
6
+
7
+ import { connect } from 'react-redux';
8
+ import { compose } from 'redux';
9
+
10
+ import { getContent } from '@plone/volto/actions';
10
11
 
11
12
  import checkSVG from '@plone/volto/icons/check.svg';
12
13
  import closeSVG from '@plone/volto/icons/clear.svg';
@@ -16,7 +17,7 @@ import resetSVG from '@plone/volto/icons/reset.svg';
16
17
  import { fetchArcgisData } from '../../utils';
17
18
 
18
19
  const LayerSelectWidget = (props) => {
19
- const { onChange, id } = props;
20
+ const { onChange, id, data_query } = props;
20
21
 
21
22
  const value = React.useMemo(() => props.value || {}, [props.value]);
22
23
 
@@ -37,7 +38,6 @@ const LayerSelectWidget = (props) => {
37
38
  const [availableLayers, setAvailableLayers] = React.useState(
38
39
  available_layers,
39
40
  );
40
- //const [layerQuery, setLayerQuery] = React.useState(query);
41
41
 
42
42
  const [builtQuery, setBuiltQuery] = React.useState(query);
43
43
 
@@ -68,6 +68,55 @@ const LayerSelectWidget = (props) => {
68
68
  }
69
69
  };
70
70
 
71
+ React.useEffect(() => {
72
+ props.getContent('', null, id);
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, []);
75
+
76
+ React.useEffect(() => {
77
+ if (query && !builtQuery) {
78
+ setBuiltQuery(query);
79
+ }
80
+ }, [query, builtQuery]);
81
+
82
+ React.useEffect(() => {
83
+ //detect existing queries in block content. If it exists. Apply matching queries to layer on fresh layer load
84
+ if (
85
+ map_service_url &&
86
+ layer &&
87
+ !query &&
88
+ data_query &&
89
+ data_query.length > 0
90
+ ) {
91
+ let autoQuery = {
92
+ combinator: 'or',
93
+ rules: [],
94
+ };
95
+ data_query.forEach((param, i) => {
96
+ if (
97
+ fields &&
98
+ fields.length > 0 &&
99
+ fields.filter(
100
+ (field, j) => field.name === param.alias || field.name === param.i,
101
+ ).length > 0
102
+ ) {
103
+ autoQuery.rules = [
104
+ ...autoQuery.rules,
105
+ { field: param.alias || param.i, operator: '=', value: param.v[0] },
106
+ ];
107
+ }
108
+ });
109
+ if (autoQuery.rules.length > 0) {
110
+ onChange(id, {
111
+ ...value,
112
+ query: autoQuery,
113
+ });
114
+ setBuiltQuery(autoQuery);
115
+ }
116
+ }
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
118
+ }, [map_service_url, layer, query, data_query, fields]);
119
+
71
120
  const handleLayerFetch = async (service_url, id) => {
72
121
  try {
73
122
  let fullLayer = await fetchArcgisData(`${service_url}/${id}`);
@@ -134,8 +183,6 @@ const LayerSelectWidget = (props) => {
134
183
  style={{ width: '100%' }}
135
184
  error={serviceUrlError}
136
185
  value={serviceUrl}
137
- // action
138
- // actionPosition="right"
139
186
  ></Input>
140
187
 
141
188
  <span style={{ fontSize: '12px', color: 'darkred' }}>
@@ -188,14 +235,6 @@ const LayerSelectWidget = (props) => {
188
235
  <h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>
189
236
  Query Layer
190
237
  </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
238
  <Grid.Row>
200
239
  <QueryBuilder
201
240
  fields={fields.map((fi, i) => {
@@ -204,8 +243,6 @@ const LayerSelectWidget = (props) => {
204
243
  query={builtQuery}
205
244
  onQueryChange={(q) => setBuiltQuery(q)}
206
245
  enableDragAndDrop={false}
207
- //controlElements={bootstrapControlElements}
208
- //controlClassnames={bootstrapControlClassnames}
209
246
  />
210
247
  </Grid.Row>
211
248
  {builtQuery && (
@@ -245,4 +282,14 @@ const LayerSelectWidget = (props) => {
245
282
  );
246
283
  };
247
284
 
248
- export default LayerSelectWidget;
285
+ export default compose(
286
+ connect(
287
+ (state, props) => ({
288
+ content: state.content.data,
289
+ data_query: state.content.data.data_query,
290
+ }),
291
+ {
292
+ getContent,
293
+ },
294
+ ),
295
+ )(LayerSelectWidget);
@@ -6,16 +6,33 @@ import { Icon } from '@plone/volto/components';
6
6
  import rightKeySVG from '@plone/volto/icons/right-key.svg';
7
7
  import downKeySVG from '@plone/volto/icons/down-key.svg';
8
8
 
9
- const LayerLegend = ({ data, name }) => {
9
+ const LayerLegend = ({ data }) => {
10
10
  const [expand, setExpand] = React.useState(true);
11
+ const [legendRows, setLegendRows] = React.useState([]);
11
12
 
13
+ const { id, name } = data.layer || {};
14
+
15
+ const fetchLegend = async (url, activeLayerID) => {
16
+ let legendData = await fetchArcgisData(url);
17
+
18
+ const { layers = [] } = legendData;
19
+ const selectedLayer = layers.filter((l, i) => l.layerId === activeLayerID);
20
+ setLegendRows(selectedLayer[0].legend);
21
+ };
22
+
23
+ React.useEffect(() => {
24
+ if (data.map_service_url && id !== undefined) {
25
+ fetchLegend(`${data.map_service_url}/legend`, id);
26
+ }
27
+ // eslint-disable-next-line react-hooks/exhaustive-deps
28
+ }, [id, data.map_service_url]);
12
29
  return (
13
30
  <div style={{ display: 'flex', flexDirection: 'column' }}>
14
31
  <h5
15
32
  role="presentation"
16
33
  onClick={() => setExpand(!expand)}
17
34
  style={{
18
- marginTop: '10px',
35
+ marginTop: '15px',
19
36
  marginBottom: '5px',
20
37
  cursor: 'pointer',
21
38
  display: 'flex',
@@ -30,8 +47,8 @@ const LayerLegend = ({ data, name }) => {
30
47
  </h5>
31
48
  <div style={{ display: 'flex', flexDirection: 'column' }}>
32
49
  {expand &&
33
- data.length > 0 &&
34
- data.map((item, i) => {
50
+ legendRows.length > 0 &&
51
+ legendRows.map((item, i) => {
35
52
  return (
36
53
  <span key={i} style={{ display: 'flex', alignItems: 'center' }}>
37
54
  <img
@@ -53,49 +70,25 @@ const LegendWidget = (props) => {
53
70
  const data = React.useMemo(() => props.data, [props.data]);
54
71
  const { layers = {} } = data;
55
72
  const { map_layers = [] } = layers;
56
- const [legendLayers, setLegendLayers] = React.useState([]);
57
-
58
- const activeLayer = map_layers.length > 0 ? map_layers[0]?.map_layer : '';
59
73
 
60
- const fetchLegend = async (url) => {
61
- let legendData = await fetchArcgisData(url);
62
-
63
- //TODO: configure this for multiple layers
64
- const { layers = [] } = legendData;
65
- const selectedLayerLedend = layers.filter(
66
- (l, i) => l.layerId === activeLayer.layer.id,
67
- );
68
- setLegendLayers(selectedLayerLedend);
69
- };
70
-
71
- React.useEffect(() => {
72
- if (activeLayer) {
73
- fetchLegend(`${activeLayer.map_service_url}/legend`);
74
- }
75
- // eslint-disable-next-line react-hooks/exhaustive-deps
76
- }, [data, activeLayer.map_service_url]);
77
74
  return (
78
75
  <>
79
76
  <div style={{ margin: '10px 0' }}>
80
77
  <Grid>
81
78
  <Grid.Row>
82
79
  <Grid.Column>
83
- <h3>Legend:</h3>
84
- {!activeLayer && (
80
+ <h4>Legend:</h4>
81
+ {map_layers.length === 0 && (
85
82
  <p>
86
83
  No layer found for legend. Please add a map layer from editor.
87
84
  </p>
88
85
  )}
89
- {legendLayers.length > 0 &&
90
- legendLayers.map((layer, i) => {
91
- return (
92
- <LayerLegend
93
- key={i}
94
- name={layer?.layerName}
95
- data={layer?.legend}
96
- />
97
- );
98
- })}
86
+
87
+ {map_layers &&
88
+ map_layers.length > 0 &&
89
+ map_layers.map((l, i) => (
90
+ <LayerLegend key={i} data={l.map_layer} />
91
+ ))}
99
92
  </Grid.Column>
100
93
  </Grid.Row>
101
94
  </Grid>
@@ -37,7 +37,6 @@ const MapEditorWidget = (props) => {
37
37
  };
38
38
 
39
39
  let schema = PanelsSchema({ data: dataForm });
40
-
41
40
  return (
42
41
  <FormFieldWrapper {...props}>
43
42
  <Modal
@@ -4,7 +4,15 @@ import { ObjectWidget } from '@plone/volto/components';
4
4
  import { withDeviceSize } from '@eeacms/volto-eea-map/hocs';
5
5
 
6
6
  export const ObjectTypesWidget = (props) => {
7
- const { schemas, value = {}, onChange, errors = {}, id, device } = props;
7
+ const {
8
+ schemas,
9
+ value = {},
10
+ onChange,
11
+ errors = {},
12
+ id,
13
+ device,
14
+ block,
15
+ } = props;
8
16
  const objectId = id;
9
17
 
10
18
  const defaultActiveTab = 0;
@@ -30,6 +38,7 @@ export const ObjectTypesWidget = (props) => {
30
38
  <ObjectWidget
31
39
  schema={schema}
32
40
  id={id}
41
+ block={block}
33
42
  errors={errors}
34
43
  value={value[id] || {}}
35
44
  onChange={(schemaId, v) => {
@@ -103,6 +103,22 @@
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
+
118
+ .data-query-widget-field {
119
+ margin: 10px 0;
120
+ }
121
+
106
122
  @keyframes fadeDown {
107
123
  from {
108
124
  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);
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  EmbedMapEdit,
6
6
  } from '@eeacms/volto-eea-map/components';
7
7
  import world from '@plone/volto/icons/world.svg';
8
+ import DataQueryWidget from './components/Blocks/EEAMap/components/widgets/DataQueryWidget';
8
9
  import LayerSelectWidget from './components/Blocks/EEAMap/components/widgets/LayerSelectWidget';
9
10
  import MapEditorWidget from './components/Blocks/EEAMap/components/widgets/MapEditorWidget';
10
11
  import ObjectTypesWidget from './components/Blocks/EEAMap/components/widgets/ObjectTypesWidget';
@@ -89,6 +90,7 @@ export default (config) => {
89
90
  config.widgets.widget.map_edit_widget = MapEditorWidget;
90
91
  config.widgets.widget.map_layers_widget = LayerSelectWidget;
91
92
  config.widgets.widget.object_types_widget = ObjectTypesWidget;
93
+ config.widgets.widget.data_query_widget = DataQueryWidget;
92
94
 
93
95
  //map editor for the visualization(content-type)
94
96
  config.widgets.id.map_visualization_data = VisualizationEditorWidget;