@eeacms/volto-eea-map 0.1.12 → 0.1.15
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 +38 -0
- package/package.json +3 -2
- package/src/actionTypes.js +1 -0
- package/src/actions.js +1 -1
- package/src/components/Blocks/EEAMap/Edit.jsx +2 -1
- package/src/components/Blocks/EEAMap/Schema.js +3 -5
- package/src/components/Blocks/EEAMap/View.jsx +3 -2
- package/src/components/Blocks/EmbedEEAMap/Edit.jsx +39 -4
- package/src/components/Blocks/EmbedEEAMap/Schema.js +16 -5
- package/src/components/Blocks/EmbedEEAMap/View.jsx +64 -12
- package/src/components/ExtraViews.jsx +85 -0
- package/src/components/{Blocks/EEAMap/components/Webmap.jsx → Webmap.jsx} +33 -31
- package/src/components/index.js +6 -6
- package/src/components/visualization/VisualizationEditorWidget.jsx +121 -0
- package/src/components/{Blocks/EEAMap/components/widgets → visualization}/VisualizationView.jsx +0 -0
- package/src/components/{Blocks/EEAMap/components/widgets → visualization}/panelsSchema.js +0 -1
- package/src/components/widgets/DataQueryWidget.jsx +50 -0
- package/src/components/{Blocks/EEAMap/components/widgets → widgets}/LayerSelectWidget.jsx +102 -46
- package/src/components/{Blocks/EEAMap/components/widgets/LayersPanel.jsx → widgets/LayersPanelWidget.jsx} +2 -2
- package/src/components/{Blocks/EEAMap/components/widgets → widgets}/LegendWidget.jsx +43 -31
- package/src/components/{Blocks/EEAMap/components/widgets → widgets}/MapEditorWidget.jsx +1 -0
- package/src/components/{Blocks/EEAMap/components/widgets → widgets}/ObjectTypesWidget.jsx +1 -2
- package/src/components/widgets/panelsSchema.js +151 -0
- package/src/constants.js +29 -1
- package/src/index.js +41 -41
- package/src/middlewares/index.js +1 -1
- package/src/reducers/map_visualizations.js +1 -1
- package/src/static/code-line.svg +1 -0
- package/src/{components/Blocks/EEAMap/styles → styles}/map.css +66 -5
- package/src/{components/Blocks/EEAMap/utils.js → utils.js} +18 -2
- package/src/components/Blocks/EEAMap/components/widgets/DataQueryWidget.jsx +0 -46
- package/src/components/Blocks/EEAMap/components/widgets/ExtraViews.jsx +0 -86
- package/src/components/Blocks/EEAMap/components/widgets/VisualizationEditorWidget.jsx +0 -94
- package/src/components/Blocks/EEAMap/constants.js +0 -29
- package/src/components/Blocks/EmbedEEAMap/styles/map.css +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,46 @@ 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.15](https://github.com/eea/volto-eea-map/compare/0.1.14...0.1.15)
|
|
8
|
+
|
|
9
|
+
- more space for button [`8fa6a3b`](https://github.com/eea/volto-eea-map/commit/8fa6a3b230cd835d0fbcc4881b14d51d318b91be)
|
|
10
|
+
- eslint happy [`30b41d2`](https://github.com/eea/volto-eea-map/commit/30b41d2d18fcf2d195cdd08a2b6b9c78e6a303bb)
|
|
11
|
+
- better update [`a1ca2f5`](https://github.com/eea/volto-eea-map/commit/a1ca2f51d1f24d932ad03fe61b5a4a564b491873)
|
|
12
|
+
- update deps [`c9d2f92`](https://github.com/eea/volto-eea-map/commit/c9d2f920c076e77f030cd841ca5a1e49cc1bc319)
|
|
13
|
+
- use only query params from qidget [`303793f`](https://github.com/eea/volto-eea-map/commit/303793f6f3af8c0cf8857e08a61cbf9e16c7d810)
|
|
14
|
+
- get map data from getContent [`40ae731`](https://github.com/eea/volto-eea-map/commit/40ae73135cd93e49ce0956d4ca0ef5e3425e3d19)
|
|
15
|
+
- use button on action [`86a090b`](https://github.com/eea/volto-eea-map/commit/86a090b17ccf3f951146cb8adcaf539fd8cf9faf)
|
|
16
|
+
|
|
17
|
+
#### [0.1.14](https://github.com/eea/volto-eea-map/compare/0.1.13...0.1.14)
|
|
18
|
+
|
|
19
|
+
> 26 August 2022
|
|
20
|
+
|
|
21
|
+
- Develop [`#14`](https://github.com/eea/volto-eea-map/pull/14)
|
|
22
|
+
- new sources styles, icons from remixicon [`c9cca2a`](https://github.com/eea/volto-eea-map/commit/c9cca2a5e41322cfdeca1865b47a1892514c1cfc)
|
|
23
|
+
- reorganize & clean [`a902b89`](https://github.com/eea/volto-eea-map/commit/a902b8945389b19b388e85e00066b2c46a9e1a2e)
|
|
24
|
+
- Layer widget improvements [`99abe57`](https://github.com/eea/volto-eea-map/commit/99abe5722590719ac7e640de44a69ee19fcecfdf)
|
|
25
|
+
- Change data queries cards [`8d3c742`](https://github.com/eea/volto-eea-map/commit/8d3c74239f62782737108c25e84683239e6ab12f)
|
|
26
|
+
- Set default settings [`2c26f57`](https://github.com/eea/volto-eea-map/commit/2c26f571618d289158c7d32fd9814edcd29a7c60)
|
|
27
|
+
- Add description to layer [`cccfd59`](https://github.com/eea/volto-eea-map/commit/cccfd598060c4228215a5add1da3e159312966b2)
|
|
28
|
+
- only embed viz for now [`6bb7daf`](https://github.com/eea/volto-eea-map/commit/6bb7daf458a47bd185870ec3627a542f8ba715bc)
|
|
29
|
+
- Visualization improvements [`2a77f8b`](https://github.com/eea/volto-eea-map/commit/2a77f8bba1f6fd840d41043ee41b1b3bd23807f3)
|
|
30
|
+
- Cleanup [`6d6ceb9`](https://github.com/eea/volto-eea-map/commit/6d6ceb99768ff477a727cf217e48099e6f2d1a59)
|
|
31
|
+
- Add all query parameters with all values [`2f8c617`](https://github.com/eea/volto-eea-map/commit/2f8c61711154953ec25e20614b4ad96ed2bf592b)
|
|
32
|
+
- Data query widget visual improvements [`7eb3144`](https://github.com/eea/volto-eea-map/commit/7eb3144ad58a839ccc96f22d58a441b245893ea7)
|
|
33
|
+
- Data query widget more responsive to changes [`bb86329`](https://github.com/eea/volto-eea-map/commit/bb863299d51627a28f02e2cda133fc0e3bf9ebe9)
|
|
34
|
+
|
|
35
|
+
#### [0.1.13](https://github.com/eea/volto-eea-map/compare/0.1.12...0.1.13)
|
|
36
|
+
|
|
37
|
+
> 22 August 2022
|
|
38
|
+
|
|
39
|
+
- Enable Embed EEA map access to data_query [`#13`](https://github.com/eea/volto-eea-map/pull/13)
|
|
40
|
+
- update embed map with data_query [`719c007`](https://github.com/eea/volto-eea-map/commit/719c00776dff7ba63bbd57761a2c86ec5345a911)
|
|
41
|
+
|
|
7
42
|
#### [0.1.12](https://github.com/eea/volto-eea-map/compare/0.1.11...0.1.12)
|
|
8
43
|
|
|
44
|
+
> 22 August 2022
|
|
45
|
+
|
|
46
|
+
- Develop [`#12`](https://github.com/eea/volto-eea-map/pull/12)
|
|
9
47
|
- cleanup [`53a2d89`](https://github.com/eea/volto-eea-map/commit/53a2d897675af2f75d8bd787ed07cdcfac69bdd0)
|
|
10
48
|
- get criteria and map it as query on fresh layers [`51f8087`](https://github.com/eea/volto-eea-map/commit/51f80870764d65140ac0a6408c01c0b63476bbd2)
|
|
11
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-eea-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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",
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
"volto-slate"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@eeacms/volto-embed": "
|
|
24
|
+
"@eeacms/volto-embed": "4.0.2",
|
|
25
25
|
"@plone/scripts": "*",
|
|
26
26
|
"esri-loader": "3.5.0",
|
|
27
|
+
"lodash": "4.17.21",
|
|
27
28
|
"react-querybuilder": "4.2.3",
|
|
28
29
|
"volto-slate": "*"
|
|
29
30
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GET_MAP_VISUALIZATION = 'GET_MAP_VISUALIZATION';
|
package/src/actions.js
CHANGED
|
@@ -11,11 +11,12 @@ import View from './View';
|
|
|
11
11
|
import { getContent } from '@plone/volto/actions';
|
|
12
12
|
|
|
13
13
|
import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
|
|
14
|
-
import '
|
|
14
|
+
import '../../../styles/map.css';
|
|
15
15
|
|
|
16
16
|
const Edit = (props) => {
|
|
17
17
|
const { block, data, onChangeBlock, selected, id } = props;
|
|
18
18
|
const schema = React.useMemo(() => Schema(props), [props]);
|
|
19
|
+
|
|
19
20
|
React.useEffect(() => {
|
|
20
21
|
if (
|
|
21
22
|
!data.data_query_params ||
|
|
@@ -39,16 +39,14 @@ export const Schema = (props) => {
|
|
|
39
39
|
title: 'Show legend',
|
|
40
40
|
type: 'boolean',
|
|
41
41
|
},
|
|
42
|
-
|
|
43
|
-
title: 'Show download',
|
|
44
|
-
type: 'boolean',
|
|
45
|
-
},
|
|
42
|
+
|
|
46
43
|
show_viewer: {
|
|
47
44
|
title: 'Show web viewer',
|
|
48
45
|
type: 'boolean',
|
|
49
46
|
},
|
|
50
47
|
data_query_params: {
|
|
51
|
-
title: '
|
|
48
|
+
title: 'Query parameters',
|
|
49
|
+
description: 'ddafdfas',
|
|
52
50
|
widget: 'data_query_widget',
|
|
53
51
|
},
|
|
54
52
|
},
|
|
@@ -3,8 +3,9 @@ import React from 'react';
|
|
|
3
3
|
import { connect } from 'react-redux';
|
|
4
4
|
import { compose } from 'redux';
|
|
5
5
|
|
|
6
|
-
import Webmap from '
|
|
7
|
-
import ExtraViews from '
|
|
6
|
+
import Webmap from '../../Webmap';
|
|
7
|
+
import ExtraViews from '../../ExtraViews';
|
|
8
|
+
|
|
8
9
|
import { PrivacyProtection } from '@eeacms/volto-embed';
|
|
9
10
|
import { getContent } from '@plone/volto/actions';
|
|
10
11
|
|
|
@@ -1,18 +1,43 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SidebarPortal } from '@plone/volto/components';
|
|
3
|
+
|
|
4
|
+
import { connect } from 'react-redux';
|
|
5
|
+
import { compose } from 'redux';
|
|
6
|
+
|
|
7
|
+
import { getContent } from '@plone/volto/actions';
|
|
8
|
+
|
|
3
9
|
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
4
|
-
import { Schema } from './Schema';
|
|
5
10
|
import View from './View';
|
|
11
|
+
import { Schema } from './Schema';
|
|
6
12
|
import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
|
|
7
|
-
import '
|
|
13
|
+
import '../../../styles/map.css';
|
|
14
|
+
|
|
15
|
+
import _ from 'lodash';
|
|
8
16
|
|
|
9
17
|
const Edit = (props) => {
|
|
10
18
|
const { block, data, onChangeBlock, selected, id } = props;
|
|
11
19
|
const schema = React.useMemo(() => Schema(props), [props]);
|
|
12
20
|
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
props.getContent(data.vis_url, null, id);
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [data.vis_url]);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
if (
|
|
27
|
+
!data.data_query_params ||
|
|
28
|
+
!_.isEqual(props.data_query, data.data_query_params)
|
|
29
|
+
) {
|
|
30
|
+
onChangeBlock(block, {
|
|
31
|
+
...data,
|
|
32
|
+
data_query_params: props.data_query,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
}, [props.data_query, block, data.data_query_params]);
|
|
37
|
+
|
|
13
38
|
return (
|
|
14
39
|
<div>
|
|
15
|
-
<View data={data} id={id} />
|
|
40
|
+
<View data={data} id={id} isEdit={true} />
|
|
16
41
|
<SidebarPortal selected={selected}>
|
|
17
42
|
<BlockDataForm
|
|
18
43
|
block={block}
|
|
@@ -31,4 +56,14 @@ const Edit = (props) => {
|
|
|
31
56
|
);
|
|
32
57
|
};
|
|
33
58
|
|
|
34
|
-
export default
|
|
59
|
+
export default compose(
|
|
60
|
+
connect(
|
|
61
|
+
(state, props) => ({
|
|
62
|
+
block_data: state.content.data,
|
|
63
|
+
data_query: state.content.data.data_query,
|
|
64
|
+
}),
|
|
65
|
+
{
|
|
66
|
+
getContent,
|
|
67
|
+
},
|
|
68
|
+
),
|
|
69
|
+
)(Edit);
|
|
@@ -10,9 +10,10 @@ export const Schema = (props) => {
|
|
|
10
10
|
'description',
|
|
11
11
|
'height',
|
|
12
12
|
'show_legend',
|
|
13
|
-
'show_download',
|
|
14
13
|
'show_viewer',
|
|
15
14
|
'show_sources',
|
|
15
|
+
'enable_queries',
|
|
16
|
+
...(props.data.enable_queries ? ['data_query_params'] : []),
|
|
16
17
|
],
|
|
17
18
|
},
|
|
18
19
|
],
|
|
@@ -31,20 +32,30 @@ export const Schema = (props) => {
|
|
|
31
32
|
},
|
|
32
33
|
show_sources: {
|
|
33
34
|
title: 'Show sources',
|
|
35
|
+
description: 'Will show sources set in this page Data provenance',
|
|
34
36
|
type: 'boolean',
|
|
35
37
|
},
|
|
36
38
|
show_legend: {
|
|
37
39
|
title: 'Show legend',
|
|
38
40
|
type: 'boolean',
|
|
39
41
|
},
|
|
40
|
-
|
|
41
|
-
title: 'Show
|
|
42
|
+
show_viewer: {
|
|
43
|
+
title: 'Show API link',
|
|
44
|
+
description: 'Open the map on ArcGIS js service',
|
|
42
45
|
type: 'boolean',
|
|
43
46
|
},
|
|
44
|
-
|
|
45
|
-
title: '
|
|
47
|
+
enable_queries: {
|
|
48
|
+
title: 'Enable queries',
|
|
49
|
+
description:
|
|
50
|
+
'Will import Criteria from content-type and try to query map layer fields.',
|
|
46
51
|
type: 'boolean',
|
|
47
52
|
},
|
|
53
|
+
data_query_params: {
|
|
54
|
+
title: 'Query parameters',
|
|
55
|
+
description:
|
|
56
|
+
'When using page level parameters to filter the map, please map those to the corresponding field name from the ArcGIS service',
|
|
57
|
+
widget: 'data_query_widget',
|
|
58
|
+
},
|
|
48
59
|
},
|
|
49
60
|
required: [],
|
|
50
61
|
};
|
|
@@ -4,40 +4,88 @@ import { connect } from 'react-redux';
|
|
|
4
4
|
import { compose } from 'redux';
|
|
5
5
|
|
|
6
6
|
import { PrivacyProtection } from '@eeacms/volto-embed';
|
|
7
|
-
|
|
8
|
-
import ExtraViews from '../EEAMap/components/widgets/ExtraViews';
|
|
7
|
+
|
|
9
8
|
import { getContent } from '@plone/volto/actions';
|
|
9
|
+
import Webmap from '../../Webmap';
|
|
10
|
+
import ExtraViews from '../../ExtraViews';
|
|
10
11
|
|
|
11
12
|
const View = (props) => {
|
|
12
|
-
const { data,
|
|
13
|
-
|
|
13
|
+
const { data, id, isEdit, map_visualization = {}, data_provenance = {} } =
|
|
14
|
+
props || {};
|
|
15
|
+
const { height = '', vis_url = '', enable_queries } = data;
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
viz_content || {};
|
|
17
|
+
const [mapData, setMapData] = React.useState(map_visualization);
|
|
17
18
|
|
|
18
19
|
React.useEffect(() => {
|
|
19
20
|
if (vis_url) {
|
|
20
21
|
props.getContent(vis_url, null, id);
|
|
21
22
|
}
|
|
22
23
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
-
}, [vis_url]);
|
|
24
|
+
}, [vis_url, enable_queries]);
|
|
25
|
+
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
const query_params = props?.data?.data_query_params;
|
|
28
|
+
var altMapData = { ...map_visualization };
|
|
29
|
+
|
|
30
|
+
if (
|
|
31
|
+
enable_queries &&
|
|
32
|
+
query_params &&
|
|
33
|
+
query_params.length > 0 &&
|
|
34
|
+
altMapData.layers &&
|
|
35
|
+
altMapData.layers.map_layers &&
|
|
36
|
+
altMapData.layers.map_layers.length > 0
|
|
37
|
+
) {
|
|
38
|
+
let rules = [];
|
|
39
|
+
altMapData.layers.map_layers.forEach((l, j) => {
|
|
40
|
+
query_params.forEach((param, i) => {
|
|
41
|
+
const matchingFields =
|
|
42
|
+
l.map_layer && l.map_layer.fields && l.map_layer.fields.length > 0
|
|
43
|
+
? l.map_layer.fields.filter(
|
|
44
|
+
(field, k) =>
|
|
45
|
+
field.name === param.alias || field.name === param.i,
|
|
46
|
+
)
|
|
47
|
+
: [];
|
|
48
|
+
|
|
49
|
+
matchingFields.forEach((m, i) => {
|
|
50
|
+
const newRules = param.v
|
|
51
|
+
? param.v.map((paramVal, i) => {
|
|
52
|
+
return {
|
|
53
|
+
field: m.name,
|
|
54
|
+
operator: '=',
|
|
55
|
+
value: paramVal,
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
: [];
|
|
59
|
+
rules = rules.concat(newRules);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
let autoQuery = {
|
|
63
|
+
combinator: 'or',
|
|
64
|
+
rules,
|
|
65
|
+
};
|
|
66
|
+
altMapData.layers.map_layers[j].map_layer.query = autoQuery;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
setMapData(altMapData);
|
|
70
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
71
|
+
}, [map_visualization, props.data, props.data_query, isEdit, enable_queries]);
|
|
24
72
|
|
|
25
73
|
return (
|
|
26
74
|
<div>
|
|
27
75
|
<PrivacyProtection data={data} {...props}>
|
|
28
|
-
{
|
|
76
|
+
{mapData && (
|
|
29
77
|
<div>
|
|
30
|
-
<Webmap data={
|
|
78
|
+
<Webmap data={mapData} height={height} />
|
|
31
79
|
<ExtraViews
|
|
32
80
|
data={{
|
|
33
81
|
...data,
|
|
34
82
|
data_provenance,
|
|
35
|
-
map_data:
|
|
83
|
+
map_data: map_visualization,
|
|
36
84
|
}}
|
|
37
85
|
/>
|
|
38
86
|
</div>
|
|
39
87
|
)}
|
|
40
|
-
{!
|
|
88
|
+
{!mapData && (
|
|
41
89
|
<p>No map view to show. Set visualization in block configuration.</p>
|
|
42
90
|
)}
|
|
43
91
|
</PrivacyProtection>
|
|
@@ -48,7 +96,11 @@ const View = (props) => {
|
|
|
48
96
|
export default compose(
|
|
49
97
|
connect(
|
|
50
98
|
(state, props) => ({
|
|
51
|
-
|
|
99
|
+
data_query: state.content.data.data_query,
|
|
100
|
+
data_provenance:
|
|
101
|
+
state.content.subrequests?.[props.id]?.data?.data_provenance,
|
|
102
|
+
map_visualization:
|
|
103
|
+
state.content.subrequests?.[props.id]?.data?.map_visualization_data,
|
|
52
104
|
}),
|
|
53
105
|
{
|
|
54
106
|
getContent,
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from 'semantic-ui-react';
|
|
3
|
+
import { UniversalLink } from '@plone/volto/components';
|
|
4
|
+
|
|
5
|
+
import LegendWidget from './widgets/LegendWidget';
|
|
6
|
+
import { serializeNodes } from 'volto-slate/editor/render';
|
|
7
|
+
|
|
8
|
+
import codeSVG from '../static/code-line.svg';
|
|
9
|
+
|
|
10
|
+
const ExtraViews = ({ data }) => {
|
|
11
|
+
const {
|
|
12
|
+
map_data = {},
|
|
13
|
+
description,
|
|
14
|
+
show_legend,
|
|
15
|
+
show_viewer,
|
|
16
|
+
show_sources,
|
|
17
|
+
data_provenance = {},
|
|
18
|
+
} = data;
|
|
19
|
+
return (
|
|
20
|
+
<div className="extra-eea-map-content">
|
|
21
|
+
{map_data && map_data.layers?.map_layers[0] && show_viewer && (
|
|
22
|
+
<div
|
|
23
|
+
style={{ display: 'flex', justifyContent: 'end', margin: '10px 0' }}
|
|
24
|
+
>
|
|
25
|
+
{show_viewer && (
|
|
26
|
+
<a
|
|
27
|
+
target="_blank"
|
|
28
|
+
rel="noreferrer"
|
|
29
|
+
href={
|
|
30
|
+
`https://www.arcgis.com/home/webmap/viewer.html?url=` +
|
|
31
|
+
`${map_data.layers.map_layers[0].map_layer.map_service_url}&source=sd`
|
|
32
|
+
}
|
|
33
|
+
>
|
|
34
|
+
<Button size="tiny">
|
|
35
|
+
<Button.Content>
|
|
36
|
+
<img
|
|
37
|
+
className="extra-view-external-button"
|
|
38
|
+
src={codeSVG}
|
|
39
|
+
alt=""
|
|
40
|
+
title="Show API link"
|
|
41
|
+
/>
|
|
42
|
+
</Button.Content>
|
|
43
|
+
</Button>
|
|
44
|
+
</a>
|
|
45
|
+
)}
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
{show_legend && map_data && <LegendWidget data={map_data} />}
|
|
49
|
+
{show_sources && (
|
|
50
|
+
<>
|
|
51
|
+
{data_provenance &&
|
|
52
|
+
data_provenance.data &&
|
|
53
|
+
data_provenance.data.length > 0 ? (
|
|
54
|
+
<div>
|
|
55
|
+
<h3>Sources:</h3>
|
|
56
|
+
<ul>
|
|
57
|
+
{data_provenance.data.map((param, i) => (
|
|
58
|
+
<li key={i}>
|
|
59
|
+
<div className="map_source_param_container">
|
|
60
|
+
<UniversalLink
|
|
61
|
+
className="map_source_title"
|
|
62
|
+
href={param.link}
|
|
63
|
+
>
|
|
64
|
+
{param.title}
|
|
65
|
+
</UniversalLink>
|
|
66
|
+
,
|
|
67
|
+
<span className="map_source_description">
|
|
68
|
+
{param.organisation}
|
|
69
|
+
</span>
|
|
70
|
+
</div>
|
|
71
|
+
</li>
|
|
72
|
+
))}
|
|
73
|
+
</ul>
|
|
74
|
+
</div>
|
|
75
|
+
) : (
|
|
76
|
+
<p>Data provenance is not set for visualization used or page</p>
|
|
77
|
+
)}
|
|
78
|
+
</>
|
|
79
|
+
)}
|
|
80
|
+
{description && serializeNodes(description)}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default ExtraViews;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { withDeviceSize } from '
|
|
3
|
+
import { withDeviceSize } from '../hocs';
|
|
4
4
|
import { loadModules } from 'esri-loader';
|
|
5
5
|
import { formatQuery } from 'react-querybuilder';
|
|
6
6
|
|
|
@@ -20,8 +20,8 @@ const Webmap = (props) => {
|
|
|
20
20
|
const { editMode, height, id } = props;
|
|
21
21
|
|
|
22
22
|
const data = React.useMemo(() => props.data || {}, [props.data]);
|
|
23
|
-
const device = React.useMemo(() => props.device || {}, [props.device]);
|
|
24
23
|
|
|
24
|
+
const device = React.useMemo(() => props.device || {}, [props.device]);
|
|
25
25
|
const { base = {}, layers = {}, legend = {}, general = {} } = data;
|
|
26
26
|
|
|
27
27
|
const { base_layer = '' } = base;
|
|
@@ -32,6 +32,7 @@ const Webmap = (props) => {
|
|
|
32
32
|
layers.map_layers
|
|
33
33
|
.filter(({ map_layer }) => map_layer)
|
|
34
34
|
.map((l, i) => l.map_layer);
|
|
35
|
+
|
|
35
36
|
const options = {
|
|
36
37
|
css: true,
|
|
37
38
|
};
|
|
@@ -86,34 +87,35 @@ const Webmap = (props) => {
|
|
|
86
87
|
Zoom,
|
|
87
88
|
} = modules;
|
|
88
89
|
let layers =
|
|
89
|
-
map_layers &&
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
map_layers && map_layers.length > 0
|
|
91
|
+
? map_layers
|
|
92
|
+
.filter(({ map_service_url, layer }) => map_service_url && layer)
|
|
93
|
+
.map(({ map_service_url, layer, query = '' }) => {
|
|
94
|
+
const url = `${map_service_url}/${layer}`;
|
|
95
|
+
let mapLayer;
|
|
96
|
+
switch (layer.type) {
|
|
97
|
+
case 'Raster Layer':
|
|
98
|
+
mapLayer = new MapImageLayer({
|
|
99
|
+
url: map_service_url,
|
|
100
|
+
});
|
|
101
|
+
break;
|
|
102
|
+
case 'Feature Layer':
|
|
103
|
+
mapLayer = new FeatureLayer({
|
|
104
|
+
url,
|
|
105
|
+
definitionExpression: query
|
|
106
|
+
? formatQuery(query, 'sql')
|
|
107
|
+
: '',
|
|
108
|
+
});
|
|
109
|
+
break;
|
|
110
|
+
case 'Group Layer':
|
|
111
|
+
mapLayer = new GroupLayer({ url });
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
return mapLayer;
|
|
117
|
+
})
|
|
118
|
+
: [];
|
|
117
119
|
const map = new Map({
|
|
118
120
|
basemap: base_layer || 'hybrid',
|
|
119
121
|
layers,
|
|
@@ -193,7 +195,7 @@ const Webmap = (props) => {
|
|
|
193
195
|
});
|
|
194
196
|
}
|
|
195
197
|
return { view, map };
|
|
196
|
-
}, [modules,
|
|
198
|
+
}, [modules, data, data.layers, map_layers]);
|
|
197
199
|
|
|
198
200
|
return (
|
|
199
201
|
<div>
|
package/src/components/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export EEAMapView from './Blocks/EEAMap/View';
|
|
2
|
+
export EEAMapEdit from './Blocks/EEAMap/Edit';
|
|
3
|
+
export Webmap from './Webmap';
|
|
4
|
+
export ExtraViews from './ExtraViews';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { EEAMapEdit, EEAMapView, EmbedMapView, EmbedMapEdit };
|
|
6
|
+
export EmbedMapView from './Blocks/EmbedEEAMap/View';
|
|
7
|
+
export EmbedMapEdit from './Blocks/EmbedEEAMap/Edit';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button, Grid } from 'semantic-ui-react';
|
|
3
|
+
|
|
4
|
+
import { FormFieldWrapper, InlineForm } from '@plone/volto/components';
|
|
5
|
+
|
|
6
|
+
import PanelsSchema from './panelsSchema';
|
|
7
|
+
import Webmap from '../Webmap';
|
|
8
|
+
|
|
9
|
+
const VisualizationEditorWidget = (props) => {
|
|
10
|
+
const [open, setOpen] = React.useState(false);
|
|
11
|
+
const { onChange = {}, id } = props;
|
|
12
|
+
const block = React.useMemo(() => props.block, [props.block]);
|
|
13
|
+
const value = React.useMemo(() => props.value, [props.value]);
|
|
14
|
+
|
|
15
|
+
const [intValue, setIntValue] = React.useState(value);
|
|
16
|
+
|
|
17
|
+
const dataForm = { map_data: intValue };
|
|
18
|
+
const handleApplyChanges = () => {
|
|
19
|
+
onChange(id, intValue);
|
|
20
|
+
setOpen(false);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const handleClose = () => {
|
|
24
|
+
setIntValue(value);
|
|
25
|
+
setOpen(false);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const handleChangeField = (val) => {
|
|
29
|
+
setIntValue(val);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
let schema = PanelsSchema({ data: dataForm });
|
|
33
|
+
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
if (!intValue?.general) {
|
|
36
|
+
setIntValue({
|
|
37
|
+
...intValue,
|
|
38
|
+
general: {
|
|
39
|
+
print_position: 'top-right',
|
|
40
|
+
zoom_position: 'top-right',
|
|
41
|
+
centerOnExtent: true,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!intValue?.base) {
|
|
46
|
+
setIntValue({
|
|
47
|
+
...intValue,
|
|
48
|
+
base: {
|
|
49
|
+
base_layer: 'gray-vector',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
}, [intValue]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<FormFieldWrapper {...props}>
|
|
58
|
+
<div className="wrapper">
|
|
59
|
+
<Button
|
|
60
|
+
floated="right"
|
|
61
|
+
size="tiny"
|
|
62
|
+
onClick={(e) => {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
setOpen(true);
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
Open Map Editor
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
{open && (
|
|
73
|
+
<Modal
|
|
74
|
+
id="map-editor-modal"
|
|
75
|
+
style={{ width: '95% !important' }}
|
|
76
|
+
open={true}
|
|
77
|
+
>
|
|
78
|
+
<Modal.Content scrolling>
|
|
79
|
+
<Grid stackable reversed="mobile vertically tablet vertically">
|
|
80
|
+
<Grid.Column
|
|
81
|
+
mobile={12}
|
|
82
|
+
tablet={12}
|
|
83
|
+
computer={5}
|
|
84
|
+
className="map-editor-column"
|
|
85
|
+
>
|
|
86
|
+
<InlineForm
|
|
87
|
+
block={block}
|
|
88
|
+
schema={schema}
|
|
89
|
+
onChangeField={(id, value) => {
|
|
90
|
+
handleChangeField(value);
|
|
91
|
+
}}
|
|
92
|
+
formData={dataForm}
|
|
93
|
+
/>
|
|
94
|
+
</Grid.Column>
|
|
95
|
+
<Grid.Column mobile={12} tablet={12} computer={7}>
|
|
96
|
+
<div className="webmap-container">
|
|
97
|
+
<Webmap data={intValue} editMode={true} />
|
|
98
|
+
</div>
|
|
99
|
+
</Grid.Column>
|
|
100
|
+
</Grid>
|
|
101
|
+
</Modal.Content>
|
|
102
|
+
<Modal.Actions>
|
|
103
|
+
<Grid>
|
|
104
|
+
<Grid.Row>
|
|
105
|
+
<div className="map-edit-actions-container">
|
|
106
|
+
<Button onClick={handleClose}>Close</Button>
|
|
107
|
+
<Button color="green" onClick={handleApplyChanges}>
|
|
108
|
+
Apply changes
|
|
109
|
+
</Button>
|
|
110
|
+
</div>
|
|
111
|
+
</Grid.Row>
|
|
112
|
+
</Grid>
|
|
113
|
+
</Modal.Actions>
|
|
114
|
+
</Modal>
|
|
115
|
+
)}
|
|
116
|
+
<Webmap data={value} editMode={true} />
|
|
117
|
+
</FormFieldWrapper>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export default VisualizationEditorWidget;
|
package/src/components/{Blocks/EEAMap/components/widgets → visualization}/VisualizationView.jsx
RENAMED
|
File without changes
|