@eeacms/volto-eea-map 0.1.10 → 0.1.13
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 +22 -1
- package/package.json +1 -1
- package/src/components/Blocks/EEAMap/Edit.jsx +32 -1
- package/src/components/Blocks/EEAMap/Schema.js +5 -0
- package/src/components/Blocks/EEAMap/View.jsx +3 -3
- package/src/components/Blocks/EEAMap/components/widgets/DataQueryWidget.jsx +46 -0
- package/src/components/Blocks/EEAMap/components/widgets/LayerSelectWidget.jsx +66 -4
- package/src/components/Blocks/EEAMap/components/widgets/LegendWidget.jsx +29 -36
- package/src/components/Blocks/EEAMap/components/widgets/MapEditorWidget.jsx +0 -1
- package/src/components/Blocks/EEAMap/components/widgets/ObjectTypesWidget.jsx +10 -1
- package/src/components/Blocks/EEAMap/styles/map.css +4 -0
- package/src/components/Blocks/EmbedEEAMap/Edit.jsx +37 -2
- package/src/components/Blocks/EmbedEEAMap/Schema.js +5 -0
- package/src/components/Blocks/EmbedEEAMap/View.jsx +48 -2
- package/src/index.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,31 @@ 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.13](https://github.com/eea/volto-eea-map/compare/0.1.12...0.1.13)
|
|
8
|
+
|
|
9
|
+
- update embed map with data_query [`719c007`](https://github.com/eea/volto-eea-map/commit/719c00776dff7ba63bbd57761a2c86ec5345a911)
|
|
10
|
+
|
|
11
|
+
#### [0.1.12](https://github.com/eea/volto-eea-map/compare/0.1.11...0.1.12)
|
|
12
|
+
|
|
13
|
+
> 22 August 2022
|
|
14
|
+
|
|
15
|
+
- Develop [`#12`](https://github.com/eea/volto-eea-map/pull/12)
|
|
16
|
+
- cleanup [`53a2d89`](https://github.com/eea/volto-eea-map/commit/53a2d897675af2f75d8bd787ed07cdcfac69bdd0)
|
|
17
|
+
- get criteria and map it as query on fresh layers [`51f8087`](https://github.com/eea/volto-eea-map/commit/51f80870764d65140ac0a6408c01c0b63476bbd2)
|
|
18
|
+
|
|
19
|
+
#### [0.1.11](https://github.com/eea/volto-eea-map/compare/0.1.10...0.1.11)
|
|
20
|
+
|
|
21
|
+
> 18 August 2022
|
|
22
|
+
|
|
23
|
+
- Legend for each layer in object list [`#11`](https://github.com/eea/volto-eea-map/pull/11)
|
|
24
|
+
- Legend for all layers [`2d9285e`](https://github.com/eea/volto-eea-map/commit/2d9285e12ea512b7a1f24300ad2f7b3072e334d5)
|
|
25
|
+
|
|
7
26
|
#### [0.1.10](https://github.com/eea/volto-eea-map/compare/0.1.9...0.1.10)
|
|
8
27
|
|
|
28
|
+
> 17 August 2022
|
|
29
|
+
|
|
30
|
+
- EEA core metadata adaptation [`#10`](https://github.com/eea/volto-eea-map/pull/10)
|
|
9
31
|
- 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
32
|
|
|
12
33
|
#### [0.1.9](https://github.com/eea/volto-eea-map/compare/0.1.8...0.1.9)
|
|
13
34
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
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
|
|
|
@@ -10,6 +17,19 @@ const Edit = (props) => {
|
|
|
10
17
|
const { block, data, onChangeBlock, selected, id } = props;
|
|
11
18
|
const schema = React.useMemo(() => Schema(props), [props]);
|
|
12
19
|
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
if (
|
|
22
|
+
!data.data_query_params ||
|
|
23
|
+
props.data_query !== data.data_query_params
|
|
24
|
+
) {
|
|
25
|
+
onChangeBlock(block, {
|
|
26
|
+
...data,
|
|
27
|
+
data_query_params: props.data_query,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
}, [props.data_query, block, data]);
|
|
32
|
+
|
|
13
33
|
return (
|
|
14
34
|
<div>
|
|
15
35
|
<View data={data} id={id} />
|
|
@@ -31,4 +51,15 @@ const Edit = (props) => {
|
|
|
31
51
|
);
|
|
32
52
|
};
|
|
33
53
|
|
|
34
|
-
export default
|
|
54
|
+
export default compose(
|
|
55
|
+
connect(
|
|
56
|
+
(state, props) => ({
|
|
57
|
+
data_query: state.content.data.data_query,
|
|
58
|
+
data_provenance:
|
|
59
|
+
state.content.subrequests?.[props.id]?.data?.data_provenance,
|
|
60
|
+
}),
|
|
61
|
+
{
|
|
62
|
+
getContent,
|
|
63
|
+
},
|
|
64
|
+
),
|
|
65
|
+
)(Edit);
|
|
@@ -13,6 +13,7 @@ export const Schema = (props) => {
|
|
|
13
13
|
'show_download',
|
|
14
14
|
'show_viewer',
|
|
15
15
|
'show_sources',
|
|
16
|
+
'data_query_params',
|
|
16
17
|
],
|
|
17
18
|
},
|
|
18
19
|
],
|
|
@@ -46,6 +47,10 @@ export const Schema = (props) => {
|
|
|
46
47
|
title: 'Show web viewer',
|
|
47
48
|
type: 'boolean',
|
|
48
49
|
},
|
|
50
|
+
data_query_params: {
|
|
51
|
+
title: 'Data query parameters',
|
|
52
|
+
widget: 'data_query_widget',
|
|
53
|
+
},
|
|
49
54
|
},
|
|
50
55
|
required: [],
|
|
51
56
|
};
|
|
@@ -9,11 +9,10 @@ import { PrivacyProtection } from '@eeacms/volto-embed';
|
|
|
9
9
|
import { getContent } from '@plone/volto/actions';
|
|
10
10
|
|
|
11
11
|
const View = (props) => {
|
|
12
|
-
const { data, id, path
|
|
12
|
+
const { data, id, path } = props || {};
|
|
13
13
|
const { map_data = {}, height = '' } = data;
|
|
14
14
|
|
|
15
15
|
React.useEffect(() => {
|
|
16
|
-
// get content from document
|
|
17
16
|
if (path) {
|
|
18
17
|
props.getContent(path, null, id);
|
|
19
18
|
}
|
|
@@ -24,7 +23,7 @@ const View = (props) => {
|
|
|
24
23
|
<div>
|
|
25
24
|
<PrivacyProtection data={data} {...props}>
|
|
26
25
|
<Webmap data={map_data} height={height} id={id} />
|
|
27
|
-
<ExtraViews data={
|
|
26
|
+
<ExtraViews data={data} />
|
|
28
27
|
</PrivacyProtection>
|
|
29
28
|
</div>
|
|
30
29
|
);
|
|
@@ -33,6 +32,7 @@ const View = (props) => {
|
|
|
33
32
|
export default compose(
|
|
34
33
|
connect(
|
|
35
34
|
(state, props) => ({
|
|
35
|
+
data_query: state.content.subrequests?.[props.id]?.data?.data_query,
|
|
36
36
|
data_provenance:
|
|
37
37
|
state.content.subrequests?.[props.id]?.data?.data_provenance,
|
|
38
38
|
}),
|
|
@@ -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;
|
|
@@ -4,6 +4,11 @@ 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
6
|
|
|
7
|
+
import { connect } from 'react-redux';
|
|
8
|
+
import { compose } from 'redux';
|
|
9
|
+
|
|
10
|
+
import { getContent } from '@plone/volto/actions';
|
|
11
|
+
|
|
7
12
|
import checkSVG from '@plone/volto/icons/check.svg';
|
|
8
13
|
import closeSVG from '@plone/volto/icons/clear.svg';
|
|
9
14
|
import aheadSVG from '@plone/volto/icons/ahead.svg';
|
|
@@ -12,7 +17,7 @@ import resetSVG from '@plone/volto/icons/reset.svg';
|
|
|
12
17
|
import { fetchArcgisData } from '../../utils';
|
|
13
18
|
|
|
14
19
|
const LayerSelectWidget = (props) => {
|
|
15
|
-
const { onChange, id } = props;
|
|
20
|
+
const { onChange, id, data_query } = props;
|
|
16
21
|
|
|
17
22
|
const value = React.useMemo(() => props.value || {}, [props.value]);
|
|
18
23
|
|
|
@@ -63,6 +68,55 @@ const LayerSelectWidget = (props) => {
|
|
|
63
68
|
}
|
|
64
69
|
};
|
|
65
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
|
+
|
|
66
120
|
const handleLayerFetch = async (service_url, id) => {
|
|
67
121
|
try {
|
|
68
122
|
let fullLayer = await fetchArcgisData(`${service_url}/${id}`);
|
|
@@ -129,8 +183,6 @@ const LayerSelectWidget = (props) => {
|
|
|
129
183
|
style={{ width: '100%' }}
|
|
130
184
|
error={serviceUrlError}
|
|
131
185
|
value={serviceUrl}
|
|
132
|
-
// action
|
|
133
|
-
// actionPosition="right"
|
|
134
186
|
></Input>
|
|
135
187
|
|
|
136
188
|
<span style={{ fontSize: '12px', color: 'darkred' }}>
|
|
@@ -230,4 +282,14 @@ const LayerSelectWidget = (props) => {
|
|
|
230
282
|
);
|
|
231
283
|
};
|
|
232
284
|
|
|
233
|
-
export default
|
|
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
|
|
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: '
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
<
|
|
84
|
-
{
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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>
|
|
@@ -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 {
|
|
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) => {
|
|
@@ -1,8 +1,14 @@
|
|
|
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
13
|
import './styles/map.css';
|
|
8
14
|
|
|
@@ -10,6 +16,24 @@ const Edit = (props) => {
|
|
|
10
16
|
const { block, data, onChangeBlock, selected, id } = props;
|
|
11
17
|
const schema = React.useMemo(() => Schema(props), [props]);
|
|
12
18
|
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
props.getContent(data.vis_url, null, id);
|
|
21
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
|
+
}, [data.vis_url]);
|
|
23
|
+
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
if (
|
|
26
|
+
!data.data_query_params ||
|
|
27
|
+
props.data_query !== data.data_query_params
|
|
28
|
+
) {
|
|
29
|
+
onChangeBlock(block, {
|
|
30
|
+
...data,
|
|
31
|
+
data_query_params: props.data_query,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [props.data_query, block, data]);
|
|
36
|
+
|
|
13
37
|
return (
|
|
14
38
|
<div>
|
|
15
39
|
<View data={data} id={id} />
|
|
@@ -31,4 +55,15 @@ const Edit = (props) => {
|
|
|
31
55
|
);
|
|
32
56
|
};
|
|
33
57
|
|
|
34
|
-
export default
|
|
58
|
+
export default compose(
|
|
59
|
+
connect(
|
|
60
|
+
(state, props) => ({
|
|
61
|
+
data_query: state.content.data.data_query,
|
|
62
|
+
data_provenance:
|
|
63
|
+
state.content.subrequests?.[props.id]?.data?.data_provenance,
|
|
64
|
+
}),
|
|
65
|
+
{
|
|
66
|
+
getContent,
|
|
67
|
+
},
|
|
68
|
+
),
|
|
69
|
+
)(Edit);
|
|
@@ -13,6 +13,7 @@ export const Schema = (props) => {
|
|
|
13
13
|
'show_download',
|
|
14
14
|
'show_viewer',
|
|
15
15
|
'show_sources',
|
|
16
|
+
'data_query_params',
|
|
16
17
|
],
|
|
17
18
|
},
|
|
18
19
|
],
|
|
@@ -45,6 +46,10 @@ export const Schema = (props) => {
|
|
|
45
46
|
title: 'Show web viewer',
|
|
46
47
|
type: 'boolean',
|
|
47
48
|
},
|
|
49
|
+
data_query_params: {
|
|
50
|
+
title: 'Data query parameters',
|
|
51
|
+
widget: 'data_query_widget',
|
|
52
|
+
},
|
|
48
53
|
},
|
|
49
54
|
required: [],
|
|
50
55
|
};
|
|
@@ -15,19 +15,64 @@ const View = (props) => {
|
|
|
15
15
|
const { map_visualization_data = '', data_provenance = {} } =
|
|
16
16
|
viz_content || {};
|
|
17
17
|
|
|
18
|
+
const [mapData, setMapData] = React.useState(map_visualization_data);
|
|
19
|
+
|
|
18
20
|
React.useEffect(() => {
|
|
19
|
-
if (vis_url) {
|
|
21
|
+
if (vis_url && !map_visualization_data) {
|
|
20
22
|
props.getContent(vis_url, null, id);
|
|
21
23
|
}
|
|
22
24
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
25
|
}, [vis_url]);
|
|
24
26
|
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (
|
|
29
|
+
props.data_query &&
|
|
30
|
+
props.data_query.length > 0 &&
|
|
31
|
+
map_visualization_data
|
|
32
|
+
) {
|
|
33
|
+
let altMapData = { ...map_visualization_data };
|
|
34
|
+
|
|
35
|
+
props.data_query.forEach((param, i) => {
|
|
36
|
+
if (
|
|
37
|
+
map_visualization_data.layers &&
|
|
38
|
+
map_visualization_data.layers.map_layers &&
|
|
39
|
+
map_visualization_data.layers.map_layers.length > 0
|
|
40
|
+
) {
|
|
41
|
+
map_visualization_data.layers.map_layers.forEach((l, j) => {
|
|
42
|
+
if (
|
|
43
|
+
l.map_layer &&
|
|
44
|
+
l.map_layer.fields &&
|
|
45
|
+
l.map_layer.fields.length > 0 &&
|
|
46
|
+
l.map_layer.fields.filter(
|
|
47
|
+
(field, k) =>
|
|
48
|
+
field.name === param.alias || field.name === param.i,
|
|
49
|
+
).length > 0
|
|
50
|
+
) {
|
|
51
|
+
let autoQuery = {
|
|
52
|
+
combinator: 'or',
|
|
53
|
+
rules: props.data_query.map((q, i) => {
|
|
54
|
+
return {
|
|
55
|
+
field: param.alias ? param.alias : param.i,
|
|
56
|
+
operator: '=',
|
|
57
|
+
value: param.v[0],
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
altMapData.layers.map_layers[j].map_layer.query = autoQuery;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
setMapData(altMapData);
|
|
67
|
+
}
|
|
68
|
+
}, [props.data_query, map_visualization_data]);
|
|
69
|
+
|
|
25
70
|
return (
|
|
26
71
|
<div>
|
|
27
72
|
<PrivacyProtection data={data} {...props}>
|
|
28
73
|
{map_visualization_data && (
|
|
29
74
|
<div>
|
|
30
|
-
<Webmap data={
|
|
75
|
+
<Webmap data={mapData} height={height} />
|
|
31
76
|
<ExtraViews
|
|
32
77
|
data={{
|
|
33
78
|
...data,
|
|
@@ -48,6 +93,7 @@ const View = (props) => {
|
|
|
48
93
|
export default compose(
|
|
49
94
|
connect(
|
|
50
95
|
(state, props) => ({
|
|
96
|
+
data_query: state.content.data.data_query,
|
|
51
97
|
viz_content: state.content.subrequests?.[props.id]?.data,
|
|
52
98
|
}),
|
|
53
99
|
{
|
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;
|