@eeacms/volto-eea-map 0.1.2 → 0.1.3

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 CHANGED
@@ -4,8 +4,27 @@ 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.3](https://github.com/eea/volto-eea-map/compare/0.1.2...0.1.3)
8
+
9
+ - Icons & download/viewer change [`321f538`](https://github.com/eea/volto-eea-map/commit/321f538e9582f9a12db3f64beb26588616e867e2)
10
+ - Inline inputs actions & styles [`1f4787e`](https://github.com/eea/volto-eea-map/commit/1f4787e3b3f0dc1328ff23cca2459db816188e3a)
11
+ - more updates for cy10 [`4d5c6a1`](https://github.com/eea/volto-eea-map/commit/4d5c6a1925413b44acc70b5ad3753378830dba2d)
12
+ - updates for cy10 [`30e0293`](https://github.com/eea/volto-eea-map/commit/30e0293ed79cad3cf3f62bcacd3c14a5627543bd)
13
+ - upgrade to cypress 10 [`fe9ca3e`](https://github.com/eea/volto-eea-map/commit/fe9ca3e6a98dd02c6b774f931fe73f18712e0e7b)
14
+ - padding & menu dimension [`da27ccd`](https://github.com/eea/volto-eea-map/commit/da27ccd2b0b42fb5c325a76bdde63e92216b1c93)
15
+ - general tab settings move to block schema [`075baed`](https://github.com/eea/volto-eea-map/commit/075baed1629964b40d355c8612498e02a16eedfc)
16
+ - enable conditional editor schema [`801f3c1`](https://github.com/eea/volto-eea-map/commit/801f3c1999b9b7373d1093d3835d62df8bd2fbca)
17
+ - run cypress on latest alpha [`0935ace`](https://github.com/eea/volto-eea-map/commit/0935aceedb0963b770aa9579c2c21a4f543513c3)
18
+ - Clear schema [`4b22f0a`](https://github.com/eea/volto-eea-map/commit/4b22f0aee58cca2bbcd2a8bee9864a01d65e7738)
19
+ - Center on extent control [`9e8b13d`](https://github.com/eea/volto-eea-map/commit/9e8b13dfd5bbfa5eb2419c54444a15fefa384de4)
20
+ - Clear consoles [`798bc2f`](https://github.com/eea/volto-eea-map/commit/798bc2fbf6f77ffadcedcf1e4666b315bc71ea6c)
21
+ - Center map on first layer [`8fbc1ca`](https://github.com/eea/volto-eea-map/commit/8fbc1ca711ceba09e38e841cd7f551c1a8787027)
22
+
7
23
  #### [0.1.2](https://github.com/eea/volto-eea-map/compare/0.1.1...0.1.2)
8
24
 
25
+ > 29 July 2022
26
+
27
+ - Develop [`#2`](https://github.com/eea/volto-eea-map/pull/2)
9
28
  - Legend only selected layer [`3474d79`](https://github.com/eea/volto-eea-map/commit/3474d7989321f656397c292bddc289f8f6329a8e)
10
29
  - Query layer by existing fields [`52363f5`](https://github.com/eea/volto-eea-map/commit/52363f57a9ab4e49c7418e883bdf0c5bb30c1734)
11
30
  - Cleanup [`d4e07b2`](https://github.com/eea/volto-eea-map/commit/d4e07b2fb89a5a27f5e4411047cb43e1c8add769)
@@ -0,0 +1,36 @@
1
+ const { defineConfig } = require('cypress');
2
+
3
+ module.exports = defineConfig({
4
+ viewportWidth: 1280,
5
+ defaultCommandTimeout: 8888,
6
+ chromeWebSecurity: false,
7
+ reporter: 'junit',
8
+ video: true,
9
+
10
+ retries: {
11
+ runMode: 8,
12
+ openMode: 0,
13
+ },
14
+
15
+ reporterOptions: {
16
+ mochaFile: 'cypress/reports/cypress-[hash].xml',
17
+ jenkinsMode: true,
18
+ toConsole: true,
19
+ },
20
+
21
+ e2e: {
22
+ // We've imported your old cypress plugins here.
23
+ // You may want to clean this up later by importing these.
24
+ // setupNodeEvents(on, config) {
25
+ // return require('./cypress/plugins/index.js')(on, config);
26
+ // },
27
+ baseUrl: 'http://localhost:3000',
28
+ },
29
+
30
+ component: {
31
+ devServer: {
32
+ framework: 'react',
33
+ bundler: 'webpack',
34
+ },
35
+ },
36
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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,14 +21,15 @@
21
21
  "volto-slate"
22
22
  ],
23
23
  "dependencies": {
24
- "esri-loader": "3.5.0",
25
- "@plone/scripts": "*",
26
24
  "@eeacms/volto-embed": "^2.0.1",
25
+ "@plone/scripts": "*",
26
+ "esri-loader": "3.5.0",
27
27
  "volto-slate": "*"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@cypress/code-coverage": "^3.9.5",
31
- "babel-plugin-transform-class-properties": "^6.24.1"
31
+ "babel-plugin-transform-class-properties": "^6.24.1",
32
+ "cypress": "10.3.1"
32
33
  },
33
34
  "scripts": {
34
35
  "release": "release-it",
@@ -5,7 +5,15 @@ export const Schema = () => {
5
5
  {
6
6
  id: 'default',
7
7
  title: 'Default',
8
- fields: ['description', 'height', 'map_data'],
8
+ fields: [
9
+ 'description',
10
+ 'height',
11
+ 'map_data',
12
+ 'show_sources',
13
+ 'show_legend',
14
+ 'show_download',
15
+ 'show_viewer',
16
+ ],
9
17
  },
10
18
  ],
11
19
  properties: {
@@ -22,6 +30,22 @@ export const Schema = () => {
22
30
  description: 'Open the map customization interface',
23
31
  widget: 'map_edit_widget',
24
32
  },
33
+ show_sources: {
34
+ title: 'Show sources',
35
+ type: 'boolean',
36
+ },
37
+ show_legend: {
38
+ title: 'Show legend',
39
+ type: 'boolean',
40
+ },
41
+ show_download: {
42
+ title: 'Show download',
43
+ type: 'boolean',
44
+ },
45
+ show_viewer: {
46
+ title: 'Show web viewer',
47
+ type: 'boolean',
48
+ },
25
49
  },
26
50
  required: [],
27
51
  };
@@ -114,13 +114,6 @@ const Webmap = (props) => {
114
114
  return mapLayer;
115
115
  });
116
116
 
117
- // //this next layer will be used to filter country and intersect with existing layer
118
- // const allCountriesLayer = new FeatureLayer({
119
- // url:
120
- // 'https://trial.discomap.eea.europa.eu/arcgis/rest/services/CLMS/WorldCountries/MapServer/1',
121
- // definitionExpression: `(CNTR_ID = 'BG')`,
122
- // });
123
-
124
117
  const map = new Map({
125
118
  basemap: base_layer || 'hybrid',
126
119
  layers,
@@ -136,6 +129,21 @@ const Webmap = (props) => {
136
129
  },
137
130
  });
138
131
 
132
+ if (layers && layers[0] && zoom && zoom.centerOnExtent) {
133
+ view.whenLayerView(layers[0]).then(function (layerView) {
134
+ layerView.watch('updating', function (val) {
135
+ // view.goTo(response.extent);
136
+
137
+ if (!val && layerView) {
138
+ layerView.queryExtent().then(function (response) {
139
+ ///go to the extent of all the graphics in the layer view
140
+ if (response.extent) view.goTo(response.extent);
141
+ });
142
+ }
143
+ });
144
+ });
145
+ }
146
+
139
147
  if (zoom?.show_zoom) {
140
148
  const zoomPosition = zoom && zoom.position ? zoom.position : 'top-right';
141
149
  const zoomWidget = new Zoom({
@@ -9,28 +9,33 @@ import worldSVG from '@plone/volto/icons/world.svg';
9
9
  import downloadSVG from '@plone/volto/icons/download.svg';
10
10
 
11
11
  const ExtraViews = ({ data }) => {
12
- const { map_data = {}, description } = data;
13
- const { general = {} } = map_data;
12
+ const {
13
+ map_data = {},
14
+ description,
15
+ show_legend,
16
+ show_download,
17
+ show_viewer,
18
+ } = data;
14
19
  return (
15
20
  <>
16
- {general.show_legend && <LegendWidget data={map_data} />}
17
- {description && serializeNodes(description)}
18
- {(general.show_download || general.show_viewer) && (
21
+ {(show_download || show_viewer) && (
19
22
  <div
20
23
  style={{ display: 'flex', justifyContent: 'end', margin: '10px 0' }}
21
24
  >
22
- {general.show_download && (
25
+ {show_download && (
23
26
  <a
24
27
  target="_blank"
25
28
  rel="noreferrer"
26
29
  href={`${map_data.layers.map_layers[0].map_layer.map_service_url}?f=lyr&v=9.3`}
27
30
  >
28
31
  <Button size="tiny">
29
- <Icon name={downloadSVG} title="Download" size="25px" />
32
+ <Button.Content>
33
+ <Icon name={downloadSVG} title="Download" size="25px" />
34
+ </Button.Content>
30
35
  </Button>
31
36
  </a>
32
37
  )}
33
- {general.show_viewer && (
38
+ {show_viewer && (
34
39
  <a
35
40
  target="_blank"
36
41
  rel="noreferrer"
@@ -40,12 +45,16 @@ const ExtraViews = ({ data }) => {
40
45
  }
41
46
  >
42
47
  <Button size="tiny">
43
- <Icon name={worldSVG} title="Check Url" size="25px" />
48
+ <Button.Content>
49
+ <Icon name={worldSVG} title="View map" size="25px" />
50
+ </Button.Content>
44
51
  </Button>
45
52
  </a>
46
53
  )}
47
54
  </div>
48
55
  )}
56
+ {show_legend && <LegendWidget data={map_data} />}
57
+ {description && serializeNodes(description)}
49
58
  </>
50
59
  );
51
60
  };
@@ -4,6 +4,7 @@ import { Input, Select, Button, Grid } from 'semantic-ui-react';
4
4
 
5
5
  import checkSVG from '@plone/volto/icons/check.svg';
6
6
  import closeSVG from '@plone/volto/icons/clear.svg';
7
+ import aheadSVG from '@plone/volto/icons/ahead.svg';
7
8
 
8
9
  import { fetchArcgisData } from '../../utils';
9
10
 
@@ -97,30 +98,26 @@ const LayerSelectWidget = (props) => {
97
98
  <Input
98
99
  type="text"
99
100
  onChange={(e, { value }) => setServiceUrl(value)}
100
- style={{ width: '100%' }}
101
+ style={{ width: '70%' }}
101
102
  value={serviceUrl}
102
- />
103
- <Grid.Row>
103
+ action
104
+ actionPosition="right"
105
+ >
106
+ <input />
104
107
  <Button
105
- style={{
106
- margin: '10px 0',
107
- display: 'flex',
108
- alignItems: 'center',
109
- }}
108
+ type="submit"
109
+ size="tiny"
110
+ compact
110
111
  color={checkColor}
111
112
  onClick={handleServiceUrlCheck}
112
113
  >
113
- <p style={{ fontSize: '14px', margin: '0', marginRight: '5px' }}>
114
- Check Url
115
- </p>
116
114
  <Icon
117
115
  name={serviceUrlError ? closeSVG : checkSVG}
118
- style={{ marginLeft: '5px' }}
119
116
  title="Check Url"
120
117
  size="17px"
121
118
  />
122
119
  </Button>
123
- </Grid.Row>
120
+ </Input>
124
121
  </Grid.Row>
125
122
  <h4>Layer</h4>
126
123
  <Grid.Row>
@@ -137,26 +134,28 @@ const LayerSelectWidget = (props) => {
137
134
  <Input
138
135
  type="text"
139
136
  onChange={(e, { value }) => setLayerQuery(value)}
140
- style={{ width: '100%' }}
137
+ style={{ width: '70%' }}
141
138
  value={layerQuery}
142
- />
143
- <Button
144
- style={{
145
- margin: '10px 0',
146
- display: 'flex',
147
- alignItems: 'center',
148
- }}
149
- color={checkColor}
150
- onClick={handleQueryLayer}
139
+ action
140
+ actionPosition="right"
151
141
  >
152
- <p style={{ fontSize: '14px', margin: '0', marginRight: '5px' }}>
153
- Query Layer
154
- </p>
155
- </Button>
142
+ <input />
143
+ <Button
144
+ type="submit"
145
+ size="tiny"
146
+ compact
147
+ color={'green'}
148
+ onClick={handleQueryLayer}
149
+ >
150
+ <Icon name={aheadSVG} title="Check Url" size="17px" />
151
+ </Button>
152
+ </Input>
153
+ </Grid.Row>
154
+ <Grid.Row>
155
+ <p style={{ fontSize: '12px', fontWeight: 'bold' }}>
156
+ Available Fields:
157
+ </p>
156
158
  </Grid.Row>
157
- <p style={{ fontSize: '12px', fontWeight: 'bold' }}>
158
- Available Fields:
159
- </p>
160
159
  {fields &&
161
160
  fields.length > 0 &&
162
161
  fields.map((field, id) => (
@@ -8,7 +8,7 @@ const LayerLegend = ({ data }) => {
8
8
  {data.length > 0 &&
9
9
  data.map((item, i) => {
10
10
  return (
11
- <span style={{ display: 'flex', alignItems: 'center' }}>
11
+ <span key={i} style={{ display: 'flex', alignItems: 'center' }}>
12
12
  <img alt="alt" src={`data:image/png;base64,${item.imageData}`} />
13
13
  <span style={{ fontSize: '13px' }}>{item.label}</span>
14
14
  </span>
@@ -49,9 +49,12 @@ const LegendWidget = (props) => {
49
49
  <Grid.Column>
50
50
  <h3>Legend:</h3>
51
51
  {legendLayers.length > 0 &&
52
- legendLayers.map((layer, index) => {
52
+ legendLayers.map((layer, i) => {
53
53
  return (
54
- <div style={{ display: 'flex', flexDirection: 'column' }}>
54
+ <div
55
+ key={i}
56
+ style={{ display: 'flex', flexDirection: 'column' }}
57
+ >
55
58
  <h5 style={{ marginTop: '10px', marginBottom: '5px' }}>
56
59
  {layer?.layerName}
57
60
  </h5>
@@ -3,7 +3,7 @@ import { Modal, Button, Grid } from 'semantic-ui-react';
3
3
  import Webmap from '../Webmap';
4
4
  import { FormFieldWrapper, InlineForm } from '@plone/volto/components';
5
5
 
6
- import { panelsSchema } from './panelsSchema';
6
+ import PanelsSchema from './panelsSchema';
7
7
 
8
8
  const MapEditorWidget = (props) => {
9
9
  const [open, setOpen] = React.useState(false);
@@ -26,6 +26,8 @@ const MapEditorWidget = (props) => {
26
26
  setIntValue(fieldVal);
27
27
  };
28
28
 
29
+ let schema = PanelsSchema({ data: dataForm });
30
+
29
31
  return (
30
32
  <FormFieldWrapper {...props}>
31
33
  <Modal
@@ -46,8 +48,8 @@ const MapEditorWidget = (props) => {
46
48
  <Grid.Column width={4}>
47
49
  <InlineForm
48
50
  block={block}
49
- title={panelsSchema.title}
50
- schema={panelsSchema}
51
+ title={schema.title}
52
+ schema={schema}
51
53
  onChangeField={(id, value) => {
52
54
  handleChangeField(id, value);
53
55
  }}
@@ -24,7 +24,7 @@ export const ObjectTypesWidget = (props) => {
24
24
  ),
25
25
  render: () => {
26
26
  return (
27
- <Tab.Pane>
27
+ <Tab.Pane style={{ padding: '0' }}>
28
28
  <ObjectWidget
29
29
  schema={schema}
30
30
  id={id}
@@ -45,7 +45,7 @@ export const ObjectTypesWidget = (props) => {
45
45
  menu={{ fluid: true, vertical: true, tabular: true }}
46
46
  panes={schemas.map(createTab)}
47
47
  activeIndex={activeTab}
48
- grid={{ paneWidth: 8, tabWidth: 4 }}
48
+ grid={{ paneWidth: 9, tabWidth: 3 }}
49
49
  />
50
50
  );
51
51
  };
@@ -55,6 +55,7 @@ const MapLayersSchema = {
55
55
  },
56
56
  required: [],
57
57
  };
58
+
58
59
  const PrintSchema = {
59
60
  title: 'Print',
60
61
  fieldsets: [
@@ -81,110 +82,94 @@ const PrintSchema = {
81
82
  required: [],
82
83
  };
83
84
 
84
- const ZoomSchema = {
85
- title: 'Zoom',
86
- fieldsets: [
87
- {
88
- id: 'default',
89
- title: 'Zoom',
90
- fields: ['show_zoom', 'position', 'zoom_level', 'long', 'lat'],
91
- },
92
- ],
93
- properties: {
94
- show_zoom: {
95
- title: 'Show zoom',
96
- type: 'boolean',
97
- },
98
- position: {
99
- title: 'Zoom position',
100
- choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
101
- (n) => {
102
- return [n, n];
103
- },
104
- ),
105
- },
106
- zoom_level: {
107
- title: 'Zoom level',
108
- type: 'number',
109
- },
110
- long: {
111
- title: 'Longitude',
112
- type: 'number',
113
- },
114
- lat: {
115
- title: 'Latitude',
116
- type: 'number',
117
- },
118
- },
119
- required: [],
120
- };
85
+ const ZoomSchema = ({ data = {} }) => {
86
+ const centerOnExtent = data?.map_data?.zoom?.centerOnExtent;
121
87
 
122
- const GeneralSchema = {
123
- title: 'General',
124
- fieldsets: [
125
- {
126
- id: 'default',
127
- title: 'General',
128
- fields: ['show_sources', 'show_legend', 'show_download', 'show_viewer'],
129
- },
130
- ],
131
- properties: {
132
- show_sources: {
133
- title: 'Show sources',
134
- type: 'boolean',
135
- },
136
- show_legend: {
137
- title: 'Show legend',
138
- type: 'boolean',
139
- },
140
- show_download: {
141
- title: 'Show download',
142
- type: 'boolean',
143
- },
144
- show_viewer: {
145
- title: 'Show web viewer',
146
- type: 'boolean',
147
- },
148
- },
149
- required: [],
88
+ return {
89
+ title: 'Zoom',
90
+ fieldsets: [
91
+ {
92
+ id: 'default',
93
+ title: 'Zoom',
94
+ fields: [
95
+ 'show_zoom',
96
+ 'centerOnExtent',
97
+ 'position',
98
+ ...(!centerOnExtent ? ['zoom_level', 'long', 'lat'] : []),
99
+ ],
100
+ },
101
+ ],
102
+ properties: {
103
+ show_zoom: {
104
+ title: 'Show zoom',
105
+ type: 'boolean',
106
+ },
107
+ centerOnExtent: {
108
+ title: 'Center on extent',
109
+ type: 'boolean',
110
+ description: 'This will override latitude/longitude/zoom level',
111
+ },
112
+ position: {
113
+ title: 'Zoom position',
114
+ choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
115
+ (n) => {
116
+ return [n, n];
117
+ },
118
+ ),
119
+ },
120
+ zoom_level: {
121
+ title: 'Zoom level',
122
+ type: 'number',
123
+ },
124
+ long: {
125
+ title: 'Longitude',
126
+ type: 'number',
127
+ },
128
+ lat: {
129
+ title: 'Latitude',
130
+ type: 'number',
131
+ },
132
+ },
133
+ required: [],
134
+ };
150
135
  };
151
136
 
152
- export const panelsSchema = {
153
- title: 'Map Editor',
154
- fieldsets: [
155
- {
156
- id: 'default',
157
- title: 'Map Editor Sections',
158
- fields: ['map_data'],
159
- },
160
- ],
161
- properties: {
162
- map_data: {
163
- title: 'Panels',
164
- widget: 'object_types_widget',
165
- schemas: [
166
- {
167
- id: 'general',
168
- schema: GeneralSchema,
169
- },
170
- {
171
- id: 'base',
172
- schema: BaseLayerSchema,
173
- },
174
- {
175
- id: 'layers',
176
- schema: MapLayersSchema,
177
- },
178
- {
179
- id: 'print',
180
- schema: PrintSchema,
181
- },
182
- {
183
- id: 'zoom',
184
- schema: ZoomSchema,
185
- },
186
- ],
187
- },
188
- },
189
- required: [],
137
+ export default ({ data = {} }) => {
138
+ const zoomSchema = ZoomSchema({ data });
139
+
140
+ return {
141
+ title: 'Map Editor',
142
+ fieldsets: [
143
+ {
144
+ id: 'default',
145
+ title: 'Map Editor Sections',
146
+ fields: ['map_data'],
147
+ },
148
+ ],
149
+ properties: {
150
+ map_data: {
151
+ title: 'Panels',
152
+ widget: 'object_types_widget',
153
+ schemas: [
154
+ {
155
+ id: 'base',
156
+ schema: BaseLayerSchema,
157
+ },
158
+ {
159
+ id: 'layers',
160
+ schema: MapLayersSchema,
161
+ },
162
+ {
163
+ id: 'print',
164
+ schema: PrintSchema,
165
+ },
166
+ {
167
+ id: 'zoom',
168
+ schema: zoomSchema,
169
+ },
170
+ ],
171
+ },
172
+ },
173
+ required: [],
174
+ };
190
175
  };
package/cypress.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "baseUrl": "http://localhost:3000",
3
- "viewportWidth": 1280,
4
- "defaultCommandTimeout": 8888,
5
- "chromeWebSecurity": false,
6
- "reporter": "junit",
7
- "video": true,
8
- "retries": {
9
- "runMode": 8,
10
- "openMode": 0
11
- },
12
- "reporterOptions": {
13
- "mochaFile": "cypress/reports/cypress-[hash].xml",
14
- "jenkinsMode": true,
15
- "toConsole": true
16
- }
17
- }