@eeacms/volto-eea-map 0.1.11 → 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 +8 -0
- package/package.json +1 -1
- package/src/components/Blocks/EEAMap/Edit.jsx +31 -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/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/index.js +2 -0
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.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
|
+
|
|
7
12
|
#### [0.1.11](https://github.com/eea/volto-eea-map/compare/0.1.10...0.1.11)
|
|
8
13
|
|
|
14
|
+
> 18 August 2022
|
|
15
|
+
|
|
16
|
+
- Legend for each layer in object list [`#11`](https://github.com/eea/volto-eea-map/pull/11)
|
|
9
17
|
- Legend for all layers [`2d9285e`](https://github.com/eea/volto-eea-map/commit/2d9285e12ea512b7a1f24300ad2f7b3072e334d5)
|
|
10
18
|
|
|
11
19
|
#### [0.1.10](https://github.com/eea/volto-eea-map/compare/0.1.9...0.1.10)
|
package/package.json
CHANGED
|
@@ -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
|
|
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);
|
|
@@ -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);
|
|
@@ -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) => {
|
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;
|