@eeacms/volto-eea-map 0.1.13 → 0.1.14

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +1 -1
  3. package/src/actionTypes.js +1 -0
  4. package/src/actions.js +1 -1
  5. package/src/components/Blocks/EEAMap/Edit.jsx +1 -1
  6. package/src/components/Blocks/EEAMap/Schema.js +3 -5
  7. package/src/components/Blocks/EEAMap/View.jsx +3 -2
  8. package/src/components/Blocks/EmbedEEAMap/Edit.jsx +4 -7
  9. package/src/components/Blocks/EmbedEEAMap/Schema.js +13 -7
  10. package/src/components/Blocks/EmbedEEAMap/View.jsx +62 -44
  11. package/src/components/ExtraViews.jsx +85 -0
  12. package/src/components/{Blocks/EEAMap/components/Webmap.jsx → Webmap.jsx} +33 -31
  13. package/src/components/index.js +6 -6
  14. package/src/components/visualization/VisualizationEditorWidget.jsx +120 -0
  15. package/src/components/{Blocks/EEAMap/components/widgets → visualization}/VisualizationView.jsx +0 -0
  16. package/src/components/{Blocks/EEAMap/components/widgets → visualization}/panelsSchema.js +0 -1
  17. package/src/components/widgets/DataQueryWidget.jsx +50 -0
  18. package/src/components/{Blocks/EEAMap/components/widgets → widgets}/LayerSelectWidget.jsx +102 -46
  19. package/src/components/{Blocks/EEAMap/components/widgets/LayersPanel.jsx → widgets/LayersPanelWidget.jsx} +2 -2
  20. package/src/components/{Blocks/EEAMap/components/widgets → widgets}/LegendWidget.jsx +45 -31
  21. package/src/components/{Blocks/EEAMap/components/widgets → widgets}/MapEditorWidget.jsx +1 -0
  22. package/src/components/{Blocks/EEAMap/components/widgets → widgets}/ObjectTypesWidget.jsx +1 -2
  23. package/src/components/widgets/panelsSchema.js +151 -0
  24. package/src/constants.js +29 -1
  25. package/src/index.js +41 -41
  26. package/src/middlewares/index.js +1 -1
  27. package/src/reducers/map_visualizations.js +1 -1
  28. package/src/static/code-line.svg +1 -0
  29. package/src/{components/Blocks/EEAMap/styles → styles}/map.css +60 -5
  30. package/src/{components/Blocks/EEAMap/utils.js → utils.js} +18 -2
  31. package/src/components/Blocks/EEAMap/components/widgets/DataQueryWidget.jsx +0 -46
  32. package/src/components/Blocks/EEAMap/components/widgets/ExtraViews.jsx +0 -86
  33. package/src/components/Blocks/EEAMap/components/widgets/VisualizationEditorWidget.jsx +0 -94
  34. package/src/components/Blocks/EEAMap/constants.js +0 -29
  35. package/src/components/Blocks/EmbedEEAMap/styles/map.css +0 -22
package/CHANGELOG.md CHANGED
@@ -4,8 +4,26 @@ 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.14](https://github.com/eea/volto-eea-map/compare/0.1.13...0.1.14)
8
+
9
+ - new sources styles, icons from remixicon [`c9cca2a`](https://github.com/eea/volto-eea-map/commit/c9cca2a5e41322cfdeca1865b47a1892514c1cfc)
10
+ - reorganize & clean [`a902b89`](https://github.com/eea/volto-eea-map/commit/a902b8945389b19b388e85e00066b2c46a9e1a2e)
11
+ - Layer widget improvements [`99abe57`](https://github.com/eea/volto-eea-map/commit/99abe5722590719ac7e640de44a69ee19fcecfdf)
12
+ - Change data queries cards [`8d3c742`](https://github.com/eea/volto-eea-map/commit/8d3c74239f62782737108c25e84683239e6ab12f)
13
+ - Set default settings [`2c26f57`](https://github.com/eea/volto-eea-map/commit/2c26f571618d289158c7d32fd9814edcd29a7c60)
14
+ - Add description to layer [`cccfd59`](https://github.com/eea/volto-eea-map/commit/cccfd598060c4228215a5add1da3e159312966b2)
15
+ - only embed viz for now [`6bb7daf`](https://github.com/eea/volto-eea-map/commit/6bb7daf458a47bd185870ec3627a542f8ba715bc)
16
+ - Visualization improvements [`2a77f8b`](https://github.com/eea/volto-eea-map/commit/2a77f8bba1f6fd840d41043ee41b1b3bd23807f3)
17
+ - Cleanup [`6d6ceb9`](https://github.com/eea/volto-eea-map/commit/6d6ceb99768ff477a727cf217e48099e6f2d1a59)
18
+ - Add all query parameters with all values [`2f8c617`](https://github.com/eea/volto-eea-map/commit/2f8c61711154953ec25e20614b4ad96ed2bf592b)
19
+ - Data query widget visual improvements [`7eb3144`](https://github.com/eea/volto-eea-map/commit/7eb3144ad58a839ccc96f22d58a441b245893ea7)
20
+ - Data query widget more responsive to changes [`bb86329`](https://github.com/eea/volto-eea-map/commit/bb863299d51627a28f02e2cda133fc0e3bf9ebe9)
21
+
7
22
  #### [0.1.13](https://github.com/eea/volto-eea-map/compare/0.1.12...0.1.13)
8
23
 
24
+ > 22 August 2022
25
+
26
+ - Enable Embed EEA map access to data_query [`#13`](https://github.com/eea/volto-eea-map/pull/13)
9
27
  - update embed map with data_query [`719c007`](https://github.com/eea/volto-eea-map/commit/719c00776dff7ba63bbd57761a2c86ec5345a911)
10
28
 
11
29
  #### [0.1.12](https://github.com/eea/volto-eea-map/compare/0.1.11...0.1.12)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
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",
@@ -0,0 +1 @@
1
+ export const GET_MAP_VISUALIZATION = 'GET_MAP_VISUALIZATION';
package/src/actions.js CHANGED
@@ -1,4 +1,4 @@
1
- import { GET_MAP_VISUALIZATION } from './constants';
1
+ import { GET_MAP_VISUALIZATION } from './actionTypes';
2
2
 
3
3
  export function getVisualization(path) {
4
4
  return {
@@ -11,7 +11,7 @@ import View from './View';
11
11
  import { getContent } from '@plone/volto/actions';
12
12
 
13
13
  import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
14
- import './styles/map.css';
14
+ import '../../../styles/map.css';
15
15
 
16
16
  const Edit = (props) => {
17
17
  const { block, data, onChangeBlock, selected, id } = props;
@@ -39,16 +39,14 @@ export const Schema = (props) => {
39
39
  title: 'Show legend',
40
40
  type: 'boolean',
41
41
  },
42
- show_download: {
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: 'Data query parameters',
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 './components/Webmap';
7
- import ExtraViews from './components/widgets/ExtraViews';
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
 
@@ -10,7 +10,7 @@ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
10
10
  import View from './View';
11
11
  import { Schema } from './Schema';
12
12
  import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
13
- import './styles/map.css';
13
+ import '../../../styles/map.css';
14
14
 
15
15
  const Edit = (props) => {
16
16
  const { block, data, onChangeBlock, selected, id } = props;
@@ -20,12 +20,9 @@ const Edit = (props) => {
20
20
  props.getContent(data.vis_url, null, id);
21
21
  // eslint-disable-next-line react-hooks/exhaustive-deps
22
22
  }, [data.vis_url]);
23
-
24
23
  React.useEffect(() => {
25
- if (
26
- !data.data_query_params ||
27
- props.data_query !== data.data_query_params
28
- ) {
24
+ const diffParams = props.data_query !== data.data_query_params;
25
+ if (diffParams || !data.data_query_params) {
29
26
  onChangeBlock(block, {
30
27
  ...data,
31
28
  data_query_params: props.data_query,
@@ -36,7 +33,7 @@ const Edit = (props) => {
36
33
 
37
34
  return (
38
35
  <div>
39
- <View data={data} id={id} />
36
+ <View data={data} id={id} isEdit={true} />
40
37
  <SidebarPortal selected={selected}>
41
38
  <BlockDataForm
42
39
  block={block}
@@ -10,10 +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',
16
- 'data_query_params',
15
+ 'enable_queries',
16
+ ...(props.data.enable_queries ? ['data_query_params'] : []),
17
17
  ],
18
18
  },
19
19
  ],
@@ -32,22 +32,28 @@ export const Schema = (props) => {
32
32
  },
33
33
  show_sources: {
34
34
  title: 'Show sources',
35
+ description: 'Will show sources set in this page Data provenance',
35
36
  type: 'boolean',
36
37
  },
37
38
  show_legend: {
38
39
  title: 'Show legend',
39
40
  type: 'boolean',
40
41
  },
41
- show_download: {
42
- title: 'Show download',
42
+ show_viewer: {
43
+ title: 'Show API link',
44
+ description: 'Open the map on ArcGIS js service',
43
45
  type: 'boolean',
44
46
  },
45
- show_viewer: {
46
- title: 'Show web viewer',
47
+ enable_queries: {
48
+ title: 'Enable queries',
49
+ description:
50
+ 'Will import Criteria from content-type and try to query map layer fields.',
47
51
  type: 'boolean',
48
52
  },
49
53
  data_query_params: {
50
- title: 'Data query parameters',
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',
51
57
  widget: 'data_query_widget',
52
58
  },
53
59
  },
@@ -4,85 +4,99 @@ import { connect } from 'react-redux';
4
4
  import { compose } from 'redux';
5
5
 
6
6
  import { PrivacyProtection } from '@eeacms/volto-embed';
7
- import Webmap from '../EEAMap/components/Webmap';
8
- import ExtraViews from '../EEAMap/components/widgets/ExtraViews';
7
+
9
8
  import { getContent } from '@plone/volto/actions';
9
+ import { getVisualization } from '../../../actions';
10
+ import Webmap from '../../Webmap';
11
+ import ExtraViews from '../../ExtraViews';
10
12
 
11
13
  const View = (props) => {
12
- const { data, viz_content = {}, id } = props || {};
13
- const { height = '', vis_url = '' } = data;
14
+ const { data, viz_content = {}, id, isEdit, map_visualization } = props || {};
15
+ const { height = '', vis_url = '', enable_queries } = data;
14
16
 
15
- const { map_visualization_data = '', data_provenance = {} } =
16
- viz_content || {};
17
+ const { data_provenance = {} } = viz_content || {};
17
18
 
18
- const [mapData, setMapData] = React.useState(map_visualization_data);
19
+ const [mapData, setMapData] = React.useState(map_visualization);
19
20
 
20
21
  React.useEffect(() => {
21
- if (vis_url && !map_visualization_data) {
22
+ if (vis_url) {
22
23
  props.getContent(vis_url, null, id);
24
+ props.getVisualization(vis_url);
23
25
  }
24
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
25
- }, [vis_url]);
27
+ }, [vis_url, enable_queries]);
26
28
 
27
29
  React.useEffect(() => {
30
+ const query_params = isEdit
31
+ ? props.data.data_query_params
32
+ : props.data_query;
33
+ var altMapData = { ...map_visualization };
34
+
28
35
  if (
29
- props.data_query &&
30
- props.data_query.length > 0 &&
31
- map_visualization_data
36
+ enable_queries &&
37
+ query_params &&
38
+ query_params.length > 0 &&
39
+ altMapData.layers &&
40
+ altMapData.layers.map_layers &&
41
+ altMapData.layers.map_layers.length > 0
32
42
  ) {
33
- let altMapData = { ...map_visualization_data };
43
+ let rules = [];
44
+ altMapData.layers.map_layers.forEach((l, j) => {
45
+ query_params.forEach((param, i) => {
46
+ const matchingFields =
47
+ l.map_layer && l.map_layer.fields && l.map_layer.fields.length > 0
48
+ ? l.map_layer.fields.filter(
49
+ (field, k) =>
50
+ field.name === param.alias || field.name === param.i,
51
+ )
52
+ : [];
34
53
 
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
+ matchingFields.forEach((m, i) => {
55
+ const newRules = param.v
56
+ ? param.v.map((paramVal, i) => {
54
57
  return {
55
- field: param.alias ? param.alias : param.i,
58
+ field: m.name,
56
59
  operator: '=',
57
- value: param.v[0],
60
+ value: paramVal,
58
61
  };
59
- }),
60
- };
61
- altMapData.layers.map_layers[j].map_layer.query = autoQuery;
62
- }
62
+ })
63
+ : [];
64
+ rules = rules.concat(newRules);
63
65
  });
64
- }
66
+ });
67
+ let autoQuery = {
68
+ combinator: 'or',
69
+ rules,
70
+ };
71
+ altMapData.layers.map_layers[j].map_layer.query = autoQuery;
65
72
  });
66
- setMapData(altMapData);
67
73
  }
68
- }, [props.data_query, map_visualization_data]);
74
+ setMapData(altMapData);
75
+ }, [
76
+ map_visualization,
77
+ props.data,
78
+ props.data_query,
79
+ viz_content,
80
+ isEdit,
81
+ enable_queries,
82
+ ]);
69
83
 
70
84
  return (
71
85
  <div>
72
86
  <PrivacyProtection data={data} {...props}>
73
- {map_visualization_data && (
87
+ {mapData && (
74
88
  <div>
75
89
  <Webmap data={mapData} height={height} />
76
90
  <ExtraViews
77
91
  data={{
78
92
  ...data,
79
93
  data_provenance,
80
- map_data: map_visualization_data,
94
+ map_data: map_visualization,
81
95
  }}
82
96
  />
83
97
  </div>
84
98
  )}
85
- {!map_visualization_data && (
99
+ {!mapData && (
86
100
  <p>No map view to show. Set visualization in block configuration.</p>
87
101
  )}
88
102
  </PrivacyProtection>
@@ -94,10 +108,14 @@ export default compose(
94
108
  connect(
95
109
  (state, props) => ({
96
110
  data_query: state.content.data.data_query,
111
+ state,
112
+ map_visualization:
113
+ state.map_visualizations?.data[props.data.vis_url]?.data,
97
114
  viz_content: state.content.subrequests?.[props.id]?.data,
98
115
  }),
99
116
  {
100
117
  getContent,
118
+ getVisualization,
101
119
  },
102
120
  ),
103
121
  )(View);
@@ -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 '@eeacms/volto-eea-map/hocs';
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
- 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 ? formatQuery(query, 'sql') : '',
106
- });
107
- break;
108
- case 'Group Layer':
109
- mapLayer = new GroupLayer({ url });
110
- break;
111
- default:
112
- break;
113
- }
114
- return mapLayer;
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, base_layer, map_layers, general, legend]);
198
+ }, [modules, data, data.layers, map_layers]);
197
199
 
198
200
  return (
199
201
  <div>
@@ -1,7 +1,7 @@
1
- import EEAMapView from './Blocks/EEAMap/View';
2
- import EEAMapEdit from './Blocks/EEAMap/Edit';
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
- import EmbedMapView from './Blocks/EmbedEEAMap/View';
5
- import EmbedMapEdit from './Blocks/EmbedEEAMap/Edit';
6
-
7
- export { EEAMapEdit, EEAMapView, EmbedMapView, EmbedMapEdit };
6
+ export EmbedMapView from './Blocks/EmbedEEAMap/View';
7
+ export EmbedMapEdit from './Blocks/EmbedEEAMap/Edit';
@@ -0,0 +1,120 @@
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
+ }, [intValue]);
54
+
55
+ return (
56
+ <FormFieldWrapper {...props}>
57
+ <div className="wrapper">
58
+ <Button
59
+ floated="right"
60
+ size="tiny"
61
+ onClick={(e) => {
62
+ e.preventDefault();
63
+ e.stopPropagation();
64
+ setOpen(true);
65
+ }}
66
+ >
67
+ Open Map Editor
68
+ </Button>
69
+ </div>
70
+
71
+ {open && (
72
+ <Modal
73
+ id="map-editor-modal"
74
+ style={{ width: '95% !important' }}
75
+ open={true}
76
+ >
77
+ <Modal.Content scrolling>
78
+ <Grid stackable reversed="mobile vertically tablet vertically">
79
+ <Grid.Column
80
+ mobile={12}
81
+ tablet={12}
82
+ computer={5}
83
+ className="map-editor-column"
84
+ >
85
+ <InlineForm
86
+ block={block}
87
+ schema={schema}
88
+ onChangeField={(id, value) => {
89
+ handleChangeField(value);
90
+ }}
91
+ formData={dataForm}
92
+ />
93
+ </Grid.Column>
94
+ <Grid.Column mobile={12} tablet={12} computer={7}>
95
+ <div className="webmap-container">
96
+ <Webmap data={intValue} editMode={true} />
97
+ </div>
98
+ </Grid.Column>
99
+ </Grid>
100
+ </Modal.Content>
101
+ <Modal.Actions>
102
+ <Grid>
103
+ <Grid.Row>
104
+ <div className="map-edit-actions-container">
105
+ <Button onClick={handleClose}>Close</Button>
106
+ <Button color="green" onClick={handleApplyChanges}>
107
+ Apply changes
108
+ </Button>
109
+ </div>
110
+ </Grid.Row>
111
+ </Grid>
112
+ </Modal.Actions>
113
+ </Modal>
114
+ )}
115
+ <Webmap data={value} editMode={true} />
116
+ </FormFieldWrapper>
117
+ );
118
+ };
119
+
120
+ export default VisualizationEditorWidget;
@@ -79,7 +79,6 @@ const GeneralSchema = ({ data = {} }) => {
79
79
  type: 'boolean',
80
80
  description:
81
81
  'This will override latitude/longitude/zoom level and will lock zoom/moving the map.',
82
- default: true,
83
82
  },
84
83
  zoom_position: {
85
84
  title: 'Zoom position',