@eeacms/volto-eea-map 2.0.6 → 3.0.0

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,6 +4,46 @@ 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
+ ### [3.0.0](https://github.com/eea/volto-eea-map/compare/2.0.7...3.0.0) - 23 November 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - update [Miu Razvan - [`005b994`](https://github.com/eea/volto-eea-map/commit/005b9949a93a9101cf5b88054523e05d03deae05)]
12
+ - clean up [Miu Razvan - [`4144747`](https://github.com/eea/volto-eea-map/commit/4144747b84d1fb0e51614c7a963d750c9b67100d)]
13
+ - clean up [Miu Razvan - [`80c37f9`](https://github.com/eea/volto-eea-map/commit/80c37f9cb8b54e79caf5d147e452a5e88168a218)]
14
+ - bump version + remove uneeded code [Miu Razvan - [`adb8733`](https://github.com/eea/volto-eea-map/commit/adb8733fa4ce3d42a9d16cb7ad19518d49949da2)]
15
+ - update [Miu Razvan - [`6723242`](https://github.com/eea/volto-eea-map/commit/6723242a8507a29194cfc9650ae214d2abca74ad)]
16
+ - fix sonorqube [Dobricean Ioan Dorian - [`02b4406`](https://github.com/eea/volto-eea-map/commit/02b44067598c6cedcfc28c3b7667e4cb23addfc5)]
17
+ - fix prettier [Dobricean Ioan Dorian - [`78fc2ba`](https://github.com/eea/volto-eea-map/commit/78fc2baa2f5264ca1bba61b70bc0bdc5b2788e67)]
18
+ - Fix Sonorqube [dobri1408 - [`e04011a`](https://github.com/eea/volto-eea-map/commit/e04011aa811422f865d0bbb1e66af558a4310e77)]
19
+ - adapt embedeeamap to use serialized data [Dobricean Ioan Dorian - [`005965c`](https://github.com/eea/volto-eea-map/commit/005965c6793a9a9977fef52c08ba9a3173eec348)]
20
+ ### [2.0.7](https://github.com/eea/volto-eea-map/compare/2.0.6...2.0.7) - 10 November 2023
21
+
22
+ #### :rocket: New Features
23
+
24
+ - feat: mobile toolbar [Miu Razvan - [`0c8d2fa`](https://github.com/eea/volto-eea-map/commit/0c8d2fa66d175f97f5bed3fbb26de5841fa71905)]
25
+ - feat: use toolbar [Miu Razvan - [`d1c76bb`](https://github.com/eea/volto-eea-map/commit/d1c76bba44c7bf357276b908b00224a4d7837eae)]
26
+ - feat: share option, design improvements [dana-cfc4 - [`33a0d5e`](https://github.com/eea/volto-eea-map/commit/33a0d5e4c386b8507cfba4a59ea73131256e25a8)]
27
+
28
+ #### :bug: Bug Fixes
29
+
30
+ - fix: same background colour for popups [dana-cfc4 - [`61e465f`](https://github.com/eea/volto-eea-map/commit/61e465f36a272ee76311665d1a249c070524741d)]
31
+ - fix: volto version 16 [dana-cfc4 - [`abe9ac2`](https://github.com/eea/volto-eea-map/commit/abe9ac29e3657ff8773001d8a9e9b03f72c026a4)]
32
+ - fix: display figure note [dana-cfc4 - [`7f3d58f`](https://github.com/eea/volto-eea-map/commit/7f3d58f9828b9a0fd43075aed2c76559a16bd8fe)]
33
+
34
+ #### :house: Internal changes
35
+
36
+ - chore: husky, lint-staged use fixed versions [valentinab25 - [`0ee38a7`](https://github.com/eea/volto-eea-map/commit/0ee38a7bee84694a5e0230e2d17083fbc071f0c8)]
37
+ - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`8efeb44`](https://github.com/eea/volto-eea-map/commit/8efeb4423da70e421a88cabdeb559eb3613fb96e)]
38
+ - chore: display legend for content type item, fix case when no note is set [dana-cfc4 - [`ae630a8`](https://github.com/eea/volto-eea-map/commit/ae630a88cffa2a8ef60e0bbfead392508b015497)]
39
+ - chore: display figureNote [dana-cfc4 - [`19fa10c`](https://github.com/eea/volto-eea-map/commit/19fa10c92a96d8362af5fbe460085405c4bad517)]
40
+ - chore: add toggle for more info -refs#257682 [dana-cfc4 - [`65d6b7b`](https://github.com/eea/volto-eea-map/commit/65d6b7ba7ae0a2aaf513c8ced0d2bb977e43ef1b)]
41
+ - chore: add figure note and more info extra views, display legend for content type item -refs#257682 [dana-cfc4 - [`720ab02`](https://github.com/eea/volto-eea-map/commit/720ab022cd99947d71c5b598a1637b12255d17af)]
42
+
43
+ #### :hammer_and_wrench: Others
44
+
45
+ - Refs #260203: make background_image required [laszlocseh - [`baa5c4f`](https://github.com/eea/volto-eea-map/commit/baa5c4fa2fe618af51df12d48b4512ecafc357a8)]
46
+ - use toolbar from volto-embed [Miu Razvan - [`29b73fb`](https://github.com/eea/volto-eea-map/commit/29b73fb8378ca56b3634bf1f7d57ce69a242b18e)]
7
47
  ### [2.0.6](https://github.com/eea/volto-eea-map/compare/2.0.5...2.0.6) - 29 September 2023
8
48
 
9
49
  #### :house: Internal changes
@@ -19,7 +59,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
19
59
 
20
60
  - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`4c6d141`](https://github.com/eea/volto-eea-map/commit/4c6d1413b67ffc3fe27a7d09dcc99ef98867cec9)]
21
61
  - test: Fix package.json scripts to use makefile [Alin Voinea - [`1cd6751`](https://github.com/eea/volto-eea-map/commit/1cd675118165d8631c41d35c00a8c902c7edd803)]
22
- - test: Fix eslint and yarn i18n [Alin Voinea - [`0184641`](https://github.com/eea/volto-eea-map/commit/018464116ba5b86b2c1e0a4ebc9b2fd95b772b66)]
23
62
  - i18n: Add en [Alin Voinea - [`1d29304`](https://github.com/eea/volto-eea-map/commit/1d293049a21e138fa933cd5ed9a04cceac1a5cff)]
24
63
  ### [2.0.5](https://github.com/eea/volto-eea-map/compare/2.0.4...2.0.5) - 23 August 2023
25
64
 
@@ -76,14 +115,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
76
115
  #### :hammer_and_wrench: Others
77
116
 
78
117
  - Release 2.0.0 [Alin Voinea - [`7be280d`](https://github.com/eea/volto-eea-map/commit/7be280d4809186e663f422687aca3c33dd732904)]
79
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`ba6ed22`](https://github.com/eea/volto-eea-map/commit/ba6ed22118406db979457384d4739cced2096137)]
80
118
  ### [1.0.2](https://github.com/eea/volto-eea-map/compare/1.0.1...1.0.2) - 21 July 2023
81
119
 
82
120
  #### :hammer_and_wrench: Others
83
121
 
84
122
  - Allow blocks in content type [Tiberiu Ichim - [`2ac09a6`](https://github.com/eea/volto-eea-map/commit/2ac09a613aba07f6cbaf42c386660f2d7d09bd13)]
85
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`403b4c0`](https://github.com/eea/volto-eea-map/commit/403b4c009e5aaded58203bc292ba3baa4631488b)]
86
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`aedb654`](https://github.com/eea/volto-eea-map/commit/aedb6544fd45b147a3385425aba46ffba108f5ca)]
87
123
  ### [1.0.1](https://github.com/eea/volto-eea-map/compare/1.0.0...1.0.1) - 22 June 2023
88
124
 
89
125
  #### :rocket: New Features
@@ -144,7 +180,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
144
180
 
145
181
  - chore: clear unused #254131 [andreiggr - [`ccec2ea`](https://github.com/eea/volto-eea-map/commit/ccec2eaab173c905cd4ea0190a9c6cfd630250f9)]
146
182
  - chore: clear block style #254131 [andreiggr - [`af500bc`](https://github.com/eea/volto-eea-map/commit/af500bc10a5f280eff0335f45bae1596d66a7e6b)]
147
- - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`76b29e5`](https://github.com/eea/volto-eea-map/commit/76b29e510f5156590723831a524bc39dfba6deba)]
148
183
 
149
184
  #### :hammer_and_wrench: Others
150
185
 
@@ -154,7 +189,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
154
189
  - * versions [andreiggr - [`6d9ff2b`](https://github.com/eea/volto-eea-map/commit/6d9ff2b26a236b6445678e3d84698d1c3c0826f4)]
155
190
  - add razzle-plugin-scss dep [andreiggr - [`d74cee5`](https://github.com/eea/volto-eea-map/commit/d74cee51d30c866afe55730e5b25e0bf11d2caea)]
156
191
  - volto-object-widget [andreiggr - [`18d0ed7`](https://github.com/eea/volto-eea-map/commit/18d0ed72c1ba7b0f7159a0eefc09ccea9acee5cb)]
157
- - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`5911d01`](https://github.com/eea/volto-eea-map/commit/5911d01f7f3bc79a2c834fab75a9a4ac05d2d042)]
158
192
  ### [0.1.32](https://github.com/eea/volto-eea-map/compare/0.1.31...0.1.32) - 20 February 2023
159
193
 
160
194
  #### :hammer_and_wrench: Others
@@ -162,7 +196,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
162
196
  - remove console.log [tedw87 - [`3aeb3e8`](https://github.com/eea/volto-eea-map/commit/3aeb3e8ec5474387f3cd22eb9b387c6681e17120)]
163
197
  - refactor code [tedw87 - [`6d7830e`](https://github.com/eea/volto-eea-map/commit/6d7830eb934f56c255eea5642bdefba30d892946)]
164
198
  - add Blossom basemap layer [tedw87 - [`5226ee2`](https://github.com/eea/volto-eea-map/commit/5226ee218df3401cf467afbc7a4d720dc30719e1)]
165
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`1dad5c6`](https://github.com/eea/volto-eea-map/commit/1dad5c6617096ff85223165a6dd2b1d5d7deea6a)]
166
199
  ### [0.1.31](https://github.com/eea/volto-eea-map/compare/0.1.30...0.1.31) - 11 November 2022
167
200
 
168
201
  #### :hammer_and_wrench: Others
package/README.md CHANGED
@@ -18,24 +18,30 @@
18
18
 
19
19
  # Configuration
20
20
 
21
- This addon contains the EEA Embed Map Block & EEA Map Block. It's configured to work with the map visualization content type and give more access to ArcGIS maps. See available maps here https://discomap.eea.europa.eu/
21
+ This addon contains the EEA Embed Map Block & EEA Map Block. It's configured to work with the map visualization content type and give more access to ArcGIS maps. See available maps here https://discomap.eea.europa.eu/
22
22
 
23
- # Enable data queries auto-import
23
+ # Enable data queries auto-import
24
24
 
25
- To enable automatic import of queries from the content-type, "Parameters for data connections" should be checked as behavior on the content-type that uses the map.
25
+ To enable automatic import of queries from the content-type, "Parameters for data connections" should be checked as behavior on the content-type that uses the map.
26
26
 
27
27
  controlpanel/dexterity-types/{content-type-id}
28
28
 
29
29
  # Enable Sources
30
30
 
31
- Sources (Data provenance) should be set on the visualization. To enable this, "EEA Core Metadata" should be checked as behavior on the visualization content-type.
31
+ Sources (Data provenance) should be set on the visualization. To enable this, "EEA Core Metadata" should be checked as behavior on the visualization content-type.
32
32
 
33
33
  controlpanel/dexterity-types/map_visualization
34
-
34
+
35
35
  After this, sources can be added from the visualization edit interface. "Data Provenance" tab => "Add source"
36
36
 
37
+ [EEA MAP](https://raw.githubusercontent.com/eea/volto-eea-map/master/docs/volto-eea-map.gif)
38
+
37
39
  ## Getting started
38
40
 
41
+ ### Upgrade
42
+
43
+ #### 3.0.0 -> requires >= eea.api.dataconnector@7.0
44
+
39
45
  ### Try volto-eea-map with Docker
40
46
 
41
47
  git clone https://github.com/eea/volto-eea-map.git
@@ -55,25 +61,25 @@ Go to http://localhost:3000
55
61
 
56
62
  1. Start Volto frontend
57
63
 
58
- * If you already have a volto project, just update `package.json`:
64
+ - If you already have a volto project, just update `package.json`:
59
65
 
60
- ```JSON
61
- "addons": [
62
- "@eeacms/volto-eea-map"
63
- ],
66
+ ```JSON
67
+ "addons": [
68
+ "@eeacms/volto-eea-map"
69
+ ],
64
70
 
65
- "dependencies": {
66
- "@eeacms/volto-eea-map": "*"
67
- }
68
- ```
71
+ "dependencies": {
72
+ "@eeacms/volto-eea-map": "*"
73
+ }
74
+ ```
69
75
 
70
- * If not, create one:
76
+ - If not, create one:
71
77
 
72
- ```
73
- npm install -g yo @plone/generator-volto
74
- yo @plone/volto my-volto-project --canary --addon @eeacms/volto-eea-map
75
- cd my-volto-project
76
- ```
78
+ ```
79
+ npm install -g yo @plone/generator-volto
80
+ yo @plone/volto my-volto-project --canary --addon @eeacms/volto-eea-map
81
+ cd my-volto-project
82
+ ```
77
83
 
78
84
  1. Install new add-ons and restart Volto:
79
85
 
package/RELEASE.md CHANGED
@@ -20,9 +20,9 @@ You need to first install the [release-it](https://github.com/release-it/release
20
20
  ```
21
21
  npm install -g release-it
22
22
  ```
23
-
23
+
24
24
  Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.
25
-
25
+
26
26
  Release-it is a tool that automates 4 important steps in the release process:
27
27
 
28
28
  1. Version increase in `package.json` ( increased from the current version in `package.json`)
@@ -30,45 +30,45 @@ Release-it is a tool that automates 4 important steps in the release process:
30
30
  3. GitHub release on the commit with the changelog and package.json modification on the develop branch
31
31
  4. NPM release ( by default it's disabled, but can be enabled in the configuration file )
32
32
 
33
- To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
33
+ To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
34
34
 
35
35
  ```
36
36
  export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
37
37
  ```
38
-
38
+
39
39
  To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :
40
-
40
+
41
41
  ```
42
42
  echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
43
43
  ```
44
44
 
45
45
  #### Using release-it tool
46
-
46
+
47
47
  There are 3 yarn scripts that can be run to do the release
48
48
 
49
49
  ##### yarn release-beta
50
50
 
51
- Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
51
+ Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
52
52
 
53
53
  ```
54
- ? Select increment (next version):
55
- ❯ prepatch (0.1.1-beta.0)
56
- preminor (0.2.0-beta.0)
57
- premajor (1.0.0-beta.0)
58
- Other, please specify...
54
+ ? Select increment (next version):
55
+ ❯ prepatch (0.1.1-beta.0)
56
+ preminor (0.2.0-beta.0)
57
+ premajor (1.0.0-beta.0)
58
+ Other, please specify...
59
59
  ```
60
60
 
61
61
  ##### yarn release-major-beta
62
62
 
63
63
  Same as `yarn release-beta`, but with premajor version pre-selected.
64
-
64
+
65
65
  ##### yarn release
66
66
 
67
67
  Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.
68
68
 
69
69
  #### Important notes
70
70
 
71
- > Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
71
+ > Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
72
72
 
73
73
  > Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).
74
74
 
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 5000,
5
+ defaultCommandTimeout: 8888,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
- video: true,
8
+ video: false,
9
9
  retries: {
10
- runMode: 1,
10
+ runMode: 2,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "2.0.6",
3
+ "version": "3.0.0",
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",
@@ -36,8 +36,8 @@
36
36
  "babel-plugin-transform-class-properties": "^6.24.1",
37
37
  "cypress": "10.3.1",
38
38
  "cypress-fail-fast": "^5.0.1",
39
- "husky": "*",
40
- "lint-staged": "*",
39
+ "husky": "^8.0.3",
40
+ "lint-staged": "^14.0.1",
41
41
  "md5": "^2.3.0"
42
42
  },
43
43
  "lint-staged": {
@@ -81,4 +81,4 @@
81
81
  "cypress:open": "make cypress-open",
82
82
  "prepare": "husky install"
83
83
  }
84
- }
84
+ }
@@ -1,87 +1,84 @@
1
- import React from 'react';
2
- import { SidebarPortal } from '@plone/volto/components';
3
-
1
+ import React, { useEffect, useMemo } from 'react';
2
+ import { Message } from 'semantic-ui-react';
4
3
  import { connect } from 'react-redux';
5
4
  import { compose } from 'redux';
6
5
 
6
+ import { SidebarPortal } from '@plone/volto/components';
7
+ import { getContent } from '@plone/volto/actions';
8
+ import { flattenToAppURL } from '@plone/volto/helpers';
7
9
  import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
8
10
  import Webmap from '@eeacms/volto-eea-map/components/Webmap';
9
11
  import ExtraViews from '@eeacms/volto-eea-map/components/ExtraViews';
10
12
 
11
- import { expandToBackendURL } from '@plone/volto/helpers';
12
-
13
13
  import { Schema } from './Schema';
14
14
  import { applyQueriesToMapLayers } from '@eeacms/volto-eea-map/utils';
15
15
 
16
- import { getVisualization } from '@eeacms/volto-eea-map/actions';
16
+ import { getMapVisualizationData } from './helpers';
17
17
 
18
18
  const Edit = (props) => {
19
- const { block, onChangeBlock, selected, data_provenance = {} } = props;
19
+ const { id, block, onChangeBlock, selected, data, getContent } = props;
20
+ const {
21
+ data_query_params,
22
+ enable_queries,
23
+ show_legend = true,
24
+ show_note = true,
25
+ show_sources = true,
26
+ show_more_info = true,
27
+ show_share = true,
28
+ dataprotection = { enabled: true },
29
+ height = '',
30
+ } = data;
20
31
  const schema = Schema(props);
21
32
  const [mapData, setMapData] = React.useState('');
22
- const data = React.useMemo(() => props.data, [props.data]);
23
- const { height = '' } = data;
24
33
 
25
- React.useEffect(() => {
26
- if (!Object.hasOwn(data, 'show_legend')) {
27
- onChangeBlock(block, {
28
- ...data,
29
- show_legend: true,
30
- });
31
- }
32
- if (!Object.hasOwn(data, 'show_sources')) {
33
- onChangeBlock(block, {
34
- ...data,
35
- show_sources: true,
36
- });
37
- }
38
- if (!Object.hasOwn(data, 'dataprotection')) {
39
- onChangeBlock(block, {
40
- ...data,
41
- dataprotection: { enabled: true },
42
- });
43
- }
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
- }, [data.show_legend, data.show_sources, data.dataprotection]);
34
+ const vis_url = useMemo(() => flattenToAppURL(data.vis_url), [data.vis_url]);
46
35
 
47
- React.useEffect(() => {
48
- if (props.data.vis_url) {
49
- props.getVisualization(expandToBackendURL(props.data.vis_url));
36
+ const map_visualization_data = useMemo(() => getMapVisualizationData(props), [
37
+ props,
38
+ ]);
39
+
40
+ useEffect(() => {
41
+ const mapVisId = flattenToAppURL(map_visualization_data['@id'] || '');
42
+ if (vis_url && vis_url !== mapVisId) {
43
+ getContent(vis_url, null, id);
50
44
  }
51
- if (!props.data.vis_url) {
45
+ if (!vis_url) {
52
46
  setMapData('');
53
47
  }
54
- // eslint-disable-next-line react-hooks/exhaustive-deps
55
- }, [props.data.vis_url]);
48
+ }, [id, getContent, vis_url, map_visualization_data]);
56
49
 
57
50
  React.useEffect(() => {
58
51
  const updatedMapData = applyQueriesToMapLayers(
59
- props.map_visualization,
60
- props.data.data_query_params,
61
- props.data.enable_queries,
52
+ map_visualization_data,
53
+ data_query_params,
54
+ enable_queries,
62
55
  );
63
56
  setMapData(updatedMapData);
64
-
65
- // eslint-disable-next-line react-hooks/exhaustive-deps
66
- }, [props.map_visualization, props.data]);
57
+ }, [map_visualization_data, data_query_params, enable_queries]);
67
58
 
68
59
  return (
69
60
  <>
70
- {mapData && (
61
+ {!vis_url && (
62
+ <Message>Please select a visualization from block editor.</Message>
63
+ )}
64
+
65
+ {!!vis_url && mapData && (
71
66
  <div>
72
67
  <Webmap data={mapData} height={height} isEdit={true} />
73
68
  <ExtraViews
74
69
  data={{
75
70
  ...data,
76
- data_provenance,
77
- map_data: props.map_visualization,
71
+ show_legend,
72
+ show_note,
73
+ show_sources,
74
+ show_more_info,
75
+ show_share,
76
+ dataprotection,
77
+ map_visualization_data,
78
78
  }}
79
79
  />
80
80
  </div>
81
81
  )}
82
- {!mapData && (
83
- <p>No map view to show. Set visualization in block configuration.</p>
84
- )}
85
82
  <SidebarPortal selected={selected}>
86
83
  <BlockDataForm
87
84
  block={block}
@@ -103,18 +100,11 @@ const Edit = (props) => {
103
100
  export default compose(
104
101
  connect(
105
102
  (state, props) => ({
103
+ mapContent: state.content.subrequests?.[props.id]?.data,
106
104
  data_query: state.content.data.data_query,
107
- map_visualization: props.data.vis_url
108
- ? state.map_visualizations?.data[expandToBackendURL(props.data.vis_url)]
109
- ?.data
110
- : '',
111
- data_provenance: props.data.vis_url
112
- ? state.map_visualizations?.data[expandToBackendURL(props.data.vis_url)]
113
- ?.data_provenance
114
- : '',
115
105
  }),
116
106
  {
117
- getVisualization,
107
+ getContent,
118
108
  },
119
109
  ),
120
110
  )(Edit);
@@ -60,10 +60,11 @@ const ProtectionSchema = () => ({
60
60
  background_image: {
61
61
  title: 'Static map preview image',
62
62
  widget: 'file',
63
+ required: true,
63
64
  },
64
65
  },
65
66
 
66
- required: [],
67
+ required: ['background_image'],
67
68
  });
68
69
 
69
70
  export const Schema = (props) => {
@@ -83,14 +84,26 @@ export const Schema = (props) => {
83
84
  'vis_url',
84
85
  'description',
85
86
  'height',
87
+ 'enable_queries',
88
+ ...(props.data.enable_queries ? ['data_query_params'] : []),
89
+ ],
90
+ },
91
+ {
92
+ id: 'toolbar',
93
+ title: 'Toolbar',
94
+ fields: [
86
95
  'show_legend',
87
96
  'show_viewer',
97
+ 'show_note',
88
98
  'show_sources',
89
- 'enable_queries',
90
- ...(props.data.enable_queries ? ['data_query_params'] : []),
91
- 'dataprotection',
99
+ 'show_more_info',
100
+ 'show_share',
92
101
  ],
93
102
  },
103
+ {
104
+ fields: ['dataprotection'],
105
+ title: 'Data Protection',
106
+ },
94
107
  ],
95
108
  properties: {
96
109
  vis_url: {
@@ -107,10 +120,26 @@ export const Schema = (props) => {
107
120
  title: 'Description',
108
121
  widget: 'slate',
109
122
  },
123
+ show_note: {
124
+ title: 'Show note',
125
+ type: 'boolean',
126
+ defaultValue: true,
127
+ },
110
128
  show_sources: {
111
129
  title: 'Show sources',
112
130
  description: 'Will show sources set in this page Data provenance',
113
131
  type: 'boolean',
132
+ defaultValue: true,
133
+ },
134
+ show_more_info: {
135
+ title: 'Show more info',
136
+ type: 'boolean',
137
+ defaultValue: true,
138
+ },
139
+ show_share: {
140
+ title: 'Show share button',
141
+ type: 'boolean',
142
+ defaultValue: true,
114
143
  },
115
144
  show_legend: {
116
145
  title: 'Show legend',
@@ -1,61 +1,49 @@
1
- import React from 'react';
2
-
3
- import { connect } from 'react-redux';
4
- import { compose } from 'redux';
5
-
6
- import { expandToBackendURL } from '@plone/volto/helpers';
7
-
1
+ import React, { useMemo } from 'react';
8
2
  import { PrivacyProtection } from '@eeacms/volto-embed';
9
-
10
3
  import Webmap from '@eeacms/volto-eea-map/components/Webmap';
11
4
  import ExtraViews from '@eeacms/volto-eea-map/components/ExtraViews';
12
5
  import { applyQueriesToMapLayers } from '@eeacms/volto-eea-map/utils';
13
- import { getVisualization } from '@eeacms/volto-eea-map/actions';
6
+
7
+ import { getMapVisualizationData } from './helpers';
14
8
 
15
9
  const View = (props) => {
16
- const { data, data_provenance = {} } = props || {};
17
- const { height = '' } = data;
10
+ const { data_query_params, enable_queries, height = '' } = props.data;
18
11
 
19
- const [mapData, setMapData] = React.useState('');
12
+ const map_visualization_data = useMemo(() => getMapVisualizationData(props), [
13
+ props,
14
+ ]);
20
15
 
21
- React.useEffect(() => {
22
- if (props.data.vis_url) {
23
- props.getVisualization(expandToBackendURL(props.data.vis_url));
24
- }
25
- if (!props.data.vis_url) {
26
- setMapData('');
27
- }
28
- // eslint-disable-next-line react-hooks/exhaustive-deps
29
- }, [props.data.vis_url]);
16
+ const { data_provenance = {}, figure_note = [] } = map_visualization_data;
17
+ const [mapData, setMapData] = React.useState('');
30
18
 
31
19
  React.useEffect(() => {
32
20
  const updatedMapData = applyQueriesToMapLayers(
33
- props.map_visualization,
34
- props.data.data_query_params,
35
- props.data.enable_queries,
21
+ map_visualization_data,
22
+ data_query_params,
23
+ enable_queries,
36
24
  );
37
-
38
25
  setMapData(updatedMapData);
39
- // eslint-disable-next-line react-hooks/exhaustive-deps
40
- }, [
41
- props.map_visualization,
42
- props.data.data_query_params,
43
- props.data.enable_queries,
44
- ]);
26
+ }, [map_visualization_data, data_query_params, enable_queries]);
45
27
 
46
28
  return (
47
- <PrivacyProtection data={data} {...props}>
48
- {mapData && (
49
- <div>
29
+ <PrivacyProtection
30
+ data={props.data}
31
+ className="embed-map-visualization"
32
+ {...props}
33
+ >
34
+ {!!mapData && (
35
+ <>
50
36
  <Webmap data={mapData} height={height} />
51
37
  <ExtraViews
52
38
  data={{
53
- ...data,
39
+ ...props.data,
54
40
  data_provenance,
55
- map_data: props.map_visualization,
41
+ figure_note,
42
+ map_data: map_visualization_data,
43
+ '@id': props['@id'],
56
44
  }}
57
45
  />
58
- </div>
46
+ </>
59
47
  )}
60
48
  {!mapData && (
61
49
  <p>No map view to show. Set visualization in block configuration.</p>
@@ -64,20 +52,4 @@ const View = (props) => {
64
52
  );
65
53
  };
66
54
 
67
- export default compose(
68
- connect(
69
- (state, props) => ({
70
- map_visualization: props.data.vis_url
71
- ? state.map_visualizations?.data[expandToBackendURL(props.data.vis_url)]
72
- ?.data
73
- : '',
74
- data_provenance: props.data.vis_url
75
- ? state.map_visualizations?.data[expandToBackendURL(props.data.vis_url)]
76
- ?.data_provenance
77
- : '',
78
- }),
79
- {
80
- getVisualization,
81
- },
82
- ),
83
- )(View);
55
+ export default View;
@@ -1,8 +1,9 @@
1
+ import { pickMetadata } from '@eeacms/volto-embed/helpers';
1
2
  import { updateBlockQueryFromPageQuery } from '@eeacms/volto-eea-map/utils';
2
3
 
3
4
  const deepUpdateDataQueryParams = (block, data, data_query, onChangeBlock) => {
4
5
  // If block data_query_params do not exist, init them
5
- if (!data?.data_query_params) {
6
+ if (!data?.data_query_params && data_query) {
6
7
  onChangeBlock(block, {
7
8
  ...data,
8
9
  data_query_params: [...data_query],
@@ -27,4 +28,14 @@ const deepUpdateDataQueryParams = (block, data, data_query, onChangeBlock) => {
27
28
  }
28
29
  };
29
30
 
30
- export { deepUpdateDataQueryParams };
31
+ function getMapVisualizationData(props) {
32
+ const content = props.mapContent || {};
33
+ const map_visualization_data =
34
+ content.map_visualization_data || props.data?.map_visualization_data || {};
35
+ return {
36
+ ...pickMetadata(content),
37
+ ...map_visualization_data,
38
+ };
39
+ }
40
+
41
+ export { deepUpdateDataQueryParams, getMapVisualizationData };
@@ -1,27 +1,65 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import { connect } from 'react-redux';
3
+ import cx from 'classnames';
2
4
  import { serializeNodes } from '@plone/volto-slate/editor/render';
5
+ import {
6
+ FigureNote,
7
+ Sources,
8
+ MoreInfo,
9
+ Share,
10
+ } from '@eeacms/volto-embed/Toolbar';
3
11
  import LegendView from '@eeacms/volto-eea-map/components/LegendView';
4
- import Sources from './Sources';
5
12
 
6
- const ExtraViews = ({ data }) => {
13
+ import '@eeacms/volto-embed/Toolbar/styles.less';
14
+
15
+ const ExtraViews = ({ data, screen }) => {
16
+ const toolbar = useRef();
17
+ const [mobile, setMobile] = useState(false);
7
18
  const {
8
- map_data = {},
19
+ map_visualization_data = {},
9
20
  description,
10
21
  show_legend,
11
22
  show_viewer,
12
- show_sources,
13
- data_provenance = {},
23
+ show_note = true,
24
+ show_sources = true,
25
+ show_more_info = true,
26
+ show_share = true,
14
27
  } = data;
15
28
 
29
+ const { data_provenance = {}, figure_note = [] } = map_visualization_data;
30
+
31
+ useEffect(() => {
32
+ if (toolbar.current) {
33
+ const toolbarParentWidth = toolbar.current.parentElement.offsetWidth;
34
+
35
+ if (toolbarParentWidth < 600 && !mobile) {
36
+ setMobile(true);
37
+ } else if (toolbarParentWidth >= 600 && mobile) {
38
+ setMobile(false);
39
+ }
40
+ }
41
+ }, [screen, mobile]);
42
+
16
43
  return (
17
- <div className="extra-eea-map-content">
18
- {show_legend && map_data && (
19
- <LegendView data={map_data} show_viewer={show_viewer} />
44
+ <>
45
+ {show_legend && map_visualization_data && (
46
+ <LegendView data={map_visualization_data} show_viewer={show_viewer} />
20
47
  )}
21
- {show_sources && <Sources sources={data_provenance?.data} />}
48
+ <div className={cx('visualization-toolbar', { mobile })} ref={toolbar}>
49
+ <div className="left-col">
50
+ {show_note && <FigureNote note={figure_note || []} />}
51
+ {show_sources && <Sources sources={data_provenance?.data} />}
52
+ {show_more_info && <MoreInfo href={data['@id']} />}
53
+ </div>
54
+ <div className="right-col">
55
+ {show_share && <Share href={data['@id']} />}
56
+ </div>
57
+ </div>
22
58
  {description && serializeNodes(description)}
23
- </div>
59
+ </>
24
60
  );
25
61
  };
26
62
 
27
- export default ExtraViews;
63
+ export default connect((state) => ({
64
+ screen: state.screen,
65
+ }))(ExtraViews);
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+ import { Popup } from 'semantic-ui-react';
4
+ import {
5
+ serializeNodes,
6
+ serializeNodesToText,
7
+ } from '@plone/volto-slate/editor/render';
8
+ import { isArray } from 'lodash';
9
+
10
+ export const serializeText = (note) => {
11
+ if (!serializeNodesToText(note))
12
+ return <p>There are no notes set for this visualization</p>;
13
+ return isArray(note) ? serializeNodes(note) : note;
14
+ };
15
+
16
+ const FigureNote = ({ note = [] }) => {
17
+ const [expanded, setExpanded] = React.useState(false);
18
+ return (
19
+ <div className="eea-map-note-container">
20
+ <Popup
21
+ position="bottom left"
22
+ popper={{ id: 'eea-map-note-popup' }}
23
+ trigger={
24
+ <button className={cx('eea-map-note-button', { expanded })}>
25
+ Note
26
+ </button>
27
+ }
28
+ on="click"
29
+ onClose={() => {
30
+ setExpanded(false);
31
+ }}
32
+ onOpen={() => {
33
+ setExpanded(true);
34
+ }}
35
+ >
36
+ <Popup.Content>{serializeText(note)}</Popup.Content>
37
+ </Popup>
38
+ </div>
39
+ );
40
+ };
41
+
42
+ export default FigureNote;
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
2
  import { Button, Grid } from 'semantic-ui-react';
3
+ import cx from 'classnames';
3
4
  import { fetchArcGISData, setLegendColumns } from '../utils';
4
- import { Icon } from '@plone/volto/components';
5
5
  import { serializeNodes } from '@plone/volto-slate/editor/render';
6
6
 
7
- import rightKeySVG from '@plone/volto/icons/right-key.svg';
8
- import downKeySVG from '@plone/volto/icons/down-key.svg';
9
7
  import { withDeviceSize } from '@eeacms/volto-eea-map/hocs';
10
8
 
11
9
  import codeSVG from '@eeacms/volto-eea-map/static/code-line.svg';
@@ -40,14 +38,7 @@ const LayerLegend = ({ data, show_viewer }) => {
40
38
  justifyContent: 'space-between',
41
39
  }}
42
40
  >
43
- <h5
44
- style={{
45
- marginTop: '15px',
46
- marginBottom: '5px',
47
- }}
48
- >
49
- {name}
50
- </h5>
41
+ <h5 style={{ marginBottom: '0.5rem' }}>{name}</h5>
51
42
  {show_viewer && map_service_url && (
52
43
  <a
53
44
  target="_blank"
@@ -112,41 +103,42 @@ const LegendView = (props) => {
112
103
 
113
104
  const legendColumns =
114
105
  map_layers && setLegendColumns(map_layers.length, device);
106
+
115
107
  return (
116
- <>
117
- <div className="legend-container">
118
- <button className="legend-action" onClick={() => setExpand(!expand)}>
119
- {/* <h3 role="presentation" className="legend-title"> */}
120
- <Icon
121
- name={expand ? downKeySVG : rightKeySVG}
122
- title={expand ? 'Collapse' : 'Expand'}
123
- size="17px"
124
- />
125
- Legend:
126
- {/* </h3> */}
127
- </button>
128
- <Grid columns={legendColumns}>
129
- {(!map_layers || map_layers.length === 0) && (
130
- <p>
131
- No layer found for legend. Please add a map layer from editor.
132
- </p>
133
- )}
134
- {expand && (
135
- <Grid.Row divided>
136
- {map_layers &&
137
- map_layers.length > 0 &&
138
- map_layers.map((l, i) => (
139
- <LayerLegend
140
- key={i}
141
- data={l.map_layer}
142
- show_viewer={show_viewer}
143
- />
144
- ))}
145
- </Grid.Row>
146
- )}
108
+ <div className={cx('legend-toolbar', { open: expand })}>
109
+ <button
110
+ className={cx('trigger-button', { open: expand })}
111
+ onClick={() => setExpand(!expand)}
112
+ >
113
+ Legend
114
+ <i
115
+ className={cx({
116
+ 'ri-arrow-right-s-line': !expand,
117
+ 'ri-arrow-down-s-line': expand,
118
+ })}
119
+ />
120
+ </button>
121
+ {expand && (
122
+ <Grid className="legend-container" columns={legendColumns}>
123
+ <Grid.Row divided>
124
+ {(!map_layers || map_layers.length === 0) && (
125
+ <Grid.Column>
126
+ <p>
127
+ No layer found for legend. Please add a map layer from editor.
128
+ </p>
129
+ </Grid.Column>
130
+ )}
131
+ {map_layers?.map((l, i) => (
132
+ <LayerLegend
133
+ key={i}
134
+ data={l.map_layer}
135
+ show_viewer={show_viewer}
136
+ />
137
+ ))}
138
+ </Grid.Row>
147
139
  </Grid>
148
- </div>
149
- </>
140
+ )}
141
+ </div>
150
142
  );
151
143
  };
152
144
 
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+ import { UniversalLink } from '@plone/volto/components';
4
+
5
+ const Link = ({ children, ...props }) => {
6
+ if (props.href) {
7
+ return <UniversalLink {...props}>{children}</UniversalLink>;
8
+ }
9
+ return <span {...props}>{children}</span>;
10
+ };
11
+
12
+ const MoreInfoLink = ({ contentTypeLink }) => {
13
+ return (
14
+ <Link href={contentTypeLink}>
15
+ <button className={cx('eea-map-more-info-button')}>
16
+ More info <i class="ri-external-link-line"></i>
17
+ </button>
18
+ </Link>
19
+ );
20
+ };
21
+
22
+ export default MoreInfoLink;
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import { Popup, Input, Button } from 'semantic-ui-react';
3
+ import { useCopyToClipboard } from '../utils.js';
4
+ import cx from 'classnames';
5
+
6
+ const Share = ({ contentTypeLink = '' }) => {
7
+ const [expanded, setExpanded] = React.useState(false);
8
+ const popupRef = React.useRef();
9
+
10
+ const CopyUrlButton = ({ className, url, buttonText }) => {
11
+ const [copyUrlStatus, copyUrl] = useCopyToClipboard(url);
12
+
13
+ if (copyUrlStatus === 'copied') {
14
+ buttonText = 'Copied!';
15
+ } else if (copyUrlStatus === 'failed') {
16
+ buttonText = 'Copy failed. Please try again.';
17
+ }
18
+
19
+ return (
20
+ <Button
21
+ primary
22
+ onClick={copyUrl}
23
+ className={cx('copy-button', className)}
24
+ >
25
+ {buttonText}
26
+ </Button>
27
+ );
28
+ };
29
+
30
+ return (
31
+ <Popup
32
+ popper={{ id: 'eea-map-share-popup' }}
33
+ trigger={
34
+ <div className="eea-map-share-container">
35
+ <button className={cx('eea-map-share-button', { expanded })}>
36
+ <span>Share</span>
37
+ <i class="ri-share-fill"></i>
38
+ </button>
39
+ </div>
40
+ }
41
+ position="bottom left"
42
+ on="click"
43
+ onClose={() => {
44
+ setExpanded(false);
45
+ }}
46
+ onOpen={() => {
47
+ setExpanded(true);
48
+ }}
49
+ ref={popupRef}
50
+ >
51
+ <div>
52
+ <span className="eea-map-share-popup-text">Copy link</span>
53
+ <div className="eea-map-share-popup-container">
54
+ <Input
55
+ className="eea-map-share-link"
56
+ defaultValue={contentTypeLink}
57
+ />
58
+ <CopyUrlButton
59
+ className="eea-map-copy-button"
60
+ url={contentTypeLink}
61
+ buttonText="Copy"
62
+ />
63
+ </div>
64
+ </div>
65
+ </Popup>
66
+ );
67
+ };
68
+
69
+ export default Share;
@@ -60,7 +60,7 @@ const Webmap = (props) => {
60
60
  css: true,
61
61
  }).then((modules) => {
62
62
  const [
63
- Map,
63
+ MapBlock,
64
64
  MapView,
65
65
  FeatureLayer,
66
66
  MapImageLayer,
@@ -75,7 +75,7 @@ const Webmap = (props) => {
75
75
  Fullscreen,
76
76
  ] = modules;
77
77
  setModules({
78
- Map,
78
+ MapBlock,
79
79
  MapView,
80
80
  FeatureLayer,
81
81
  MapImageLayer,
@@ -125,7 +125,7 @@ const Webmap = (props) => {
125
125
  const esri = React.useMemo(() => {
126
126
  if (Object.keys(modules).length === 0) return {};
127
127
  const {
128
- Map,
128
+ MapBlock,
129
129
  MapView,
130
130
  FeatureLayer,
131
131
  MapImageLayer,
@@ -257,7 +257,7 @@ const Webmap = (props) => {
257
257
  return customBase;
258
258
  };
259
259
 
260
- const map = new Map({
260
+ const map = new MapBlock({
261
261
  basemap:
262
262
  data?.base?.use_custom_base && data?.base?.custom_base_layer
263
263
  ? setCustomBasemap(data?.base?.custom_base_layer)
@@ -360,7 +360,7 @@ const Webmap = (props) => {
360
360
  `;
361
361
 
362
362
  return (
363
- <div>
363
+ <div className="esri-map-wrapper">
364
364
  <style>{dynamicStyle}</style>
365
365
  <div ref={mapRef} className="esri-map"></div>
366
366
  </div>
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import Webmap from '../Webmap';
3
+ import LegendView from '../LegendView';
3
4
  import { hasBlocksData } from '@plone/volto/helpers';
4
5
  import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
5
6
 
@@ -13,7 +14,10 @@ const VisualizationView = (props) => {
13
14
  {hasBlocksData(content) ? (
14
15
  <RenderBlocks {...props} />
15
16
  ) : (
16
- <Webmap data={map_visualization_data} />
17
+ <>
18
+ <Webmap data={map_visualization_data} />
19
+ <LegendView data={map_visualization_data} show_viewer={true} />
20
+ </>
17
21
  )}
18
22
  </div>
19
23
  );
@@ -1,6 +1,12 @@
1
1
  import Webmap from '../Webmap';
2
+ import LegendView from '../LegendView';
2
3
 
3
4
  export default function VisualizationViewWidget(props) {
4
5
  const { value: map_visualization_data = {} } = props;
5
- return <Webmap data={map_visualization_data} />;
6
+ return (
7
+ <>
8
+ <Webmap data={map_visualization_data} />
9
+ <LegendView data={map_visualization_data} show_viewer={true} />
10
+ </>
11
+ );
6
12
  }
package/src/index.js CHANGED
@@ -12,9 +12,6 @@ import VisualizationView from './components/visualization/VisualizationView';
12
12
 
13
13
  import SimpleColorPickerWidget from './components/widgets/SimpleColorPickerWidget';
14
14
 
15
- import { data_visualizations } from './middlewares';
16
- import * as addonReducers from './reducers';
17
-
18
15
  import './less/global.less';
19
16
 
20
17
  export default (config) => {
@@ -67,15 +64,5 @@ export default (config) => {
67
64
  //map viewer for the visualization(content-type)
68
65
  config.views.contentTypesViews.map_visualization = VisualizationView;
69
66
 
70
- config.settings.storeExtenders = [
71
- ...(config.settings.storeExtenders || []),
72
- data_visualizations,
73
- ];
74
-
75
- config.addonReducers = {
76
- ...config.addonReducers,
77
- ...addonReducers,
78
- };
79
-
80
67
  return config;
81
68
  };
@@ -15,6 +15,10 @@
15
15
 
16
16
  @import './variables.less';
17
17
 
18
+ .esri-map-wrapper {
19
+ margin-bottom: 1rem;
20
+ }
21
+
18
22
  // TODO: pull out colors and dimensions into variables
19
23
  .map-edit-container {
20
24
  display: flex;
@@ -182,7 +186,6 @@
182
186
  .legend-container {
183
187
  display: flex;
184
188
  flex-direction: column;
185
- margin: 15px 0;
186
189
  }
187
190
 
188
191
  .map_source_param_container {
@@ -198,23 +201,6 @@
198
201
  padding: 2px 15px !important;
199
202
  }
200
203
 
201
- .legend-action {
202
- z-index: 22;
203
- display: inline-flex;
204
- align-items: center;
205
- padding-bottom: 3px;
206
- border: none;
207
- background: transparent;
208
- background-color: transparent;
209
- color: #3d5265;
210
- cursor: pointer;
211
- font-weight: bold;
212
-
213
- &:hover {
214
- color: @secondaryColor;
215
- }
216
- }
217
-
218
204
  .map-number-input {
219
205
  padding: 5px !important;
220
206
  }
@@ -225,43 +211,25 @@
225
211
  color: green;
226
212
  }
227
213
 
228
- /* sources */
229
-
230
- .eea-map-sources-list {
231
- margin: 0;
232
- list-style: decimal inside;
233
- padding-inline-start: 0;
234
- }
235
-
236
- #eea-map-sources-popup .ui.popup {
237
- min-width: 600px;
238
- background-color: #f9f9f9;
239
- box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
240
- }
214
+ .eea-map-info {
215
+ display: flex;
216
+ flex-direction: row;
241
217
 
242
- .eea-map-sources-button {
243
- display: inline-flex;
244
- align-items: center;
245
- padding-top: 10px;
246
- padding-bottom: 3px;
247
- border: none;
248
- background-color: transparent;
249
- color: @textColor;
250
- cursor: pointer;
251
- font-weight: bold;
218
+ > * {
219
+ padding: 0 0.5rem;
220
+ border-collapse: collapse;
221
+ }
252
222
 
253
- .icon {
254
- margin-left: 0.5rem;
223
+ > *:first-child {
224
+ padding-left: 0;
255
225
  }
256
226
 
257
- &:hover {
258
- color: @secondaryColor;
227
+ > *:last-child {
228
+ padding-right: 0;
259
229
  }
260
230
 
261
- &.expanded {
262
- padding-bottom: 0;
263
- border-bottom: 3px solid @secondaryColor;
264
- color: @secondaryColor;
231
+ > *:not(:last-child) {
232
+ border-right: 1px solid @textColor;
265
233
  }
266
234
  }
267
235
 
@@ -282,9 +250,4 @@
282
250
  max-width: 0.2cm;
283
251
  height: 0.2cm;
284
252
  }
285
-
286
- .eea-map-sources-container,
287
- #eea-map-sources-popup {
288
- display: none;
289
- }
290
253
  }
package/src/utils.js CHANGED
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable no-throw-literal */
2
+ import React from 'react';
2
3
  import { getBaseUrl } from '@plone/volto/helpers';
4
+
3
5
  const setLegendColumns = (legendsNo, device) => {
4
6
  switch (device) {
5
7
  case 'widescreen':
@@ -118,9 +120,32 @@ const updateBlockQueryFromPageQuery = (data_query, data_query_params) => {
118
120
  return newDataQuery;
119
121
  };
120
122
 
123
+ const useCopyToClipboard = (text) => {
124
+ const [copyStatus, setCopyStatus] = React.useState('inactive');
125
+ const copy = React.useCallback(() => {
126
+ navigator.clipboard.writeText(text).then(
127
+ () => setCopyStatus('copied'),
128
+ () => setCopyStatus('failed'),
129
+ );
130
+ }, [text]);
131
+
132
+ React.useEffect(() => {
133
+ if (copyStatus === 'inactive') {
134
+ return;
135
+ }
136
+
137
+ const timeout = setTimeout(() => setCopyStatus('inactive'), 3000);
138
+
139
+ return () => clearTimeout(timeout);
140
+ }, [copyStatus]);
141
+
142
+ return [copyStatus, copy];
143
+ };
144
+
121
145
  export {
122
146
  setLegendColumns,
123
147
  fetchArcGISData,
124
148
  applyQueriesToMapLayers,
125
149
  updateBlockQueryFromPageQuery,
150
+ useCopyToClipboard,
126
151
  };
@@ -1 +0,0 @@
1
- export const GET_MAP_VISUALIZATION = 'GET_MAP_VISUALIZATION';
package/src/actions.js DELETED
@@ -1,12 +0,0 @@
1
- import { GET_MAP_VISUALIZATION } from './actionTypes';
2
-
3
- export function getVisualization(path) {
4
- return {
5
- type: GET_MAP_VISUALIZATION,
6
- path,
7
- request: {
8
- op: 'get',
9
- path: `${path}/@map-visualization`,
10
- },
11
- };
12
- }
@@ -1,14 +0,0 @@
1
- import { GET_MAP_VISUALIZATION } from '../actionTypes';
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
- ];
@@ -1 +0,0 @@
1
- export * from './map_visualizations';
@@ -1,3 +0,0 @@
1
- import map_visualizations from './map_visualizations';
2
-
3
- export { map_visualizations };
@@ -1,48 +0,0 @@
1
- import { GET_MAP_VISUALIZATION } from '../actionTypes';
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
- }