@eeacms/volto-cca-policy 0.1.16 → 0.1.17

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/.project.eslintrc.js +6 -0
  2. package/CHANGELOG.md +76 -0
  3. package/eslint.extend.js +15 -0
  4. package/package.json +4 -2
  5. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.js +63 -83
  6. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.jsx +53 -0
  7. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.jsx +117 -0
  8. package/src/components/manage/Blocks/CaseStudyExplorer/FeatureDisplay.jsx +30 -0
  9. package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.jsx +80 -0
  10. package/src/components/manage/Blocks/CaseStudyExplorer/InfoOverlay.jsx +77 -0
  11. package/src/components/manage/Blocks/CaseStudyExplorer/hooks.js +20 -0
  12. package/src/components/manage/Blocks/CaseStudyExplorer/styles.less +59 -0
  13. package/src/components/manage/Blocks/CaseStudyExplorer/utils.js +73 -0
  14. package/src/components/manage/Blocks/FilterAceContent/FilterAceContentEdit.jsx +32 -0
  15. package/src/components/manage/Blocks/FilterAceContent/FilterAceContentView.jsx +40 -0
  16. package/src/components/manage/Blocks/FilterAceContent/index.js +22 -0
  17. package/src/components/manage/Blocks/FilterAceContent/schema.js +112 -0
  18. package/src/components/manage/Blocks/RelevantAceContent/RelevantAceContentEdit.jsx +45 -0
  19. package/src/components/manage/Blocks/RelevantAceContent/RelevantAceContentView.jsx +56 -0
  20. package/src/components/manage/Blocks/RelevantAceContent/index.js +22 -0
  21. package/src/components/manage/Blocks/RelevantAceContent/schema.js +155 -0
  22. package/src/components/manage/Blocks/SearchAceContent/SearchAceContentEdit.jsx +32 -0
  23. package/src/components/manage/Blocks/SearchAceContent/SearchAceContentView.jsx +34 -0
  24. package/src/components/manage/Blocks/SearchAceContent/index.js +22 -0
  25. package/src/components/manage/Blocks/SearchAceContent/schema.js +100 -0
  26. package/src/components/manage/Blocks/index.js +6 -1
  27. package/src/components/theme/Widgets/GeocharsWidget.jsx +344 -0
  28. package/src/components/theme/Widgets/GeolocationWidget.jsx +155 -0
  29. package/src/helpers/Constants.jsx +67 -0
  30. package/src/helpers/index.js +10 -1
  31. package/src/index.js +14 -2
  32. package/src/search/config.js +184 -0
  33. package/src/search/facets.js +1189 -0
  34. package/src/search/index.js +24 -0
  35. package/theme/globals/site.overrides +11 -0
@@ -26,6 +26,11 @@ const addonAliases = Object.keys(reg.packages).map((o) => [
26
26
  reg.packages[o].modulePath,
27
27
  ]);
28
28
 
29
+ const voltoSearchlibPath = path.dirname(
30
+ reg.packages['@eeacms/volto-searchlib'].modulePath,
31
+ );
32
+ const searchlibPath = path.resolve(`${voltoSearchlibPath}/searchlib`);
33
+
29
34
  module.exports = {
30
35
  extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
31
36
  settings: {
@@ -34,6 +39,7 @@ module.exports = {
34
39
  map: [
35
40
  ['@plone/volto', '@plone/volto/src'],
36
41
  ...addonAliases,
42
+ ['@eeacms/search', searchlibPath],
37
43
  ['@package', `${__dirname}/src`],
38
44
  ['~', `${__dirname}/src`],
39
45
  ],
package/CHANGELOG.md CHANGED
@@ -4,6 +4,82 @@ 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.17](https://github.com/eea/volto-cca-policy/compare/0.1.16...0.1.17) - 28 April 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Change logoTargetUrl to avoid redirect [laszlocseh - [`c4471b7`](https://github.com/eea/volto-cca-policy/commit/c4471b774952295b32892db147f3b969e5987fb4)]
12
+ - Add eslint extenders [Tiberiu Ichim - [`1d5bdf0`](https://github.com/eea/volto-cca-policy/commit/1d5bdf09c1e15b5a4af62fe0d2c6ac9244b9a2e1)]
13
+ - Code cleanup [Tiberiu Ichim - [`fab4585`](https://github.com/eea/volto-cca-policy/commit/fab4585335c1478b2e9dde916d893139b2dbbadc)]
14
+ - Add facets [Tiberiu Ichim - [`f4c6f81`](https://github.com/eea/volto-cca-policy/commit/f4c6f8135666594ad8a2598e09688688a5f0589a)]
15
+ - Loads [Tiberiu Ichim - [`e2eb38c`](https://github.com/eea/volto-cca-policy/commit/e2eb38ca93f0a71a95fd9c6fab4de9dffef40af5)]
16
+ - WIP [Tiberiu Ichim - [`7bd6907`](https://github.com/eea/volto-cca-policy/commit/7bd6907c3cd9f96899f054024f5017e82d9e98ac)]
17
+ - WIP [Tiberiu Ichim - [`bd91e7e`](https://github.com/eea/volto-cca-policy/commit/bd91e7e68cf371019513084373ade188fa66614f)]
18
+ - WIP Filter ace content block [kreafox - [`4963075`](https://github.com/eea/volto-cca-policy/commit/4963075abbe5b24892e5d052ee8f4b102950f329)]
19
+ - Add dependency on globalsearch [Tiberiu Ichim - [`eb517b3`](https://github.com/eea/volto-cca-policy/commit/eb517b38656a2ea18f89c2efb1cc4b6aa1dec882)]
20
+ - Fix vocabulary [kreafox - [`c8f614a`](https://github.com/eea/volto-cca-policy/commit/c8f614a4532b4a6d78a533d3ad0fd20d4887c8f3)]
21
+ - Update schema [kreafox - [`dd337ef`](https://github.com/eea/volto-cca-policy/commit/dd337eff91b50d1992c88a7dea755e64dbb65745)]
22
+ - Update sort options [kreafox - [`b3a9804`](https://github.com/eea/volto-cca-policy/commit/b3a98044c660a96b9c32c26d4a6304f9ad1774e1)]
23
+ - Style lint [Tiberiu Ichim - [`8363105`](https://github.com/eea/volto-cca-policy/commit/8363105289184afb076e75587a27969077abb539)]
24
+ - Animate fit [Tiberiu Ichim - [`b7f073f`](https://github.com/eea/volto-cca-policy/commit/b7f073f330a39ef662c25688d067206999141a7d)]
25
+ - Add combine results [kreafox - [`eeafeda`](https://github.com/eea/volto-cca-policy/commit/eeafedabeb8f4af1cba68595008faf5648928a67)]
26
+ - Fix padding of extent [Tiberiu Ichim - [`796d05a`](https://github.com/eea/volto-cca-policy/commit/796d05aa473fc7b1b0afd8bc29396e26e99d8392)]
27
+ - Fixes to map [Tiberiu Ichim - [`f1ce4c4`](https://github.com/eea/volto-cca-policy/commit/f1ce4c4bf9ce8b6bb87cb7ae94bd0c82a616f8a0)]
28
+ - List items in relevant acecontent block [kreafox - [`d6fade5`](https://github.com/eea/volto-cca-policy/commit/d6fade5bcc90da105b8e0b306a317790f4d75599)]
29
+ - Fixes to map [Tiberiu Ichim - [`4e31cfe`](https://github.com/eea/volto-cca-policy/commit/4e31cfe6eec5a23b0deeb3226838abf116048878)]
30
+ - Fixes to map [Tiberiu Ichim - [`b8fb736`](https://github.com/eea/volto-cca-policy/commit/b8fb7360ddc6480cdabe789050f17135e447fda7)]
31
+ - cem css [Tripon Eugen - [`3c5f36d`](https://github.com/eea/volto-cca-policy/commit/3c5f36dd6f885c5fe98ad75875619c9df2c55cc2)]
32
+ - Refs #251121 - wip [Tripon Eugen - [`512301d`](https://github.com/eea/volto-cca-policy/commit/512301d9ce9f478fa80c0c726ea47e5bb3b81f1d)]
33
+ - CaseStudyExplorer View [Tripon Eugen - [`6556e5d`](https://github.com/eea/volto-cca-policy/commit/6556e5df21515e37665c1d5240623d87299d1a42)]
34
+ - Relevant acecontent: add option of adding source [kreafox - [`6d2da45`](https://github.com/eea/volto-cca-policy/commit/6d2da45d8e9e07308720555cfe5dafcc3caaa353)]
35
+ - WIP relevant acecontent [kreafox - [`aade13c`](https://github.com/eea/volto-cca-policy/commit/aade13cc0ff1c865b598f9e77fe81f0eb5d28207)]
36
+ - Simplify [kreafox - [`2f66df8`](https://github.com/eea/volto-cca-policy/commit/2f66df8cf6e9b69e8ca53c3184006a595b6c4eb9)]
37
+ - Add share info button [kreafox - [`014891e`](https://github.com/eea/volto-cca-policy/commit/014891ec2ca3ef1b555e43febdeda05b79b941dd)]
38
+ - Add view for SearchAceContent [kreafox - [`2702109`](https://github.com/eea/volto-cca-policy/commit/27021098e9ec344903460482be29b05c9880b560)]
39
+ - WIP SearchAceContent block [kreafox - [`f54fac0`](https://github.com/eea/volto-cca-policy/commit/f54fac05d910a86c23f7e72e6de5982408192d00)]
40
+ - Add new block [Tiberiu Ichim - [`6193c7e`](https://github.com/eea/volto-cca-policy/commit/6193c7ea6721389ae9f182f5654f6ab0e5c6c5cb)]
41
+ - Refs #161509 - GeolocationWidget: improve form. [GhitaB - [`0e8ea37`](https://github.com/eea/volto-cca-policy/commit/0e8ea3756d8b60b4f48292407c57fc2179d89f5f)]
42
+ - Refs #161509 - GeolocationWidget: improve form. [GhitaB - [`dd72546`](https://github.com/eea/volto-cca-policy/commit/dd72546622c71c09bc1c151cc57b45fcb5bdb651)]
43
+ - Refs #161509 - GeolocationWidget: improve form. [GhitaB - [`e74ef5f`](https://github.com/eea/volto-cca-policy/commit/e74ef5f1f0a31f0f466661045139b09e6e503899)]
44
+ - Refs #161509 - GeolocationWidget: get rid of states. [GhitaB - [`667d35f`](https://github.com/eea/volto-cca-policy/commit/667d35f85cfe5812bb1994a92e760492e6144246)]
45
+ - Refs #161509 - GeolocationWidget: search address, update coordinates, recenter map. [GhitaB - [`b2eddfa`](https://github.com/eea/volto-cca-policy/commit/b2eddfa075416650ac9c45f6322ebb1691f95c04)]
46
+ - Refs #161509 - GeolocationWidget: recenter map on coordinates change. [GhitaB - [`63ed0b8`](https://github.com/eea/volto-cca-policy/commit/63ed0b8c23995109fc283c4ae71ae8247cb77d10)]
47
+ - Refs #161509 - GeolocationWidget: load map using longitude, latitude. Set zoom. [GhitaB - [`710198a`](https://github.com/eea/volto-cca-policy/commit/710198a6871685abdcb583e25827f8aa56ca4d2c)]
48
+ - Refs #161509 - Add GeolocationWidget (WIP). [GhitaB - [`5aadc67`](https://github.com/eea/volto-cca-policy/commit/5aadc678b02b9ee6b913b661082309ab5c334500)]
49
+ - Refs #161509 - Add GeolocationWidget (WIP). [GhitaB - [`fb3fafb`](https://github.com/eea/volto-cca-policy/commit/fb3fafb69c78e0587aeeb194335f8a540bbd0cd2)]
50
+ - Refs #161509 - GeocharsWidget: add description for subnational regions. [GhitaB - [`639619e`](https://github.com/eea/volto-cca-policy/commit/639619eeb94db1f4ac8ee93cc67aea417cc209f3)]
51
+ - Refs #161509 - GeocharsWidget: hide textarea (containing JSON value). [GhitaB - [`dd9f834`](https://github.com/eea/volto-cca-policy/commit/dd9f83494b97192c1cf4872aeff2263f8f3923ad)]
52
+ - Refs #161509 - GeocharsWidget: keep selected regions visible until unselected, when countries section is changed. [GhitaB - [`e183218`](https://github.com/eea/volto-cca-policy/commit/e1832187efce45be532f96b5aa2eec5d80640036)]
53
+ - Refs #161509 - GeocharsWidget: show subregions only for checked countries. [GhitaB - [`4c74b88`](https://github.com/eea/volto-cca-policy/commit/4c74b8875a7488eea2ddc524f66294caf2f0414e)]
54
+ - Refs #161509 - GeocharsWidget: clear other fields when selecting Global, but keep a copy of values in case option is changed again before saving. [GhitaB - [`c7d1469`](https://github.com/eea/volto-cca-policy/commit/c7d1469462dd4dda591313037b9a35c9e6baaddd)]
55
+ - Refs #161509 - GeocharsWidget: simplify code - use component for element. [GhitaB - [`495a400`](https://github.com/eea/volto-cca-policy/commit/495a40000e6c4d6f0d9e745cb125c739b3b7bc67)]
56
+ - Refs #161509 - GeocharsWidget: simplify code - use component for macro regions. [GhitaB - [`9921a07`](https://github.com/eea/volto-cca-policy/commit/9921a07910a875766c2c69b7b6e08c4a44c55e48)]
57
+ - Refs #161509 - GeocharsWidget: simplify code - use component for bioregions. [GhitaB - [`4bff217`](https://github.com/eea/volto-cca-policy/commit/4bff217454ef4bd5e714b0e425c9957b02c7d29f)]
58
+ - Refs #161509 - GeocharsWidget: simplify code - use component for countries. [GhitaB - [`f4ab32b`](https://github.com/eea/volto-cca-policy/commit/f4ab32b03b22e44d6b39846bc5e3538204b25222)]
59
+ - Refs #161509 - GeocharsWidget: simplify code - use component for subnational regions. [GhitaB - [`fa8ae29`](https://github.com/eea/volto-cca-policy/commit/fa8ae291569322a7310c0571b1cd84735b07288a)]
60
+ - Refs #161509 - GeocharsWidget: simplify code - use component for city. [GhitaB - [`63a7db2`](https://github.com/eea/volto-cca-policy/commit/63a7db278e7ad3daf89dc2ad30980a2c58e44d94)]
61
+ - Refs #161509 - GeocharsWidget: simplify code - shorter var name. [GhitaB - [`8f71c44`](https://github.com/eea/volto-cca-policy/commit/8f71c44244c207b85fd620031ada70d053f51b30)]
62
+ - Refs #161509 - GeocharsWidget: simplify code - move consts. [GhitaB - [`83c82a0`](https://github.com/eea/volto-cca-policy/commit/83c82a0db139d4b6c578a203a5a7dda5abc3cbb2)]
63
+ - Refs #161509 - GeocharsWidget: select city. [GhitaB - [`6854102`](https://github.com/eea/volto-cca-policy/commit/685410285e09b5fd4313695fe8144497a429b397)]
64
+ - Refs #161509 - GeocharsWidget: select subnational regions - fix bug. [GhitaB - [`5557254`](https://github.com/eea/volto-cca-policy/commit/55572547bfae8e492a149a601beaaa2a8e93e509)]
65
+ - Refs #161509 - GeocharsWidget: select subnational regions. [GhitaB - [`d831604`](https://github.com/eea/volto-cca-policy/commit/d8316041945a27d1c1bd0aff656bfd7b2d3d5f18)]
66
+ - Refs #161509 - GeocharsWidget: select bio regions. [GhitaB - [`37ffd7b`](https://github.com/eea/volto-cca-policy/commit/37ffd7b0fde421e9349e26a649010fdce8ccd343)]
67
+ - Refs #161509 - GeocharsWidget: select macro transnational regions. [GhitaB - [`fcd0507`](https://github.com/eea/volto-cca-policy/commit/fcd050722864f3e9878eee4cc97140dc470f8b53)]
68
+ - Refs #161509 - GeocharsWidget: show only EU countries. [GhitaB - [`5e835dd`](https://github.com/eea/volto-cca-policy/commit/5e835ddf0626fda0d381d998f86083d9d83ce508)]
69
+ - Refs #161509 - GeocharsWidget: fix bug in countries selection, update textarea on changes. [GhitaB - [`4a125df`](https://github.com/eea/volto-cca-policy/commit/4a125dfe326ef8c876f7dc06f4286e438b73a632)]
70
+ - Refs #161509 - GeocharsWidget: add styles. [GhitaB - [`c958cbf`](https://github.com/eea/volto-cca-policy/commit/c958cbfbd3ca0160cf5ea7aaaaac32b37e06c77b)]
71
+ - Refs #161509 - GeocharsWidget: add styles. [GhitaB - [`51a447d`](https://github.com/eea/volto-cca-policy/commit/51a447d68266b2ff97b58e126ef33b706f36a509)]
72
+ - Refs #161509 - GeocharsWidget: update countries on change. [GhitaB - [`6487bdc`](https://github.com/eea/volto-cca-policy/commit/6487bdc3ff73af2395f4820d3d586f2ddeeec76c)]
73
+ - Refs #161509 - GeocharsWidget: update Global/Europe value on change. [GhitaB - [`1f16c14`](https://github.com/eea/volto-cca-policy/commit/1f16c142f9e1eab00e173bf3268f23eda2d49b5d)]
74
+ - Refs #161509 - GeocharsWidget: hide/show fields for each Global/Europe case. [GhitaB - [`503129e`](https://github.com/eea/volto-cca-policy/commit/503129e5aaec02305e3765b23587bc3471a00ec1)]
75
+ - Refs #161509 - GeocharsWidget: hide/show fields for each Global/Europe case. [GhitaB - [`50f7ac9`](https://github.com/eea/volto-cca-policy/commit/50f7ac9b651e40b610a64e4242acdc1c58d52964)]
76
+ - Refs #161509 - GeocharsWidget: add spacing. [GhitaB - [`2c9a1db`](https://github.com/eea/volto-cca-policy/commit/2c9a1dbef2a56815fd90134b2ce11bb6ef00f612)]
77
+ - Refs #161509 - GeocharsWidget: city. [GhitaB - [`a37c9f6`](https://github.com/eea/volto-cca-policy/commit/a37c9f6b90858385ec6863684f68cc09890843b3)]
78
+ - Refs #161509 - GeocharsWidget: subnational regions. [GhitaB - [`e05e004`](https://github.com/eea/volto-cca-policy/commit/e05e00499853fa0692652264074a0c09fc46a0d1)]
79
+ - Refs #161509 - GeocharsWidget: biogeographical regions. [GhitaB - [`4cc4695`](https://github.com/eea/volto-cca-policy/commit/4cc4695d71a93998c991112544113f7d9a1a3971)]
80
+ - Refs #161509 - GeocharsWidget: macro transnational regions. [GhitaB - [`afe36eb`](https://github.com/eea/volto-cca-policy/commit/afe36ebd8b65aed650ad23a2d1bb6a71b5589f02)]
81
+ - Refs #161509 - GeocharsWidget: countries. [GhitaB - [`5662531`](https://github.com/eea/volto-cca-policy/commit/56625317f6cc02840d73b06050e87befed2fe10c)]
82
+ - Refs #161509 - Add GeocharsWidget to be used for geochars field (WIP). [GhitaB - [`85bcb7b`](https://github.com/eea/volto-cca-policy/commit/85bcb7b0f676e8e447e84954ec9018415d30145c)]
7
83
  ### [0.1.16](https://github.com/eea/volto-cca-policy/compare/0.1.15...0.1.16) - 29 March 2023
8
84
 
9
85
  #### :hammer_and_wrench: Others
@@ -0,0 +1,15 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ modify(defaultConfig) {
5
+ const aliasMap = defaultConfig.settings['import/resolver'].alias.map;
6
+ const addonPath = aliasMap.find(
7
+ ([name]) => name === '@eeacms/volto-searchlib',
8
+ )[1];
9
+
10
+ const searchlibPath = path.resolve(`${addonPath}/../searchlib`);
11
+ aliasMap.push(['@eeacms/search', searchlibPath]);
12
+
13
+ return defaultConfig;
14
+ },
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -18,10 +18,12 @@
18
18
  },
19
19
  "addons": [
20
20
  "@eeacms/volto-openlayers-map",
21
- "@eeacms/volto-eea-design-system"
21
+ "@eeacms/volto-eea-design-system",
22
+ "@eeacms/volto-globalsearch"
22
23
  ],
23
24
  "dependencies": {
24
25
  "@eeacms/volto-eea-design-system": "*",
26
+ "@eeacms/volto-globalsearch": "*",
25
27
  "@eeacms/volto-openlayers-map": "*"
26
28
  },
27
29
  "devDependencies": {
@@ -1,109 +1,89 @@
1
1
  import React from 'react';
2
- import superagent from 'superagent';
3
- import { addAppURL } from '@plone/volto/helpers';
4
2
  import { Grid } from 'semantic-ui-react'; // Dropdown,
5
- import { getVocabulary } from '@plone/volto/actions'; // , searchContent
6
- //import ECDEIndicator from './ECDEIndicator';
7
- import { useDispatch } from 'react-redux'; // , useSelector
8
-
9
- // const cases_url =
10
- // 'http://localhost:3000/en/mkh/case-studies-map-arcgis.json/@@download/file';
11
- const cases_url = '@@case-studies-map.arcgis.json';
12
- const IPCC = 'eea.climateadapt.aceitems_ipcc_category';
3
+ import { addAppURL } from '@plone/volto/helpers';
13
4
 
14
- function useCases(url) {
15
- const [cases, setCases] = React.useState([]);
5
+ import CaseStudyMap from './CaseStudyMap';
6
+ import CaseStudyFilters from './CaseStudyFilters';
16
7
 
17
- React.useEffect(() => {
18
- superagent
19
- .get(cases_url)
20
- .set('accept', 'json')
21
- .then((resp) => {
22
- const res = JSON.parse(resp.text);
23
- setCases(res.features);
24
- });
25
- }, []);
8
+ import { filterCases, getFilters } from './utils';
9
+ import { useCases } from './hooks';
26
10
 
27
- return cases;
28
- }
11
+ import './styles.less';
29
12
 
30
- // function useFilters() {
31
- // const [filters, setFilters] = React.useState([]);
32
- // }
13
+ const cases_url = '@@case-studies-map.arcgis.json';
33
14
 
34
15
  export default function CaseStudyExplorerView(props) {
35
- // console.log(regions);
36
16
  const cases = useCases(addAppURL(cases_url));
37
17
 
38
- //const filters = useFilters();
18
+ const [activeFilters, setActiveFilters] = React.useState({
19
+ sectors: [],
20
+ impacts: [],
21
+ });
22
+
23
+ const [activeItems, setActiveItems] = React.useState(cases);
39
24
  const [filters, setFilters] = React.useState([]);
40
- const dispatch = useDispatch();
41
- // const ipcc_categories = useSelector(
42
- // (state) => state.vocabularies?.[IPCC]?.items,
43
- // );
44
25
 
45
26
  React.useEffect(() => {
46
- const action = getVocabulary({
47
- vocabNameOrURL: IPCC,
48
- });
49
- dispatch(action);
50
- }, [dispatch]);
27
+ const _filters = getFilters(cases);
28
+ setFilters(_filters);
29
+ }, [cases, activeFilters.impacts, activeFilters.sectors, activeItems.length]);
51
30
 
52
31
  React.useEffect(() => {
53
- let _filters = { sectors: {}, impacts: {} };
32
+ const activeItems = filterCases(cases, activeFilters);
33
+ setActiveItems(activeItems);
34
+ }, [activeFilters, cases]);
54
35
 
55
- // console.log('acis', typeof cases, cases[0], cases);
56
- // console.log(Object.keys(cases));
57
- for (var key of Object.keys(cases)) {
58
- // console.log(key, cases[key]);
59
- var _case = cases[key];
60
- let sectorKeys = _case.properties.sectors.split(',');
61
- let sectorNames = _case.properties.sectors_str.split(',');
62
- for (var i = 0; i < sectorNames.length; i++) {
63
- if (!_filters.sectors.hasOwnProperty(sectorKeys[i + 1])) {
64
- _filters.sectors[sectorKeys[i + 1]] = sectorNames[i];
65
- }
66
- }
67
- let impactKeys = _case.properties.impacts.split(',');
68
- let impactNames = _case.properties.impacts_str.split(',');
69
- for (i = 0; i < impactNames.length; i++) {
70
- if (!_filters.impacts.hasOwnProperty(impactKeys[i + 1])) {
71
- _filters.impacts[impactKeys[i + 1]] = impactNames[i];
72
- }
73
- }
74
- }
75
- setFilters(_filters);
76
- }, [cases]);
77
-
78
- // const [activeFilters, setActiveFilters] = React.useState({});
79
- //
80
- // console.log({ ipcc_categories, filters });
36
+ if (__SERVER__) return '';
81
37
 
82
38
  return (
83
39
  <div>
84
40
  <Grid columns="12">
85
- <Grid.Column mobile={12} tablet={12} computer={10} className="col-left">
86
- MAP HERE
41
+ <Grid.Column mobile={9} tablet={9} computer={10} className="col-left">
42
+ {cases.length ? (
43
+ <CaseStudyMap items={cases} activeItems={activeItems} />
44
+ ) : null}
87
45
  </Grid.Column>
88
- <Grid.Column mobile={12} tablet={12} computer={2} className="col-left">
89
- {Object.entries(filters?.sectors || {}).map(
90
- ([value, label], index) => (
91
- <div key={index}>
92
- <input
93
- value={value}
94
- type="checkbox"
95
- onChange={(e) => {
96
- // const value =
97
- // console.log(e.target.checked);
98
- // setActiveFilters({...activeFilters, sector: [...activeFilters
99
- }}
100
- />
101
- <span>{label}</span>
102
- </div>
103
- ),
104
- )}
46
+ <Grid.Column
47
+ mobile={3}
48
+ tablet={3}
49
+ computer={2}
50
+ className="col-left"
51
+ id="cse-filter"
52
+ >
53
+ <CaseStudyFilters
54
+ filters={filters}
55
+ activeFilters={activeFilters}
56
+ setActiveFilters={setActiveFilters}
57
+ />
105
58
  </Grid.Column>
106
59
  </Grid>
107
60
  </div>
108
61
  );
109
62
  }
63
+
64
+ // import { useDispatch } from 'react-redux'; // , useSelector
65
+ // import { getVocabulary } from '@plone/volto/actions'; // , searchContent
66
+ // const IPCC = 'eea.climateadapt.aceitems_ipcc_category';
67
+ // const dispatch = useDispatch();
68
+ // React.useEffect(() => {
69
+ // const action = getVocabulary({
70
+ // vocabNameOrURL: IPCC,
71
+ // });
72
+ // dispatch(action);
73
+ // }, [dispatch]);
74
+ // setMapKey(
75
+ // activeItems.length +
76
+ // '-' +
77
+ // activeFilters.sectors +
78
+ // '-' +
79
+ // activeFilters.impacts,
80
+ // );
81
+ //console.log('activeFilters filter cases', data);
82
+ // setMapKey(
83
+ // activeItems.length +
84
+ // '-' +
85
+ // activeFilters.sectors +
86
+ // '-' +
87
+ // activeFilters.impacts,
88
+ // );
89
+ // const [mapKey, setMapKey] = React.useState('-');
@@ -0,0 +1,53 @@
1
+ export default function CaseStudyFilters(props) {
2
+ const { filters, activeFilters, setActiveFilters } = props;
3
+ return (
4
+ <>
5
+ <h4>Adaptation sectors</h4>
6
+ {Object.entries(filters?.sectors || {}).map(([value, label], index) => (
7
+ <p key={index}>
8
+ <span>{label}</span>
9
+ <input
10
+ value={value}
11
+ type="checkbox"
12
+ onChange={(e) => {
13
+ // const value =
14
+ const temp = JSON.parse(JSON.stringify(activeFilters));
15
+ if (e.target.checked) {
16
+ temp.sectors.push(e.target.value);
17
+ } else {
18
+ temp.sectors = temp.sectors.filter((value) => {
19
+ if (value !== e.target.value) return value;
20
+ return null;
21
+ });
22
+ }
23
+ setActiveFilters(temp);
24
+ }}
25
+ />
26
+ </p>
27
+ ))}
28
+ <h4>Climate impacts</h4>
29
+ {Object.entries(filters?.impacts || {}).map(([value, label], index) => (
30
+ <p key={index}>
31
+ <span>{label}</span>
32
+ <input
33
+ value={value}
34
+ type="checkbox"
35
+ onChange={(e) => {
36
+ // const value =
37
+ const temp = JSON.parse(JSON.stringify(activeFilters));
38
+ if (e.target.checked) {
39
+ temp.impacts.push(e.target.value);
40
+ } else {
41
+ temp.impacts = temp.impacts.filter((value) => {
42
+ if (value !== e.target.value) return value;
43
+ return null;
44
+ });
45
+ }
46
+ setActiveFilters(temp);
47
+ }}
48
+ />
49
+ </p>
50
+ ))}
51
+ </>
52
+ );
53
+ }
@@ -0,0 +1,117 @@
1
+ import React from 'react';
2
+
3
+ import { Map, Layer, Layers } from '@eeacms/volto-openlayers-map/api';
4
+ import { openlayers as ol } from '@eeacms/volto-openlayers-map';
5
+
6
+ import InfoOverlay from './InfoOverlay';
7
+ import FeatureInteraction from './FeatureInteraction';
8
+
9
+ import { getFeatures } from './utils';
10
+
11
+ const styleCache = {};
12
+
13
+ export default function CaseStudyMap(props) {
14
+ const { items, activeItems } = props;
15
+ const [selectedCase, onSelectedCase] = React.useState();
16
+
17
+ const features = getFeatures(items); //console.log('Features list', features);
18
+
19
+ const [tileWMSSources, setTileWMSSources] = React.useState([]);
20
+ const [pointsSource] = React.useState(
21
+ new ol.source.Vector({
22
+ features,
23
+ }),
24
+ );
25
+
26
+ const [clusterSource] = React.useState(
27
+ new ol.source.Cluster({
28
+ distance: 50,
29
+ source: pointsSource,
30
+ }),
31
+ );
32
+
33
+ React.useEffect(() => {
34
+ if (activeItems) {
35
+ pointsSource.clear();
36
+ pointsSource.addFeatures(getFeatures(activeItems));
37
+ }
38
+ }, [activeItems, pointsSource]);
39
+
40
+ React.useEffect(() => {
41
+ setTileWMSSources([
42
+ new ol.source.TileWMS({
43
+ url: 'https://gisco-services.ec.europa.eu/maps/service',
44
+ params: {
45
+ LAYERS: 'OSMBlossomComposite',
46
+ TILED: true,
47
+ },
48
+ serverType: 'geoserver',
49
+ transition: 0,
50
+ }),
51
+ ]);
52
+ }, []);
53
+
54
+ return features.length > 0 ? (
55
+ <Map
56
+ view={{
57
+ center: ol.proj.fromLonLat([20, 50]),
58
+ showFullExtent: true,
59
+ zoom: 4,
60
+ }}
61
+ pixelRatio={1}
62
+ controls={ol.control.defaults({ attribution: false })}
63
+ >
64
+ <Layers>
65
+ <InfoOverlay
66
+ selectedFeature={selectedCase}
67
+ onFeatureSelect={onSelectedCase}
68
+ layerId={tileWMSSources?.[0]}
69
+ />
70
+ <FeatureInteraction onFeatureSelect={onSelectedCase} />
71
+ <Layer.Tile source={tileWMSSources[0]} zIndex={0} />
72
+ <Layer.Vector style={clusterStyle} source={clusterSource} zIndex={1} />
73
+ </Layers>
74
+ </Map>
75
+ ) : null;
76
+ }
77
+
78
+ function clusterStyle(feature) {
79
+ const size = feature.get('features').length;
80
+ //const size = feature.get('casePoints').length;
81
+ let style = styleCache[size];
82
+
83
+ if (!style) {
84
+ style = new ol.style.Style({
85
+ image: new ol.style.Circle({
86
+ radius: 10 + Math.min(Math.floor(size / 3), 10),
87
+ stroke: new ol.style.Stroke({
88
+ color: '#fff',
89
+ }),
90
+ fill: new ol.style.Fill({
91
+ color: '#3399CC',
92
+ }),
93
+ }),
94
+ text: new ol.style.Text({
95
+ text: size.toString(),
96
+ fill: new ol.style.Fill({
97
+ color: '#fff',
98
+ }),
99
+ }),
100
+ });
101
+ styleCache[size] = style;
102
+ }
103
+
104
+ return size === 1
105
+ ? new ol.style.Style({
106
+ image: new ol.style.Circle({
107
+ radius: 5,
108
+ stroke: new ol.style.Stroke({
109
+ color: '#fff',
110
+ }),
111
+ fill: new ol.style.Fill({
112
+ color: '#000000',
113
+ }),
114
+ }),
115
+ })
116
+ : style;
117
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+
3
+ export default function FeatureDisplay({ feature }) {
4
+ return feature ? (
5
+ <div id="csepopup">
6
+ <strong>{feature.title}</strong>
7
+ <span className="img">
8
+ <center>
9
+ <img src={feature.image} alt={feature.title} />
10
+ </center>
11
+ </span>
12
+ <p>
13
+ <p style={{ marginBottom: '10px' }}>
14
+ <span className="blue">Adaptation sectors: </span>
15
+ <span>{feature.adaptations}</span>
16
+ </p>
17
+ <p style={{ marginBottom: '10px' }}>
18
+ <span className="blue">Climate impacts: </span>
19
+ <span>{feature.impacts}</span>
20
+ </p>
21
+ <span className="blue">Adaptation options: </span>
22
+ <span
23
+ dangerouslySetInnerHTML={{
24
+ __html: feature.adaptation_options_links.replace('<>', '; '),
25
+ }}
26
+ ></span>
27
+ </p>
28
+ </div>
29
+ ) : null;
30
+ }
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import { openlayers as ol } from '@eeacms/volto-openlayers-map';
3
+ import { useMapContext } from '@eeacms/volto-openlayers-map/api';
4
+
5
+ const useStyles = () => {
6
+ const selected = React.useMemo(
7
+ () =>
8
+ new ol.style.Style({
9
+ fill: new ol.style.Fill({
10
+ color: '#cccccc',
11
+ }),
12
+ stroke: new ol.style.Stroke({
13
+ color: 'rgba(255, 0, 0, 0.7)',
14
+ width: 2,
15
+ }),
16
+ }),
17
+ [],
18
+ );
19
+
20
+ const selectStyle = React.useCallback(
21
+ (feature) => {
22
+ const color = feature.get('COLOR') || '#eeeeee';
23
+ selected.getFill().setColor(color);
24
+ return selected;
25
+ },
26
+ [selected],
27
+ );
28
+
29
+ return { selected, selectStyle };
30
+ };
31
+
32
+ function getExtentOfFeatures(features) {
33
+ const points = features.map((f) => f.getGeometry().flatCoordinates);
34
+ const point = new ol.geom.MultiPoint(points);
35
+ return point.getExtent();
36
+ }
37
+
38
+ export default function FeatureInteraction({ onFeatureSelect }) {
39
+ const { map } = useMapContext();
40
+ const { selectStyle } = useStyles();
41
+
42
+ React.useEffect(() => {
43
+ if (!map) return;
44
+
45
+ const select = new ol.interaction.Select({
46
+ condition: ol.condition.click,
47
+ style: selectStyle,
48
+ });
49
+
50
+ select.on('select', function (e) {
51
+ const features = e.target.getFeatures().getArray();
52
+
53
+ features.forEach((feature) => {
54
+ const subfeatures = feature.values_.features;
55
+ if (subfeatures.length === 1) {
56
+ const selectedFeature = subfeatures[0].values_;
57
+ onFeatureSelect(selectedFeature);
58
+ } else {
59
+ const extent = getExtentOfFeatures(subfeatures);
60
+ const paddedExtent = ol.extent.buffer(extent, 50000);
61
+ map.getView().fit(paddedExtent, { ...map.getSize(), duration: 1000 });
62
+ }
63
+ });
64
+
65
+ return null;
66
+ });
67
+
68
+ map.addInteraction(select);
69
+
70
+ map.on('pointermove', (e) => {
71
+ const pixel = map.getEventPixel(e.originalEvent);
72
+ const hit = map.hasFeatureAtPixel(pixel);
73
+ map.getViewport().style.cursor = hit ? 'pointer' : '';
74
+ });
75
+
76
+ return () => map.removeInteraction(select);
77
+ }, [map, selectStyle, onFeatureSelect]);
78
+
79
+ return null;
80
+ }