@eeacms/volto-eea-map 0.1.7 → 0.1.8
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 +21 -0
- package/package.json +1 -1
- package/src/actions.js +12 -0
- package/src/components/Blocks/EEAMap/Edit.jsx +2 -3
- package/src/components/Blocks/EEAMap/Schema.js +13 -7
- package/src/components/Blocks/EEAMap/View.jsx +3 -4
- package/src/components/Blocks/EEAMap/components/Webmap.jsx +18 -11
- package/src/components/Blocks/EEAMap/components/widgets/LayerSelectWidget.jsx +111 -56
- package/src/components/Blocks/EEAMap/components/widgets/MapEditorWidget.jsx +24 -20
- package/src/components/Blocks/EEAMap/components/widgets/ObjectTypesWidget.jsx +11 -3
- package/src/components/Blocks/EEAMap/components/widgets/VisualizationView.jsx +2 -2
- package/src/components/Blocks/EEAMap/components/widgets/panelsSchema.js +3 -11
- package/src/components/Blocks/EEAMap/styles/map.css +44 -0
- package/src/components/Blocks/EmbedEEAMap/Edit.jsx +34 -0
- package/src/components/Blocks/EmbedEEAMap/Schema.js +46 -0
- package/src/components/Blocks/EmbedEEAMap/View.jsx +48 -0
- package/src/components/Blocks/EmbedEEAMap/styles/map.css +22 -0
- package/src/components/index.js +4 -1
- package/src/constants.js +1 -0
- package/src/hocs/index.js +3 -0
- package/src/hocs/withDeviceSize.jsx +45 -0
- package/src/index.js +48 -2
- package/src/middlewares/index.js +14 -0
- package/src/middlewares/map_visualizations.js +1 -0
- package/src/reducers/index.js +3 -0
- package/src/reducers/map_visualizations.js +48 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,29 @@ 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.8](https://github.com/eea/volto-eea-map/compare/0.1.7...0.1.8)
|
|
8
|
+
|
|
9
|
+
- remove title on map edit widget [`1d00707`](https://github.com/eea/volto-eea-map/commit/1d0070716a743ea7f26c5f877b723492319fcecd)
|
|
10
|
+
- update query by stored value [`c0f6ddd`](https://github.com/eea/volto-eea-map/commit/c0f6dddadaaf28de5b9914214acf735a166fae88)
|
|
11
|
+
- stylelint [`511845a`](https://github.com/eea/volto-eea-map/commit/511845a319137dfe4e1c0c9846ee5ccb7656b32b)
|
|
12
|
+
- visual candy [`2b24975`](https://github.com/eea/volto-eea-map/commit/2b249758f30133d8080793e892d0771e9b63dea5)
|
|
13
|
+
- responsive hoc only keep device size [`444f8b3`](https://github.com/eea/volto-eea-map/commit/444f8b3df2dd58a1f1e5bd6c6a90c1e9919696a1)
|
|
14
|
+
- responsive improvements on edit widget [`1dcdda0`](https://github.com/eea/volto-eea-map/commit/1dcdda077f5aaa8ddd256d2bec2f1018a15e066d)
|
|
15
|
+
- map is sticky [`64f3874`](https://github.com/eea/volto-eea-map/commit/64f3874648f0ede23502998e9165e86538e44728)
|
|
16
|
+
- simplified layer edit [`b64348c`](https://github.com/eea/volto-eea-map/commit/b64348c962647cdfc48d3328c5effb3b02b6217c)
|
|
17
|
+
- no consoles [`1387128`](https://github.com/eea/volto-eea-map/commit/1387128037abb314798326fa3c47b52a13d0415f)
|
|
18
|
+
- show if zoom/print position [`c4d7107`](https://github.com/eea/volto-eea-map/commit/c4d7107e874616c2246ec883d07eb59fad76b21e)
|
|
19
|
+
- lint fix [`cc497bd`](https://github.com/eea/volto-eea-map/commit/cc497bd8fe61d8867b74a8a16bc4868ccf088d55)
|
|
20
|
+
- fixes on webmap [`1c4506b`](https://github.com/eea/volto-eea-map/commit/1c4506b227d3a0ad0f919e3ff826700304b0620a)
|
|
21
|
+
- new embed eea map block to work with visualizations [`be4f2b0`](https://github.com/eea/volto-eea-map/commit/be4f2b00f92ea9dedc359e8c2620a9a31f4b5b6b)
|
|
22
|
+
- remove vis_url logic, will be moved in a new block [`13ebe94`](https://github.com/eea/volto-eea-map/commit/13ebe94c6c339fc827c019aab0a698aa431c5b78)
|
|
23
|
+
- Updates for map visualization [`895d463`](https://github.com/eea/volto-eea-map/commit/895d46313e9b65c6a5f420284fb9459296ed83f4)
|
|
24
|
+
|
|
7
25
|
#### [0.1.7](https://github.com/eea/volto-eea-map/compare/0.1.6...0.1.7)
|
|
8
26
|
|
|
27
|
+
> 9 August 2022
|
|
28
|
+
|
|
29
|
+
- Develop [`#7`](https://github.com/eea/volto-eea-map/pull/7)
|
|
9
30
|
- fix height coming through in view [`39d4d28`](https://github.com/eea/volto-eea-map/commit/39d4d287a4fe86890f5fad8d9050130b496dfe70)
|
|
10
31
|
- Connected visualization view-edit [`52a8e21`](https://github.com/eea/volto-eea-map/commit/52a8e2187cb2e3a7db660ae4b6b5610c88be5083)
|
|
11
32
|
- map_view is map_editor_widget, add view component for content-type [`dc227f9`](https://github.com/eea/volto-eea-map/commit/dc227f9bbb259b59739a3694dc69f0fcca661137)
|
package/package.json
CHANGED
package/src/actions.js
ADDED
|
@@ -7,13 +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
|
-
if (__SERVER__) return '';
|
|
14
13
|
return (
|
|
15
14
|
<div>
|
|
16
|
-
<View data={data} />
|
|
15
|
+
<View data={data} id={id} />
|
|
17
16
|
<SidebarPortal selected={selected}>
|
|
18
17
|
<BlockDataForm
|
|
19
18
|
block={block}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const Schema = () => {
|
|
1
|
+
export const Schema = (props) => {
|
|
2
2
|
return {
|
|
3
3
|
title: 'EEA Map Block',
|
|
4
4
|
fieldsets: [
|
|
@@ -6,10 +6,10 @@ export const Schema = () => {
|
|
|
6
6
|
id: 'default',
|
|
7
7
|
title: 'Default',
|
|
8
8
|
fields: [
|
|
9
|
+
'map_data',
|
|
10
|
+
//...(use_visualization ? ['vis_url'] : ['map_data']),
|
|
9
11
|
'description',
|
|
10
12
|
'height',
|
|
11
|
-
'map_data',
|
|
12
|
-
'show_sources',
|
|
13
13
|
'show_legend',
|
|
14
14
|
'show_download',
|
|
15
15
|
'show_viewer',
|
|
@@ -17,6 +17,16 @@ export const Schema = () => {
|
|
|
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
30
|
height: {
|
|
21
31
|
title: 'Height',
|
|
22
32
|
type: 'number',
|
|
@@ -30,10 +40,6 @@ export const Schema = () => {
|
|
|
30
40
|
description: 'Open the map customization interface',
|
|
31
41
|
widget: 'map_edit_widget',
|
|
32
42
|
},
|
|
33
|
-
show_sources: {
|
|
34
|
-
title: 'Show sources',
|
|
35
|
-
type: 'boolean',
|
|
36
|
-
},
|
|
37
43
|
show_legend: {
|
|
38
44
|
title: 'Show legend',
|
|
39
45
|
type: 'boolean',
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import Webmap from './components/Webmap';
|
|
3
4
|
import ExtraViews from './components/widgets/ExtraViews';
|
|
4
5
|
import { PrivacyProtection } from '@eeacms/volto-embed';
|
|
5
6
|
|
|
6
7
|
const View = (props) => {
|
|
7
|
-
const { data } = props || {};
|
|
8
|
-
|
|
8
|
+
const { data, id } = props || {};
|
|
9
9
|
const { map_data = {}, height = '' } = data;
|
|
10
10
|
|
|
11
|
-
if (__SERVER__) return '';
|
|
12
11
|
return (
|
|
13
12
|
<div>
|
|
14
13
|
<PrivacyProtection data={data} {...props}>
|
|
15
|
-
<Webmap data={map_data} height={height} />
|
|
14
|
+
<Webmap data={map_data} height={height} id={id} />
|
|
16
15
|
<ExtraViews data={data} />
|
|
17
16
|
</PrivacyProtection>
|
|
18
17
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { withDeviceSize } from '@eeacms/volto-eea-map/hocs';
|
|
3
4
|
import { loadModules } from 'esri-loader';
|
|
4
5
|
|
|
5
6
|
const MODULES = [
|
|
@@ -15,9 +16,10 @@ const MODULES = [
|
|
|
15
16
|
];
|
|
16
17
|
|
|
17
18
|
const Webmap = (props) => {
|
|
18
|
-
const { editMode, height } = props;
|
|
19
|
+
const { editMode, height, id } = props;
|
|
19
20
|
|
|
20
21
|
const data = React.useMemo(() => props.data || {}, [props.data]);
|
|
22
|
+
const device = React.useMemo(() => props.device || {}, [props.device]);
|
|
21
23
|
|
|
22
24
|
const { base = {}, layers = {}, legend = {}, general = {} } = data;
|
|
23
25
|
|
|
@@ -139,9 +141,10 @@ const Webmap = (props) => {
|
|
|
139
141
|
});
|
|
140
142
|
}
|
|
141
143
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
const zoomPosition =
|
|
145
|
+
general && general.zoom_position ? general.zoom_position : '';
|
|
146
|
+
|
|
147
|
+
if (zoomPosition) {
|
|
145
148
|
const zoomWidget = new Zoom({
|
|
146
149
|
view: view,
|
|
147
150
|
});
|
|
@@ -168,11 +171,10 @@ const Webmap = (props) => {
|
|
|
168
171
|
view.ui.add(legendWidget, legendPosition);
|
|
169
172
|
}
|
|
170
173
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
: 'top-right';
|
|
174
|
+
const printPosition =
|
|
175
|
+
general && general.print_position ? general.print_position : '';
|
|
176
|
+
|
|
177
|
+
if (printPosition) {
|
|
176
178
|
const printWidget = new Expand({
|
|
177
179
|
content: new Print({
|
|
178
180
|
view: view,
|
|
@@ -197,7 +199,12 @@ const Webmap = (props) => {
|
|
|
197
199
|
<div>
|
|
198
200
|
<div
|
|
199
201
|
style={{
|
|
200
|
-
height:
|
|
202
|
+
height:
|
|
203
|
+
height && !editMode
|
|
204
|
+
? `${height}px`
|
|
205
|
+
: device === 'tablet' || device === 'mobile'
|
|
206
|
+
? '300px'
|
|
207
|
+
: '500px',
|
|
201
208
|
}}
|
|
202
209
|
ref={mapRef}
|
|
203
210
|
className="esri-map"
|
|
@@ -206,4 +213,4 @@ const Webmap = (props) => {
|
|
|
206
213
|
);
|
|
207
214
|
};
|
|
208
215
|
|
|
209
|
-
export default React.memo(Webmap);
|
|
216
|
+
export default withDeviceSize(React.memo(Webmap));
|
|
@@ -5,6 +5,7 @@ import { Input, Select, Button, Grid } from 'semantic-ui-react';
|
|
|
5
5
|
import checkSVG from '@plone/volto/icons/check.svg';
|
|
6
6
|
import closeSVG from '@plone/volto/icons/clear.svg';
|
|
7
7
|
import aheadSVG from '@plone/volto/icons/ahead.svg';
|
|
8
|
+
import resetSVG from '@plone/volto/icons/reset.svg';
|
|
8
9
|
|
|
9
10
|
import { fetchArcgisData } from '../../utils';
|
|
10
11
|
|
|
@@ -88,6 +89,24 @@ const LayerSelectWidget = (props) => {
|
|
|
88
89
|
});
|
|
89
90
|
};
|
|
90
91
|
|
|
92
|
+
const handleChangeServiceUrl = (value) => {
|
|
93
|
+
setServiceUrlError('');
|
|
94
|
+
setCheckColor('');
|
|
95
|
+
setServiceUrl(value);
|
|
96
|
+
setAvailableLayers('');
|
|
97
|
+
setLayerQuery('');
|
|
98
|
+
setSelectedLayer('');
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleReset = () => {
|
|
102
|
+
setServiceUrlError('');
|
|
103
|
+
setServiceUrl(map_service_url);
|
|
104
|
+
setCheckColor('');
|
|
105
|
+
setAvailableLayers(available_layers);
|
|
106
|
+
setLayerQuery(query);
|
|
107
|
+
setSelectedLayer(layer);
|
|
108
|
+
};
|
|
109
|
+
|
|
91
110
|
return (
|
|
92
111
|
<div
|
|
93
112
|
style={{
|
|
@@ -95,74 +114,110 @@ const LayerSelectWidget = (props) => {
|
|
|
95
114
|
}}
|
|
96
115
|
>
|
|
97
116
|
<Grid>
|
|
98
|
-
<
|
|
117
|
+
<h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>
|
|
118
|
+
Service URL
|
|
119
|
+
</h5>
|
|
99
120
|
<Grid.Row>
|
|
100
121
|
<Input
|
|
101
122
|
type="text"
|
|
102
|
-
onChange={(e, { value }) =>
|
|
103
|
-
style={{ width: '
|
|
123
|
+
onChange={(e, { value }) => handleChangeServiceUrl(value)}
|
|
124
|
+
style={{ width: '100%' }}
|
|
125
|
+
error={serviceUrlError}
|
|
104
126
|
value={serviceUrl}
|
|
105
|
-
action
|
|
106
|
-
actionPosition="right"
|
|
107
|
-
>
|
|
108
|
-
|
|
127
|
+
// action
|
|
128
|
+
// actionPosition="right"
|
|
129
|
+
></Input>
|
|
130
|
+
|
|
131
|
+
<span style={{ fontSize: '12px', color: 'darkred' }}>
|
|
132
|
+
{serviceUrlError.error}
|
|
133
|
+
</span>
|
|
134
|
+
</Grid.Row>
|
|
135
|
+
{serviceUrl && (
|
|
136
|
+
<Grid.Row>
|
|
137
|
+
{serviceUrl !== map_service_url && (
|
|
138
|
+
<Button
|
|
139
|
+
size="small"
|
|
140
|
+
compact
|
|
141
|
+
className="layer-reset-button"
|
|
142
|
+
onClick={handleReset}
|
|
143
|
+
>
|
|
144
|
+
<Icon name={resetSVG} title="Reset" size="20px" />
|
|
145
|
+
</Button>
|
|
146
|
+
)}
|
|
109
147
|
<Button
|
|
110
|
-
|
|
111
|
-
size="tiny"
|
|
112
|
-
compact
|
|
148
|
+
size="small"
|
|
113
149
|
color={checkColor}
|
|
150
|
+
compact
|
|
151
|
+
className="layer-check-button"
|
|
114
152
|
onClick={handleServiceUrlCheck}
|
|
115
153
|
>
|
|
116
154
|
<Icon
|
|
117
155
|
name={serviceUrlError ? closeSVG : checkSVG}
|
|
118
|
-
title="
|
|
119
|
-
size="
|
|
156
|
+
title="Submit"
|
|
157
|
+
size="20px"
|
|
120
158
|
/>
|
|
121
159
|
</Button>
|
|
122
|
-
</
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
160
|
+
</Grid.Row>
|
|
161
|
+
)}
|
|
162
|
+
{availableLayers && availableLayers.length > 0 && (
|
|
163
|
+
<>
|
|
164
|
+
<h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>Layer</h5>
|
|
165
|
+
<Grid.Row>
|
|
166
|
+
<Select
|
|
167
|
+
onChange={(e, { value }) => handleSelectLayer(value)}
|
|
168
|
+
options={availableLayers}
|
|
169
|
+
style={{ width: '100%' }}
|
|
170
|
+
placeholder="Select layer"
|
|
171
|
+
value={selectedLayer}
|
|
172
|
+
/>
|
|
173
|
+
</Grid.Row>
|
|
174
|
+
</>
|
|
175
|
+
)}
|
|
176
|
+
{availableLayers && fields && fields.length > 0 && (
|
|
177
|
+
<>
|
|
178
|
+
<h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>
|
|
179
|
+
Query Layer
|
|
180
|
+
</h5>
|
|
181
|
+
<Grid.Row stretched>
|
|
182
|
+
<Input
|
|
183
|
+
type="text"
|
|
184
|
+
style={{ width: '100%' }}
|
|
185
|
+
onChange={(e, { value }) => setLayerQuery(value)}
|
|
186
|
+
value={layerQuery}
|
|
187
|
+
></Input>
|
|
188
|
+
</Grid.Row>
|
|
189
|
+
{layerQuery && (
|
|
190
|
+
<Grid.Row>
|
|
191
|
+
<Button
|
|
192
|
+
type="submit"
|
|
193
|
+
size="tiny"
|
|
194
|
+
compact
|
|
195
|
+
className="layer-submit-button "
|
|
196
|
+
color={'green'}
|
|
197
|
+
onClick={handleQueryLayer}
|
|
198
|
+
>
|
|
199
|
+
<Icon name={aheadSVG} title="Check Url" size="20px" />
|
|
200
|
+
</Button>
|
|
201
|
+
</Grid.Row>
|
|
202
|
+
)}
|
|
203
|
+
<Grid.Row>
|
|
204
|
+
<p
|
|
205
|
+
style={{
|
|
206
|
+
fontSize: '13px',
|
|
207
|
+
fontWeight: 'bold',
|
|
208
|
+
color: 'darkgray',
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
Available Fields:
|
|
212
|
+
</p>
|
|
213
|
+
</Grid.Row>
|
|
214
|
+
{fields.map((field, id) => (
|
|
215
|
+
<p style={{ fontSize: '12px', padding: '0 5px' }}>
|
|
216
|
+
{field.alias}
|
|
217
|
+
</p>
|
|
218
|
+
))}
|
|
219
|
+
</>
|
|
220
|
+
)}
|
|
166
221
|
</Grid>
|
|
167
222
|
</div>
|
|
168
223
|
);
|
|
@@ -42,7 +42,7 @@ const MapEditorWidget = (props) => {
|
|
|
42
42
|
<FormFieldWrapper {...props}>
|
|
43
43
|
<Modal
|
|
44
44
|
id="map-editor-modal"
|
|
45
|
-
|
|
45
|
+
className="map-editor-modal"
|
|
46
46
|
onClose={handleClose}
|
|
47
47
|
onOpen={() => setOpen(true)}
|
|
48
48
|
open={open}
|
|
@@ -53,35 +53,39 @@ const MapEditorWidget = (props) => {
|
|
|
53
53
|
}
|
|
54
54
|
>
|
|
55
55
|
<Modal.Content scrolling>
|
|
56
|
-
<Grid>
|
|
57
|
-
<Grid.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
<Grid stackable reversed="mobile vertically tablet vertically">
|
|
57
|
+
<Grid.Column
|
|
58
|
+
mobile={12}
|
|
59
|
+
tablet={12}
|
|
60
|
+
computer={5}
|
|
61
|
+
className="map-editor-column"
|
|
62
|
+
>
|
|
63
|
+
<InlineForm
|
|
64
|
+
block={block}
|
|
65
|
+
//title={schema.title}
|
|
66
|
+
schema={schema}
|
|
67
|
+
onChangeField={(id, value) => {
|
|
68
|
+
handleChangeField(id, value);
|
|
69
|
+
}}
|
|
70
|
+
formData={dataForm}
|
|
71
|
+
/>
|
|
72
|
+
</Grid.Column>
|
|
73
|
+
<Grid.Column mobile={12} tablet={12} computer={7}>
|
|
74
|
+
<div className="webmap-container">
|
|
70
75
|
<Webmap data={intValue} editMode={true} />
|
|
71
|
-
</
|
|
72
|
-
</Grid.
|
|
76
|
+
</div>
|
|
77
|
+
</Grid.Column>
|
|
73
78
|
</Grid>
|
|
74
79
|
</Modal.Content>
|
|
75
80
|
<Modal.Actions>
|
|
76
81
|
<Grid>
|
|
77
82
|
<Grid.Row>
|
|
78
|
-
<
|
|
79
|
-
<Grid.Column width={4}>
|
|
83
|
+
<div className="map-edit-actions-container">
|
|
80
84
|
<Button onClick={handleClose}>Close</Button>
|
|
81
85
|
<Button color="green" onClick={handleApplyChanges}>
|
|
82
86
|
Apply changes
|
|
83
87
|
</Button>
|
|
84
|
-
</
|
|
88
|
+
</div>
|
|
85
89
|
</Grid.Row>
|
|
86
90
|
</Grid>
|
|
87
91
|
</Modal.Actions>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Menu, Tab } from 'semantic-ui-react';
|
|
3
3
|
import { ObjectWidget } from '@plone/volto/components';
|
|
4
|
+
import { withDeviceSize } from '@eeacms/volto-eea-map/hocs';
|
|
4
5
|
|
|
5
6
|
export const ObjectTypesWidget = (props) => {
|
|
6
|
-
const { schemas, value = {}, onChange, errors = {}, id } = props;
|
|
7
|
+
const { schemas, value = {}, onChange, errors = {}, id, device } = props;
|
|
7
8
|
const objectId = id;
|
|
8
9
|
|
|
9
10
|
const defaultActiveTab = 0;
|
|
@@ -11,6 +12,7 @@ export const ObjectTypesWidget = (props) => {
|
|
|
11
12
|
const [activeTab, setActiveTab] = React.useState(
|
|
12
13
|
defaultActiveTab > -1 ? defaultActiveTab : 0,
|
|
13
14
|
);
|
|
15
|
+
|
|
14
16
|
const createTab = ({ schema, id, icon }, index) => {
|
|
15
17
|
return {
|
|
16
18
|
menuItem: () => (
|
|
@@ -42,7 +44,13 @@ export const ObjectTypesWidget = (props) => {
|
|
|
42
44
|
|
|
43
45
|
return (
|
|
44
46
|
<Tab
|
|
45
|
-
menu={{
|
|
47
|
+
menu={{
|
|
48
|
+
vertical:
|
|
49
|
+
device === 'computer' || device === 'tablet' || device === 'mobile'
|
|
50
|
+
? false
|
|
51
|
+
: true,
|
|
52
|
+
tabular: true,
|
|
53
|
+
}}
|
|
46
54
|
panes={schemas.map(createTab)}
|
|
47
55
|
activeIndex={activeTab}
|
|
48
56
|
grid={{ paneWidth: 9, tabWidth: 3 }}
|
|
@@ -50,4 +58,4 @@ export const ObjectTypesWidget = (props) => {
|
|
|
50
58
|
);
|
|
51
59
|
};
|
|
52
60
|
|
|
53
|
-
export default ObjectTypesWidget;
|
|
61
|
+
export default withDeviceSize(ObjectTypesWidget);
|
|
@@ -4,11 +4,11 @@ import Webmap from '../Webmap';
|
|
|
4
4
|
const VisualizationView = (props) => {
|
|
5
5
|
const { content = {} } = props;
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const { map_visualization_data = {} } = content;
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
10
|
<div>
|
|
11
|
-
<Webmap data={
|
|
11
|
+
<Webmap data={map_visualization_data} />
|
|
12
12
|
</div>
|
|
13
13
|
);
|
|
14
14
|
};
|
|
@@ -66,25 +66,20 @@ const GeneralSchema = ({ data = {} }) => {
|
|
|
66
66
|
id: 'default',
|
|
67
67
|
title: 'Zoom',
|
|
68
68
|
fields: [
|
|
69
|
-
'show_print',
|
|
70
69
|
'print_position',
|
|
71
|
-
'show_zoom',
|
|
72
|
-
'centerOnExtent',
|
|
73
70
|
'zoom_position',
|
|
71
|
+
'centerOnExtent',
|
|
74
72
|
...(!centerOnExtent ? ['zoom_level', 'long', 'lat'] : []),
|
|
75
73
|
],
|
|
76
74
|
},
|
|
77
75
|
],
|
|
78
76
|
properties: {
|
|
79
|
-
show_zoom: {
|
|
80
|
-
title: 'Show zoom',
|
|
81
|
-
type: 'boolean',
|
|
82
|
-
},
|
|
83
77
|
centerOnExtent: {
|
|
84
78
|
title: 'Center on extent',
|
|
85
79
|
type: 'boolean',
|
|
86
80
|
description:
|
|
87
81
|
'This will override latitude/longitude/zoom level and will lock zoom/moving the map.',
|
|
82
|
+
default: true,
|
|
88
83
|
},
|
|
89
84
|
zoom_position: {
|
|
90
85
|
title: 'Zoom position',
|
|
@@ -106,10 +101,7 @@ const GeneralSchema = ({ data = {} }) => {
|
|
|
106
101
|
title: 'Latitude',
|
|
107
102
|
type: 'number',
|
|
108
103
|
},
|
|
109
|
-
|
|
110
|
-
title: 'Show print',
|
|
111
|
-
type: 'boolean',
|
|
112
|
-
},
|
|
104
|
+
|
|
113
105
|
print_position: {
|
|
114
106
|
title: 'Print position',
|
|
115
107
|
choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
|
|
@@ -20,3 +20,47 @@
|
|
|
20
20
|
display: flex;
|
|
21
21
|
padding: 1rem 0;
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
.map-editor-modal {
|
|
25
|
+
width: '95% !important';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.webmap-container {
|
|
29
|
+
position: sticky;
|
|
30
|
+
top: 10px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.map-edit-actions-container {
|
|
34
|
+
padding: 5px 0;
|
|
35
|
+
margin-right: 10px;
|
|
36
|
+
margin-left: auto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.layer-reset-button {
|
|
40
|
+
margin-top: 5px !important;
|
|
41
|
+
animation: fadeDown 0.2s ease-in;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.layer-check-button {
|
|
45
|
+
margin-top: 5px !important;
|
|
46
|
+
margin-left: auto !important;
|
|
47
|
+
animation: fadeDown 0.2s ease-in;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.layer-submit-button {
|
|
51
|
+
margin-top: 5px !important;
|
|
52
|
+
margin-left: auto !important;
|
|
53
|
+
animation: fadeDown 0.2s ease-in;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@keyframes fadeDown {
|
|
57
|
+
from {
|
|
58
|
+
opacity: 0;
|
|
59
|
+
transform: translate3d(0, -20%, 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
to {
|
|
63
|
+
opacity: 1;
|
|
64
|
+
transform: translate3d(0, 0, 0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SidebarPortal } from '@plone/volto/components';
|
|
3
|
+
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
4
|
+
import { Schema } from './Schema';
|
|
5
|
+
import View from './View';
|
|
6
|
+
import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
|
|
7
|
+
import './styles/map.css';
|
|
8
|
+
|
|
9
|
+
const Edit = (props) => {
|
|
10
|
+
const { block, data, onChangeBlock, selected } = props;
|
|
11
|
+
const schema = React.useMemo(() => Schema(props), [props]);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<View data={data} />
|
|
16
|
+
<SidebarPortal selected={selected}>
|
|
17
|
+
<BlockDataForm
|
|
18
|
+
block={block}
|
|
19
|
+
title={schema.title}
|
|
20
|
+
schema={addPrivacyProtectionToSchema(schema)}
|
|
21
|
+
onChangeField={(id, value) => {
|
|
22
|
+
onChangeBlock(block, {
|
|
23
|
+
...data,
|
|
24
|
+
[id]: value,
|
|
25
|
+
});
|
|
26
|
+
}}
|
|
27
|
+
formData={data}
|
|
28
|
+
/>
|
|
29
|
+
</SidebarPortal>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default Edit;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const Schema = (props) => {
|
|
2
|
+
return {
|
|
3
|
+
title: 'Embed EEA Map Block',
|
|
4
|
+
fieldsets: [
|
|
5
|
+
{
|
|
6
|
+
id: 'default',
|
|
7
|
+
title: 'Default',
|
|
8
|
+
fields: [
|
|
9
|
+
'vis_url',
|
|
10
|
+
'description',
|
|
11
|
+
'height',
|
|
12
|
+
'show_legend',
|
|
13
|
+
'show_download',
|
|
14
|
+
'show_viewer',
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
properties: {
|
|
19
|
+
vis_url: {
|
|
20
|
+
widget: 'object_by_path',
|
|
21
|
+
title: 'Visualization',
|
|
22
|
+
},
|
|
23
|
+
height: {
|
|
24
|
+
title: 'Height',
|
|
25
|
+
type: 'number',
|
|
26
|
+
},
|
|
27
|
+
description: {
|
|
28
|
+
title: 'Description',
|
|
29
|
+
widget: 'slate',
|
|
30
|
+
},
|
|
31
|
+
show_legend: {
|
|
32
|
+
title: 'Show legend',
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
},
|
|
35
|
+
show_download: {
|
|
36
|
+
title: 'Show download',
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
},
|
|
39
|
+
show_viewer: {
|
|
40
|
+
title: 'Show web viewer',
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: [],
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { connect } from 'react-redux';
|
|
4
|
+
import { compose } from 'redux';
|
|
5
|
+
|
|
6
|
+
import { PrivacyProtection } from '@eeacms/volto-embed';
|
|
7
|
+
import Webmap from '../EEAMap/components/Webmap';
|
|
8
|
+
import ExtraViews from '../EEAMap/components/widgets/ExtraViews';
|
|
9
|
+
import { getVisualization } from '@eeacms/volto-eea-map/actions';
|
|
10
|
+
|
|
11
|
+
const View = (props) => {
|
|
12
|
+
const { data, map_visualization } = props || {};
|
|
13
|
+
const { height = '', vis_url = '' } = data;
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (vis_url) {
|
|
17
|
+
props.getVisualization(vis_url);
|
|
18
|
+
}
|
|
19
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
+
}, [vis_url]);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<PrivacyProtection data={data} {...props}>
|
|
25
|
+
{map_visualization && (
|
|
26
|
+
<div>
|
|
27
|
+
<Webmap data={map_visualization.data} height={height} />
|
|
28
|
+
<ExtraViews data={{ ...data, map_data: map_visualization.data }} />
|
|
29
|
+
</div>
|
|
30
|
+
)}
|
|
31
|
+
{!map_visualization && (
|
|
32
|
+
<p>No map view to show. Set visualization in block configuration.</p>
|
|
33
|
+
)}
|
|
34
|
+
</PrivacyProtection>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default compose(
|
|
40
|
+
connect(
|
|
41
|
+
(state, props) => ({
|
|
42
|
+
map_visualization: state.map_visualizations.data[props.data.vis_url],
|
|
43
|
+
}),
|
|
44
|
+
{
|
|
45
|
+
getVisualization,
|
|
46
|
+
},
|
|
47
|
+
),
|
|
48
|
+
)(View);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.map-edit-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.map-modal-trigger-button {
|
|
6
|
+
margin-bottom: 10px !important;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
#map-editor-modal {
|
|
10
|
+
top: auto;
|
|
11
|
+
left: auto !important;
|
|
12
|
+
width: 95% !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#map-widget-toggle {
|
|
16
|
+
color: blue !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.map-text-view {
|
|
20
|
+
display: flex;
|
|
21
|
+
padding: 1rem 0;
|
|
22
|
+
}
|
package/src/components/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import EEAMapView from './Blocks/EEAMap/View';
|
|
2
2
|
import EEAMapEdit from './Blocks/EEAMap/Edit';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import EmbedMapView from './Blocks/EmbedEEAMap/View';
|
|
5
|
+
import EmbedMapEdit from './Blocks/EmbedEEAMap/Edit';
|
|
6
|
+
|
|
7
|
+
export { EEAMapEdit, EEAMapView, EmbedMapView, EmbedMapEdit };
|
package/src/constants.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GET_MAP_VISUALIZATION = 'GET_MAP_VISUALIZATION';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export default function withDeviceSize(WrappedComponent) {
|
|
4
|
+
return (props) => {
|
|
5
|
+
const [device, setDevice] = React.useState(null);
|
|
6
|
+
|
|
7
|
+
const updateScreenSize = () => {
|
|
8
|
+
if (__CLIENT__) {
|
|
9
|
+
const screenWidth =
|
|
10
|
+
window.innerWidth ||
|
|
11
|
+
document.documentElement.clientWidth ||
|
|
12
|
+
document.body.clientWidth ||
|
|
13
|
+
0;
|
|
14
|
+
|
|
15
|
+
setDevice(getDeviceConfig(screenWidth));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getDeviceConfig = (width) => {
|
|
20
|
+
// semantic ui breakpoints
|
|
21
|
+
if (width < 320) {
|
|
22
|
+
return 'mobile';
|
|
23
|
+
} else if (width >= 320 && width < 768) {
|
|
24
|
+
return 'tablet';
|
|
25
|
+
} else if (width >= 768 && width < 992) {
|
|
26
|
+
return 'computer';
|
|
27
|
+
} else if (width >= 992 && width < 1280) {
|
|
28
|
+
return 'large';
|
|
29
|
+
} else if (width >= 1280) {
|
|
30
|
+
return 'widescreen';
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
updateScreenSize();
|
|
36
|
+
window.addEventListener('resize', updateScreenSize);
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener('resize', updateScreenSize);
|
|
39
|
+
};
|
|
40
|
+
/* eslint-disable-next-line */
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
return <WrappedComponent {...props} device={device} />;
|
|
44
|
+
};
|
|
45
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EEAMapEdit,
|
|
3
|
+
EEAMapView,
|
|
4
|
+
EmbedMapView,
|
|
5
|
+
EmbedMapEdit,
|
|
6
|
+
} from '@eeacms/volto-eea-map/components';
|
|
2
7
|
import world from '@plone/volto/icons/world.svg';
|
|
3
8
|
import LayerSelectWidget from './components/Blocks/EEAMap/components/widgets/LayerSelectWidget';
|
|
4
9
|
import MapEditorWidget from './components/Blocks/EEAMap/components/widgets/MapEditorWidget';
|
|
@@ -6,6 +11,9 @@ import ObjectTypesWidget from './components/Blocks/EEAMap/components/widgets/Obj
|
|
|
6
11
|
import VisualizationEditorWidget from './components/Blocks/EEAMap/components/widgets/VisualizationEditorWidget';
|
|
7
12
|
import VisualizationView from './components/Blocks/EEAMap/components/widgets/VisualizationView';
|
|
8
13
|
|
|
14
|
+
import { data_visualizations } from './middlewares';
|
|
15
|
+
import * as addonReducers from './reducers';
|
|
16
|
+
|
|
9
17
|
export default (config) => {
|
|
10
18
|
config.settings.allowed_cors_destinations = [
|
|
11
19
|
...(config.settings.allowed_cors_destinations || []),
|
|
@@ -50,14 +58,52 @@ export default (config) => {
|
|
|
50
58
|
],
|
|
51
59
|
};
|
|
52
60
|
|
|
61
|
+
config.blocks.blocksConfig.embed_eea_map_block = {
|
|
62
|
+
id: 'embed_eea_map_block', // The name (id) of the block
|
|
63
|
+
title: 'Embed EEA Map', // The display name of the block
|
|
64
|
+
icon: world, // The icon used in the block chooser
|
|
65
|
+
group: 'common', // The group (blocks can be grouped, displayed in the chooser)
|
|
66
|
+
view: EmbedMapView, // The view mode component
|
|
67
|
+
edit: EmbedMapEdit, // The edit mode component
|
|
68
|
+
sidebarTab: 1, // The sidebar tab you want to be selected when selecting the block
|
|
69
|
+
security: {
|
|
70
|
+
addPermission: [], // Future proof (not implemented yet) add user permission role(s)
|
|
71
|
+
view: [], // Future proof (not implemented yet) view user role(s)
|
|
72
|
+
},
|
|
73
|
+
variations: [
|
|
74
|
+
{
|
|
75
|
+
id: 'default',
|
|
76
|
+
title: 'EEA Map (default)',
|
|
77
|
+
isDefault: true,
|
|
78
|
+
view: EEAMapView,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'extra',
|
|
82
|
+
title: 'Extra variation (expand if needed)',
|
|
83
|
+
isDefault: true,
|
|
84
|
+
view: EEAMapView,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
|
|
53
89
|
config.widgets.widget.map_edit_widget = MapEditorWidget;
|
|
54
90
|
config.widgets.widget.map_layers_widget = LayerSelectWidget;
|
|
55
91
|
config.widgets.widget.object_types_widget = ObjectTypesWidget;
|
|
56
92
|
|
|
57
93
|
//map editor for the visualization(content-type)
|
|
58
|
-
config.widgets.id.
|
|
94
|
+
config.widgets.id.map_visualization_data = VisualizationEditorWidget;
|
|
59
95
|
//map viewer for the visualization(content-type)
|
|
60
96
|
config.views.contentTypesViews.map_visualization = VisualizationView;
|
|
61
97
|
|
|
98
|
+
config.settings.storeExtenders = [
|
|
99
|
+
...(config.settings.storeExtenders || []),
|
|
100
|
+
data_visualizations,
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
config.addonReducers = {
|
|
104
|
+
...config.addonReducers,
|
|
105
|
+
...addonReducers,
|
|
106
|
+
};
|
|
107
|
+
|
|
62
108
|
return config;
|
|
63
109
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GET_MAP_VISUALIZATION } from '@eeacms/volto-eea-map/constants';
|
|
2
|
+
|
|
3
|
+
export const data_visualizations = (middlewares) => [
|
|
4
|
+
(store) => (next) => (action) => {
|
|
5
|
+
if (action.type === GET_MAP_VISUALIZATION) {
|
|
6
|
+
store.dispatch({
|
|
7
|
+
type: `${GET_MAP_VISUALIZATION}_PENDING`,
|
|
8
|
+
path: action.path,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return next(action);
|
|
12
|
+
},
|
|
13
|
+
...middlewares,
|
|
14
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './map_visualizations';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GET_MAP_VISUALIZATION } from '@eeacms/volto-eea-map/constants';
|
|
2
|
+
|
|
3
|
+
const initialState = {
|
|
4
|
+
data: {},
|
|
5
|
+
error: null,
|
|
6
|
+
loaded: false,
|
|
7
|
+
loading: false,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default function data_providers(state = initialState, action = {}) {
|
|
11
|
+
const path = action.path
|
|
12
|
+
? action.path.replace(`/@map-visualization`, '')
|
|
13
|
+
: undefined;
|
|
14
|
+
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case `${GET_MAP_VISUALIZATION}_PENDING`:
|
|
17
|
+
return {
|
|
18
|
+
...state,
|
|
19
|
+
error: null,
|
|
20
|
+
loaded: false,
|
|
21
|
+
loading: true,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
case `${GET_MAP_VISUALIZATION}_SUCCESS`:
|
|
25
|
+
return {
|
|
26
|
+
...state,
|
|
27
|
+
error: null,
|
|
28
|
+
data: {
|
|
29
|
+
...state.data,
|
|
30
|
+
[path]: action.result.map_visualization,
|
|
31
|
+
},
|
|
32
|
+
loaded: true,
|
|
33
|
+
loading: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
case `${GET_MAP_VISUALIZATION}_FAIL`:
|
|
37
|
+
return {
|
|
38
|
+
...state,
|
|
39
|
+
error: action.error,
|
|
40
|
+
data: { ...state.data },
|
|
41
|
+
loaded: false,
|
|
42
|
+
loading: false,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
default:
|
|
46
|
+
return state;
|
|
47
|
+
}
|
|
48
|
+
}
|