@eeacms/volto-cca-policy 0.1.17 → 0.1.19
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 +68 -1
- package/package.json +3 -2
- package/src/components/manage/Blocks/CaseStudyExplorer/InfoOverlay.jsx +2 -0
- package/src/components/manage/Blocks/CountryMap/CountryMapEdit.js +5 -0
- package/src/components/manage/Blocks/CountryMap/CountryMapView.js +444 -0
- package/src/components/manage/Blocks/CountryMap/euro-countries-simplified.js +46195 -0
- package/src/components/manage/Blocks/CountryMap/flags.js +57 -0
- package/src/components/manage/Blocks/CountryMap/index.js +16 -0
- package/src/components/manage/Blocks/CountryMap/styles.css +49 -0
- package/src/components/manage/Blocks/FilterAceContent/FilterAceContentEdit.jsx +38 -5
- package/src/components/manage/Blocks/FilterAceContent/FilterAceContentView.jsx +197 -26
- package/src/components/manage/Blocks/FilterAceContent/index.js +1 -1
- package/src/components/manage/Blocks/FilterAceContent/schema.js +106 -101
- package/src/components/manage/Blocks/FilterAceContent/style.less +3 -0
- package/src/components/manage/Blocks/RASTBlock/RAST.svg +67 -0
- package/src/components/manage/Blocks/RASTBlock/RASTEdit.jsx +32 -0
- package/src/components/manage/Blocks/RASTBlock/RASTView.jsx +356 -0
- package/src/components/manage/Blocks/RASTBlock/index.js +22 -0
- package/src/components/manage/Blocks/RASTBlock/schema.js +48 -0
- package/src/components/manage/Blocks/RASTBlock/styles.less +15 -0
- package/src/components/manage/Blocks/RelevantAceContent/RelevantAceContentView.jsx +3 -5
- package/src/components/manage/Blocks/RelevantAceContent/index.js +1 -1
- package/src/components/manage/Blocks/RelevantAceContent/schema.js +1 -1
- package/src/components/manage/Blocks/SearchAceContent/SearchAceContentView.jsx +1 -3
- package/src/components/manage/Blocks/SearchAceContent/schema.js +1 -1
- package/src/components/manage/Blocks/TransRegionSelect/TransRegionSelectEdit.jsx +32 -0
- package/src/components/manage/Blocks/TransRegionSelect/TransRegionSelectView.jsx +124 -0
- package/src/components/manage/Blocks/TransRegionSelect/countries.js +170 -0
- package/src/components/manage/Blocks/TransRegionSelect/index.js +22 -0
- package/src/components/manage/Blocks/TransRegionSelect/schema.js +16 -0
- package/src/components/manage/Blocks/index.js +8 -0
- package/src/customizations/volto/components/theme/Header/Header.jsx +41 -107
- package/src/helpers/Constants.jsx +2 -0
- package/src/helpers/clientOnly.js +7 -0
- package/src/helpers/index.js +2 -0
- package/src/index.js +51 -14
- package/src/search/config.js +27 -1
- package/src/search/facets.js +150 -56
- package/theme/extras/contextNavigation.overrides +54 -54
- package/theme/globals/site.overrides +15 -1
- package/src/customizations/volto/components/theme/Header/HeaderMain.jsx +0 -190
- package/src/customizations/volto/components/theme/Header/HeaderMenuPopUp.js +0 -373
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,74 @@ 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.
|
|
7
|
+
### [0.1.19](https://github.com/eea/volto-cca-policy/compare/0.1.18...0.1.19) - 7 June 2023
|
|
8
|
+
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#### :hammer_and_wrench: Others
|
|
13
|
+
|
|
14
|
+
- Comment junk [Tiberiu Ichim - [`2951a7e`](https://github.com/eea/volto-cca-policy/commit/2951a7e1063595d512c64308c6df67fa270d8b17)]
|
|
15
|
+
- cca show counter for all [Tripon Eugen - [`7fb70d0`](https://github.com/eea/volto-cca-policy/commit/7fb70d0060e14019f5c4f655447d908c3d54188a)]
|
|
16
|
+
- Add missing useEffect dependency [Tiberiu Ichim - [`954df35`](https://github.com/eea/volto-cca-policy/commit/954df35ce84a89422d21ada979442b5063eda391)]
|
|
17
|
+
- Remove console.log [Tiberiu Ichim - [`79de9fd`](https://github.com/eea/volto-cca-policy/commit/79de9fd35241ab83012b81e9073d901686c61292)]
|
|
18
|
+
- Dynamic import [Tiberiu Ichim - [`200ab64`](https://github.com/eea/volto-cca-policy/commit/200ab648cdeaf59b13ac3580da1f9e24900506f1)]
|
|
19
|
+
- Fix import [Tiberiu Ichim - [`973ece8`](https://github.com/eea/volto-cca-policy/commit/973ece8bbd1a56dbba29b2efecd5b17280143eea)]
|
|
20
|
+
- Rename json to js [Tiberiu Ichim - [`3c23c18`](https://github.com/eea/volto-cca-policy/commit/3c23c1831952831bf3ba1b490d81f9fe4f36c515)]
|
|
21
|
+
- dos2unix [Tiberiu Ichim - [`19e39f7`](https://github.com/eea/volto-cca-policy/commit/19e39f71d3a0b09318966db5626be8560dcc6300)]
|
|
22
|
+
- Format json file [Tiberiu Ichim - [`f7620d8`](https://github.com/eea/volto-cca-policy/commit/f7620d8a8aa8959e231a1e320822efc48fc2eba6)]
|
|
23
|
+
- cca mission search path [Tripon Eugen - [`20379e9`](https://github.com/eea/volto-cca-policy/commit/20379e97aec8bfc725b1dfa253e83113a51f6111)]
|
|
24
|
+
- Eslint [Tiberiu Ichim - [`e2a931b`](https://github.com/eea/volto-cca-policy/commit/e2a931bd70d78eed3c725fadfb3e351b14eadfe8)]
|
|
25
|
+
- Prettier [kreafox - [`db81941`](https://github.com/eea/volto-cca-policy/commit/db81941f2ece8d78a2a5f455c73d4192733337c7)]
|
|
26
|
+
- RAST: Make active state work on substeps [kreafox - [`df54655`](https://github.com/eea/volto-cca-policy/commit/df54655df2be166d3859400727b0ce5d2b6b3246)]
|
|
27
|
+
- Add hover and active state on RAST block [kreafox - [`5fb25ea`](https://github.com/eea/volto-cca-policy/commit/5fb25eac21311c9ca79c42e3c8f077a494f054f3)]
|
|
28
|
+
- Add missing file [Tiberiu Ichim - [`b490f4a`](https://github.com/eea/volto-cca-policy/commit/b490f4a8c0153c81b305e422d706897b585edf5b)]
|
|
29
|
+
- WIP on rast block [Tiberiu Ichim - [`8c4668b`](https://github.com/eea/volto-cca-policy/commit/8c4668bbad499ff4690861d4fbb73f86f929a8cd)]
|
|
30
|
+
- Improve condition for setting external routes using an ENV var. [GhitaB - [`674693e`](https://github.com/eea/volto-cca-policy/commit/674693e266a9088176bda187cf50b3c2f9e170ba)]
|
|
31
|
+
- WIP RAST block [kreafox - [`fd4f18a`](https://github.com/eea/volto-cca-policy/commit/fd4f18ab053c0ae0abcc17c49665631904033efc)]
|
|
32
|
+
- cca mission search portal types permanentFilter [Tripon Eugen - [`4b97280`](https://github.com/eea/volto-cca-policy/commit/4b972809ec8d8fb6c6a21cff6c875a44502b342f)]
|
|
33
|
+
- cca mission search config updates [Tripon Eugen - [`e9b7df5`](https://github.com/eea/volto-cca-policy/commit/e9b7df51af1550a445dd7f409b68bdbfcbef4cec)]
|
|
34
|
+
- Remove context nav custom style [kreafox - [`f5be52f`](https://github.com/eea/volto-cca-policy/commit/f5be52f7215f6c21fafc635abb0373a855478fd1)]
|
|
35
|
+
- Change heading in ace content blocks [kreafox - [`1afb621`](https://github.com/eea/volto-cca-policy/commit/1afb621e0324966e6d9a5b84a96bd2e7d36a6243)]
|
|
36
|
+
- cca search show only mission items [Tripon Eugen - [`45906cb`](https://github.com/eea/volto-cca-policy/commit/45906cba7d5ebe108ccef98cd38fcef3277b02a0)]
|
|
37
|
+
- Update context nav locations [kreafox - [`15c0bb3`](https://github.com/eea/volto-cca-policy/commit/15c0bb3a215f986437f1890b17f45b23b42ac669)]
|
|
38
|
+
- Fix contextnavigation [Tiberiu Ichim - [`14ac468`](https://github.com/eea/volto-cca-policy/commit/14ac468ab5fe52ddee6012e8d74a03cf2743194c)]
|
|
39
|
+
- Fix permanentFilters [Tiberiu Ichim - [`5f326c8`](https://github.com/eea/volto-cca-policy/commit/5f326c843f2c0345a968006cca0428c5a5682f2f)]
|
|
40
|
+
- Bring back Header override for mission logo [kreafox - [`c86896b`](https://github.com/eea/volto-cca-policy/commit/c86896b2616728eb1967fcc75b537eb89310f786)]
|
|
41
|
+
- cca search headers and add filter [Tripon Eugen - [`0cef408`](https://github.com/eea/volto-cca-policy/commit/0cef408038397255999d0a900e2b585c2d4b7fff)]
|
|
42
|
+
- Update context navigation locations [kreafox - [`74debb2`](https://github.com/eea/volto-cca-policy/commit/74debb25737c365bc09dab55ff9a7c54c26a37e0)]
|
|
43
|
+
- Add responsive container [Tiberiu Ichim - [`a76ca88`](https://github.com/eea/volto-cca-policy/commit/a76ca886e56117d086a28531c9f629a19c6cb9d1)]
|
|
44
|
+
- Remove layout settings block override on restriction [kreafox - [`e0bf0f8`](https://github.com/eea/volto-cca-policy/commit/e0bf0f80d9475f53d416e79f3da053812a40b514)]
|
|
45
|
+
- add breadcrumbs to apiExpanders, fixes breadcrumbs in the /contents view [Tiberiu Ichim - [`10a17f2`](https://github.com/eea/volto-cca-policy/commit/10a17f270b267985dd078a9470329d1d15254813)]
|
|
46
|
+
- Fix clicking in overlay [Tiberiu Ichim - [`442d726`](https://github.com/eea/volto-cca-policy/commit/442d7264c738179b0411dda6f3ee9341b356d5e1)]
|
|
47
|
+
- Enable layout settings block [kreafox - [`e7c3741`](https://github.com/eea/volto-cca-policy/commit/e7c37419bb74e3590d3676d83f774bc6923e417e)]
|
|
48
|
+
- Refs #251121 - facets update [Tripon Eugen - [`80a44c7`](https://github.com/eea/volto-cca-policy/commit/80a44c7a37ce0dd04b82cfdde748aca72c642f38)]
|
|
49
|
+
- testing volto search [Tripon Eugen - [`0fbe836`](https://github.com/eea/volto-cca-policy/commit/0fbe836345cf0ca8d8765f8df6b8e3914bdc6d3d)]
|
|
50
|
+
- Add clientOnly wrapper [Tiberiu Ichim - [`b82818a`](https://github.com/eea/volto-cca-policy/commit/b82818ab02f1867931fbd9e206382878d8652fb6)]
|
|
51
|
+
- test CountryMap [Tripon Eugen - [`718cd95`](https://github.com/eea/volto-cca-policy/commit/718cd95578bda3efcf6fcf3e7ebdc8a2aebc893e)]
|
|
52
|
+
- Lazyload d3 [Tiberiu Ichim - [`1846032`](https://github.com/eea/volto-cca-policy/commit/1846032bef84b6c623d03f964d63bbc22ea4cd78)]
|
|
53
|
+
- test d3 [Tripon Eugen - [`1bfc89c`](https://github.com/eea/volto-cca-policy/commit/1bfc89c54294cb1dc70d1c7a6e2ad69a49c2c88f)]
|
|
54
|
+
### [0.1.18](https://github.com/eea/volto-cca-policy/compare/0.1.17...0.1.18) - 18 May 2023
|
|
55
|
+
|
|
56
|
+
#### :hammer_and_wrench: Others
|
|
57
|
+
|
|
58
|
+
- Small Improvement on region select [kreafox - [`1221718`](https://github.com/eea/volto-cca-policy/commit/1221718978f8b20e6cf58bb984f9c9d85b691e83)]
|
|
59
|
+
- Fix region name [kreafox - [`aa8b266`](https://github.com/eea/volto-cca-policy/commit/aa8b26631cf104fabe1a0040a4c0b52f5d5650ca)]
|
|
60
|
+
- Fix case on other regions [kreafox - [`fac6535`](https://github.com/eea/volto-cca-policy/commit/fac653548863808958b422ce669878d1e50d9797)]
|
|
61
|
+
- Fix regions name [kreafox - [`5107f8b`](https://github.com/eea/volto-cca-policy/commit/5107f8b25add8b647debcaa032b9224b147fe6e6)]
|
|
62
|
+
- Refs #252182 - Get rid of listing custom organisation cards. [GhitaB - [`467faaf`](https://github.com/eea/volto-cca-policy/commit/467faafafe3692da58a85a7af95bd508114f7689)]
|
|
63
|
+
- Fix mobile menu background color [kreafox - [`ae00bd8`](https://github.com/eea/volto-cca-policy/commit/ae00bd877f6d2c62fcc6fad13e3151850003aa3e)]
|
|
64
|
+
- Refs #252182 - WIP Custom listing variation for organisation cards. [GhitaB - [`2ebca9a`](https://github.com/eea/volto-cca-policy/commit/2ebca9a3a45ba4f20ebc29b27d9f1a626611760c)]
|
|
65
|
+
- Refs #252182 - WIP Custom listing variation for organisation cards. [GhitaB - [`c638573`](https://github.com/eea/volto-cca-policy/commit/c63857327c582a9dace952e8cabf902096f8ff09)]
|
|
66
|
+
- Fix region name [kreafox - [`6baa26a`](https://github.com/eea/volto-cca-policy/commit/6baa26a32ebdb0c7ec5d91007abcb0e7d206c3f2)]
|
|
67
|
+
- Add trans region select block [kreafox - [`b95f6b3`](https://github.com/eea/volto-cca-policy/commit/b95f6b3cca8075a7a1e6a23ee14010a2d5a07d5b)]
|
|
68
|
+
- Fix macro regions [kreafox - [`388b443`](https://github.com/eea/volto-cca-policy/commit/388b4438b812a42e0f7be1e3d8b023befc21b5ab)]
|
|
69
|
+
- Set default nr of items [kreafox - [`286e83b`](https://github.com/eea/volto-cca-policy/commit/286e83b1cd17d31e749b58583fbe4efcaee47fe2)]
|
|
70
|
+
- Filter block styling [kreafox - [`b718171`](https://github.com/eea/volto-cca-policy/commit/b718171d429e011d372008a8a38de456066915d1)]
|
|
71
|
+
- Code cleanup [kreafox - [`be09233`](https://github.com/eea/volto-cca-policy/commit/be092333735f9c50c1fdcbdcbfdc28f8a3056350)]
|
|
72
|
+
- Make itemModel work [Tiberiu Ichim - [`8fed2bc`](https://github.com/eea/volto-cca-policy/commit/8fed2bce3f777b705ebca06abd58826f744530c3)]
|
|
73
|
+
- WIP filter ace content block [kreafox - [`3f8b97e`](https://github.com/eea/volto-cca-policy/commit/3f8b97e62bb8bb5c93e4b26b61c982efdb5a47c7)]
|
|
74
|
+
### [0.1.17](https://github.com/eea/volto-cca-policy/compare/0.1.16...0.1.17) - 2 May 2023
|
|
8
75
|
|
|
9
76
|
#### :hammer_and_wrench: Others
|
|
10
77
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-cca-policy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
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",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@eeacms/volto-eea-design-system": "*",
|
|
26
26
|
"@eeacms/volto-globalsearch": "*",
|
|
27
|
-
"@eeacms/volto-openlayers-map": "*"
|
|
27
|
+
"@eeacms/volto-openlayers-map": "*",
|
|
28
|
+
"d3": "3"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@cypress/code-coverage": "^3.10.0",
|
|
@@ -45,6 +45,8 @@ export default function InfoOverlay({
|
|
|
45
45
|
overlay.setPosition(coordinate);
|
|
46
46
|
setShowTooltip(true);
|
|
47
47
|
} else {
|
|
48
|
+
// handle a click in an overlay popup
|
|
49
|
+
if (evt.originalEvent.target.tagName === 'A') return;
|
|
48
50
|
setShowTooltip(false);
|
|
49
51
|
onFeatureSelect(null);
|
|
50
52
|
}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
//import * as d3 from 'd3';
|
|
3
|
+
// import cpath from './euro-countries-simplified';
|
|
4
|
+
import flags from './flags.js';
|
|
5
|
+
import './styles.css';
|
|
6
|
+
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
7
|
+
import { compose } from 'redux';
|
|
8
|
+
import { clientOnly } from '@eeacms/volto-cca-policy/helpers';
|
|
9
|
+
// import loadable from '@loadable/component';
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
const withResponsiveContainer = (WrappedComponent) => {
|
|
13
|
+
return (props) => {
|
|
14
|
+
const [size, setSize] = React.useState();
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
className="sized-wrapper"
|
|
18
|
+
ref={(node) => {
|
|
19
|
+
// console.log(node, node.clientHeight);
|
|
20
|
+
if (node && !size)
|
|
21
|
+
setSize({ height: node.clientHeight, width: node.clientWidth });
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{size ? <WrappedComponent size={size} {...props} /> : null}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const CountryMapView = (props) => {
|
|
31
|
+
const svgRef = useRef(null);
|
|
32
|
+
const { d3, size } = props;
|
|
33
|
+
const { height, width } = size;
|
|
34
|
+
let [cpath, setCpath] = React.useState();
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!cpath) {
|
|
38
|
+
import('./euro-countries-simplified').then((mod) => {
|
|
39
|
+
setCpath(mod.default);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [cpath]);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
// D3 Code
|
|
46
|
+
|
|
47
|
+
// Dimensions
|
|
48
|
+
//const parentDiv = document.getElementById('page-document');
|
|
49
|
+
let dimensions = {
|
|
50
|
+
//width: parentDiv.offsetWidth,
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
margins: 50,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
dimensions.containerWidth = dimensions.width - dimensions.margins * 2;
|
|
57
|
+
dimensions.containerHeight = dimensions.height - dimensions.margins * 2;
|
|
58
|
+
|
|
59
|
+
//const d3 = loadable.lib(() => import('d3'));
|
|
60
|
+
// SELECTIONS
|
|
61
|
+
const svg = d3
|
|
62
|
+
.select(svgRef.current)
|
|
63
|
+
.attr('id', 'country_map')
|
|
64
|
+
//.classed("line-chart", true)
|
|
65
|
+
.attr('width', dimensions.width)
|
|
66
|
+
.attr('height', dimensions.height);
|
|
67
|
+
//console.log('SVG x-y', svg.getBBox());
|
|
68
|
+
/*
|
|
69
|
+
const container = svg
|
|
70
|
+
.append('g')
|
|
71
|
+
.classed('container', true)
|
|
72
|
+
.attr(
|
|
73
|
+
'transform',
|
|
74
|
+
`translate(${dimensions.margins}, ${dimensions.margins})`,
|
|
75
|
+
);
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
cpath.features = cpath.features.map(function (c) {
|
|
79
|
+
//console.log(c);
|
|
80
|
+
var name = c.properties.SHRT_ENGL;
|
|
81
|
+
if (!name) {
|
|
82
|
+
// console.log('No flag for', c.properties);
|
|
83
|
+
return c;
|
|
84
|
+
} else if (name === 'Czechia') {
|
|
85
|
+
name = 'Czech Republic';
|
|
86
|
+
}
|
|
87
|
+
var cname = name.replace(' ', '_');
|
|
88
|
+
flags.forEach(function (f) {
|
|
89
|
+
if (f.indexOf(cname) > -1) {
|
|
90
|
+
c.url = f;
|
|
91
|
+
//console.log(c.url);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return c;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
//console.log('cpath', cpath);
|
|
98
|
+
//console.log(fpath);
|
|
99
|
+
//console.log('Flags',flags);
|
|
100
|
+
//console.log('filtered', getFocusCountriesFeature(cpath));
|
|
101
|
+
|
|
102
|
+
window.countrySettings = cpath.features;
|
|
103
|
+
|
|
104
|
+
var opts = {
|
|
105
|
+
world: cpath.features,
|
|
106
|
+
svg: svg,
|
|
107
|
+
coordinates: {
|
|
108
|
+
x: 0,
|
|
109
|
+
y: 0,
|
|
110
|
+
width: dimensions.containerWidth,
|
|
111
|
+
height: dimensions.containerHeight,
|
|
112
|
+
},
|
|
113
|
+
focusCountries: {
|
|
114
|
+
names: getFocusCountryNames(),
|
|
115
|
+
feature: getFocusCountriesFeature(cpath),
|
|
116
|
+
},
|
|
117
|
+
zoom: 0.95,
|
|
118
|
+
};
|
|
119
|
+
renderCountriesBox(opts, d3);
|
|
120
|
+
// Draw Circle
|
|
121
|
+
//container.append("circle").attr("r", 25).style("color","blue");
|
|
122
|
+
}, [props.Data, d3, width, height, cpath]); // redraw chart if data changes
|
|
123
|
+
|
|
124
|
+
return <svg ref={svgRef} />;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function getFocusCountryNames() {
|
|
128
|
+
return [
|
|
129
|
+
'Austria',
|
|
130
|
+
'Belgium',
|
|
131
|
+
'Cyprus',
|
|
132
|
+
'Czechia',
|
|
133
|
+
'Denmark',
|
|
134
|
+
'Estonia',
|
|
135
|
+
'Finland',
|
|
136
|
+
'France',
|
|
137
|
+
'Germany',
|
|
138
|
+
'Greece',
|
|
139
|
+
'Hungary',
|
|
140
|
+
'Iceland',
|
|
141
|
+
'Ireland',
|
|
142
|
+
'Italy',
|
|
143
|
+
'Lithuania',
|
|
144
|
+
'Luxembourg',
|
|
145
|
+
'Malta',
|
|
146
|
+
'Netherlands',
|
|
147
|
+
'Poland',
|
|
148
|
+
'Portugal',
|
|
149
|
+
'Romania',
|
|
150
|
+
'Slovakia',
|
|
151
|
+
'Slovenia',
|
|
152
|
+
'Spain',
|
|
153
|
+
'Sweden',
|
|
154
|
+
'United Kingdom',
|
|
155
|
+
'Liechtenstein',
|
|
156
|
+
'Norway',
|
|
157
|
+
'Switzerland',
|
|
158
|
+
'Turkey',
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
function getFocusCountriesFeature(world) {
|
|
162
|
+
const focusCountryNames = getFocusCountryNames();
|
|
163
|
+
let features = {
|
|
164
|
+
type: 'FeatureCollection',
|
|
165
|
+
features: [],
|
|
166
|
+
};
|
|
167
|
+
world.features.forEach(function (c) {
|
|
168
|
+
if (focusCountryNames.indexOf(c.properties.SHRT_ENGL) === -1) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
features.features.push(c);
|
|
172
|
+
});
|
|
173
|
+
return features;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function renderCountriesBox(opts, d3) {
|
|
177
|
+
var coords = opts.coordinates;
|
|
178
|
+
var countries = opts.focusCountries;
|
|
179
|
+
|
|
180
|
+
var svg = opts.svg;
|
|
181
|
+
var world = opts.world;
|
|
182
|
+
var zoom = opts.zoom;
|
|
183
|
+
var cprectid = makeid(); // unique id for this map drawing
|
|
184
|
+
|
|
185
|
+
var globalMapProjection = d3.geoAzimuthalEqualArea();
|
|
186
|
+
|
|
187
|
+
globalMapProjection.scale(1).translate([0, 0]);
|
|
188
|
+
|
|
189
|
+
// the path transformer
|
|
190
|
+
var path = d3.geoPath().projection(globalMapProjection);
|
|
191
|
+
|
|
192
|
+
var x = coords.x;
|
|
193
|
+
var y = coords.y;
|
|
194
|
+
var width = coords.width;
|
|
195
|
+
var height = coords.height;
|
|
196
|
+
// var extent = [[x + 20, y + 20], [x + coords.width - 20 , y + coords.height - 20]];
|
|
197
|
+
// console.log('fitting extent', extent);
|
|
198
|
+
// globalMapProjection.fitExtent(extent, countries.feature);
|
|
199
|
+
|
|
200
|
+
var b = path.bounds(countries.feature);
|
|
201
|
+
var cwRatio = (b[1][0] - b[0][0]) / width; // bounds to width ratio
|
|
202
|
+
var chRatio = (b[1][1] - b[0][1]) / height; // bounds to height ratio
|
|
203
|
+
var s = zoom / Math.max(cwRatio, chRatio);
|
|
204
|
+
var t = [
|
|
205
|
+
(width - s * (b[1][0] + b[0][0])) / 2 + x,
|
|
206
|
+
(height - s * (b[0][1] + b[1][1])) / 2 + y,
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
globalMapProjection.scale(s).translate(t);
|
|
210
|
+
|
|
211
|
+
svg
|
|
212
|
+
.append('defs') // rectangular clipping path for the whole drawn map
|
|
213
|
+
.append('clipPath')
|
|
214
|
+
.attr('id', cprectid)
|
|
215
|
+
.append('rect')
|
|
216
|
+
.attr('x', x)
|
|
217
|
+
.attr('y', y)
|
|
218
|
+
.attr('height', height)
|
|
219
|
+
.attr('width', width);
|
|
220
|
+
|
|
221
|
+
var map = svg // the map will be drawn in this group
|
|
222
|
+
.append('g');
|
|
223
|
+
// .attr('clip-path', 'url(#' + cprectid + ')')
|
|
224
|
+
//.attr("clip-path", opts.isMaplet ? "url(#" + cprectid + ")" : null
|
|
225
|
+
map // the world sphere, acts as ocean
|
|
226
|
+
.append('path')
|
|
227
|
+
.datum({
|
|
228
|
+
type: 'Sphere',
|
|
229
|
+
})
|
|
230
|
+
.attr('class', 'sphere')
|
|
231
|
+
.attr('d', path);
|
|
232
|
+
|
|
233
|
+
renderGraticule(map, 'graticule', [20, 10], path, d3);
|
|
234
|
+
renderGraticule(map, 'semi-graticule', [5, 5], path, d3);
|
|
235
|
+
|
|
236
|
+
//setCountryFlags(countries.feature.features, window._flags);
|
|
237
|
+
|
|
238
|
+
world.forEach(function (country) {
|
|
239
|
+
renderCountry(map, country, path, countries, x, y, d3);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
return path;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function renderGraticule(container, klass, steps, pathTransformer, d3) {
|
|
246
|
+
container // draw primary graticule lines
|
|
247
|
+
.append('g')
|
|
248
|
+
.attr('class', klass)
|
|
249
|
+
.selectAll('path')
|
|
250
|
+
.data(d3.geoGraticule().step(steps).lines())
|
|
251
|
+
.enter()
|
|
252
|
+
.append('path')
|
|
253
|
+
.attr('d', pathTransformer);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function makeid() {
|
|
257
|
+
var text = '';
|
|
258
|
+
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
259
|
+
|
|
260
|
+
for (var i = 0; i < 5; i++)
|
|
261
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
262
|
+
|
|
263
|
+
return text;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function renderCountry(map, country, path, countries, x, y, d3) {
|
|
267
|
+
var cprectid = makeid(); // unique id for this map drawing
|
|
268
|
+
var klass = getCountryClass(country, countries);
|
|
269
|
+
var cId = 'c-' + cprectid + '-' + country.properties.id;
|
|
270
|
+
var cpId = 'cp-' + cprectid + '-' + country.properties.id;
|
|
271
|
+
|
|
272
|
+
var available = countries.names.indexOf(country.properties.SHRT_ENGL) !== -1;
|
|
273
|
+
|
|
274
|
+
var parent = map.append('g').attr('class', klass);
|
|
275
|
+
parent // define clipping path for this country
|
|
276
|
+
.append('defs')
|
|
277
|
+
.append('clipPath')
|
|
278
|
+
.attr('id', cpId)
|
|
279
|
+
.append('path')
|
|
280
|
+
.attr('d', path(country))
|
|
281
|
+
.attr('x', x)
|
|
282
|
+
.attr('y', y);
|
|
283
|
+
|
|
284
|
+
var outline = parent // this is the country fill and outline
|
|
285
|
+
.append('path')
|
|
286
|
+
.attr('id', cId)
|
|
287
|
+
.attr('x', x)
|
|
288
|
+
.attr('y', y)
|
|
289
|
+
.attr('d', path(country));
|
|
290
|
+
if (available) {
|
|
291
|
+
var bbox = outline.node().getBBox();
|
|
292
|
+
renderCountryFlag(parent, country, bbox, cpId, d3);
|
|
293
|
+
//renderCountryLabel(country, path);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function getCountryClass(country, countries) {
|
|
298
|
+
//console.log('getCountryClass',country, countries);
|
|
299
|
+
var k = 'country-outline';
|
|
300
|
+
//var k = "country-blue";
|
|
301
|
+
//var available =
|
|
302
|
+
//window.countrySettings.indexOf(country.properties.SHRT_ENGL) !== -1;
|
|
303
|
+
//if (available) k += " country-available";
|
|
304
|
+
|
|
305
|
+
//var meta = window.countrySettings[country.properties.SHRT_ENGL];
|
|
306
|
+
//var _selectedMapSection = null;
|
|
307
|
+
|
|
308
|
+
if (getFocusCountryNames().includes(country.properties.SHRT_ENGL)) {
|
|
309
|
+
k += ' country-available';
|
|
310
|
+
}
|
|
311
|
+
//if (available && meta && meta[0] && meta[0][_selectedMapSection]) {
|
|
312
|
+
// k += " country-blue";
|
|
313
|
+
//}
|
|
314
|
+
return k;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function renderCountryLabel(country, path, force, d3) {
|
|
318
|
+
var parent = d3.select('.svg-map-container svg');
|
|
319
|
+
var klass = force ? 'country-label maplet-label' : 'country-label';
|
|
320
|
+
var g = parent.append('g').attr('class', klass);
|
|
321
|
+
if (
|
|
322
|
+
// these are very small countries that we will create a maplet for;
|
|
323
|
+
(country.properties.SHRT_ENGL === 'Liechtenstein' ||
|
|
324
|
+
country.properties.SHRT_ENGL === 'Luxembourg' ||
|
|
325
|
+
country.properties.SHRT_ENGL === 'Malta') &&
|
|
326
|
+
!force
|
|
327
|
+
) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
var delta = force ? 20 : 0;
|
|
332
|
+
|
|
333
|
+
var pId = 'pl-' + country.id;
|
|
334
|
+
var center = path.centroid(country);
|
|
335
|
+
// console.log(center, path);
|
|
336
|
+
|
|
337
|
+
var label = g
|
|
338
|
+
.append('text')
|
|
339
|
+
// .attr('class', 'place-label')
|
|
340
|
+
.attr('id', pId)
|
|
341
|
+
.attr('x', center[0])
|
|
342
|
+
.attr('y', center[1] + delta)
|
|
343
|
+
.attr('text-anchor', 'middle')
|
|
344
|
+
.text(country.properties.SHRT_ENGL.toUpperCase());
|
|
345
|
+
var bbox = label.node().getBBox();
|
|
346
|
+
|
|
347
|
+
g.append('rect')
|
|
348
|
+
// .attr('class', 'place-label-bg')
|
|
349
|
+
.attr('x', bbox.x - 1)
|
|
350
|
+
.attr('y', bbox.y - 1)
|
|
351
|
+
.attr('width', bbox.width + 2)
|
|
352
|
+
.attr('height', bbox.height + 2);
|
|
353
|
+
|
|
354
|
+
label.raise();
|
|
355
|
+
//passThruEvents(g);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// tooltip with country names on hover
|
|
359
|
+
/*
|
|
360
|
+
var countryNameTooltip = d3
|
|
361
|
+
.select('body')
|
|
362
|
+
.append('div')
|
|
363
|
+
.attr('class', 'tooltip');
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
function renderCountryFlag(parent, country, bbox, cpId, d3) {
|
|
367
|
+
var flag = parent
|
|
368
|
+
.append('image')
|
|
369
|
+
.attr('class', 'country-flag')
|
|
370
|
+
.attr('href', function () {
|
|
371
|
+
if (getIEVersion() > 0) {
|
|
372
|
+
return '++theme++climateadaptv2/static/images/fallback.svg';
|
|
373
|
+
} else {
|
|
374
|
+
return country.url;
|
|
375
|
+
}
|
|
376
|
+
})
|
|
377
|
+
.attr('preserveAspectRatio', 'none')
|
|
378
|
+
.attr('opacity', '0')
|
|
379
|
+
.attr('clip-path', 'url(#' + cpId + ')')
|
|
380
|
+
.attr('x', bbox.x)
|
|
381
|
+
.attr('y', bbox.y)
|
|
382
|
+
|
|
383
|
+
.attr('height', bbox.height)
|
|
384
|
+
.attr('width', bbox.width)
|
|
385
|
+
.on('click', function () {
|
|
386
|
+
// var link = country.properties.SHRT_ENGL.toLowerCase().replace(' ', '-');
|
|
387
|
+
// if (getFocusCountryNames().indexOf(country.properties.SHRT_ENGL) > -1)
|
|
388
|
+
// // console.log('will redirect to country:', link);
|
|
389
|
+
// //location.href = location.href.endsWith('/') ? location.href + link : location.href + '/' + link;
|
|
390
|
+
// console.log(
|
|
391
|
+
// window.location.href.endsWith('/')
|
|
392
|
+
// ? window.location.href + link
|
|
393
|
+
// : window.location.href + '/' + link,
|
|
394
|
+
// );
|
|
395
|
+
})
|
|
396
|
+
.on('mouseover', function () {
|
|
397
|
+
// var countryName = country.properties.SHRT_ENGL.toUpperCase();
|
|
398
|
+
d3.select(this).attr('opacity', 1);
|
|
399
|
+
//return countryNameTooltip.style('display', 'block').html(countryName);
|
|
400
|
+
})
|
|
401
|
+
.on('mousemove', function (event) {
|
|
402
|
+
// var countryName = country.properties.SHRT_ENGL.toUpperCase();
|
|
403
|
+
//console.log(event, d3.select(this));
|
|
404
|
+
//console.log(event.screenX, event.screenY, event, d3.select(this),this.getAttribute("cx"));
|
|
405
|
+
//console.log(d3.mouse(this));
|
|
406
|
+
// var bbox = this.getBBox();
|
|
407
|
+
/*
|
|
408
|
+
const cmt = countryNameTooltip
|
|
409
|
+
.style('display', 'block')
|
|
410
|
+
//.style("top", event.layerY+ "px")
|
|
411
|
+
//.style("left", event.layerX+ 10 + "px")
|
|
412
|
+
.style('top', event.layerY + bbox.height + 'px')
|
|
413
|
+
.style('left', event.layerX + 50 + 'px')
|
|
414
|
+
//.style("top", d3.currentEvent.pageY + "px")
|
|
415
|
+
//.style("left", d3.currentEvent.pageX + 10 + "px")
|
|
416
|
+
.html(countryName);
|
|
417
|
+
return cmt;
|
|
418
|
+
*/
|
|
419
|
+
})
|
|
420
|
+
.on('mouseout', function () {
|
|
421
|
+
d3.select(this).attr('opacity', 0);
|
|
422
|
+
//return countryNameTooltip.style('display', 'none');
|
|
423
|
+
});
|
|
424
|
+
return flag;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function getIEVersion() {
|
|
428
|
+
var sAgent = window.navigator.userAgent;
|
|
429
|
+
var Idx = sAgent.indexOf('MSIE');
|
|
430
|
+
|
|
431
|
+
// If IE, return version number.
|
|
432
|
+
if (Idx > 0)
|
|
433
|
+
return parseInt(sAgent.substring(Idx + 5, sAgent.indexOf('.', Idx)));
|
|
434
|
+
// If IE 11 then look for Updated user agent string.
|
|
435
|
+
else if (navigator.userAgent.match(/Trident\/7\./)) return 11;
|
|
436
|
+
else return 0; //It is not IE
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
//export default CountryMapView;
|
|
440
|
+
export default compose(
|
|
441
|
+
clientOnly,
|
|
442
|
+
injectLazyLibs(['d3']),
|
|
443
|
+
withResponsiveContainer,
|
|
444
|
+
)(CountryMapView);
|