@eeacms/volto-cca-policy 0.1.67 → 0.1.69

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,66 @@ 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.69](https://github.com/eea/volto-cca-policy/compare/0.1.68...0.1.69) - 31 January 2024
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Refs #161485 - observatory resource catalog menu [Tripon Eugen - [`31bbb1a`](https://github.com/eea/volto-cca-policy/commit/31bbb1a2bf361d7000d11d2f9665a9de50cd240f)]
12
+ - Refs #161485 - observatory resource catalog menu [Tripon Eugen - [`c2c31be`](https://github.com/eea/volto-cca-policy/commit/c2c31be706b255d58d08e2f9210bd2f1dc0b160b)]
13
+ ### [0.1.68](https://github.com/eea/volto-cca-policy/compare/0.1.67...0.1.68) - 30 January 2024
14
+
15
+ #### :bug: Bug Fixes
16
+
17
+ - fix: preview image in search listing [kreafox - [`77025e2`](https://github.com/eea/volto-cca-policy/commit/77025e2c65e73d2b25a85a3a601195cf5b654a45)]
18
+ - fix: stories search listing + show images [kreafox - [`04eac85`](https://github.com/eea/volto-cca-policy/commit/04eac854b915051534cec0f4c03cd86aca95ef75)]
19
+
20
+ #### :nail_care: Enhancements
21
+
22
+ - change: update icon [kreafox - [`5abd305`](https://github.com/eea/volto-cca-policy/commit/5abd305ad658e4a8bd8d2351a86448e4724ee287)]
23
+ - change: color in observatory search [kreafox - [`5711c4f`](https://github.com/eea/volto-cca-policy/commit/5711c4fc08a1e71fe74fb918da41e2f4cc173d7b)]
24
+ - change: separate mission styling [kreafox - [`4b4749a`](https://github.com/eea/volto-cca-policy/commit/4b4749abce6a871d3d595391f72520ae22bfeacf)]
25
+
26
+ #### :hammer_and_wrench: Others
27
+
28
+ - Refs #161485 - update icons [Tripon Eugen - [`91f0bee`](https://github.com/eea/volto-cca-policy/commit/91f0bee22c78854b0f4be2dcb56bf0d00a3bd6e5)]
29
+ - Refs #161485 - set portal types icons [Tripon Eugen - [`055f26a`](https://github.com/eea/volto-cca-policy/commit/055f26accc79ed56b10f539449e88d030171df3b)]
30
+ - Compute icons for clusters [Tiberiu Ichim - [`cdbe2cd`](https://github.com/eea/volto-cca-policy/commit/cdbe2cdda3b59110b136b0e947c0c97dc8965df6)]
31
+ - Refs #161485 - health impacts facet default sort order [Tripon Eugen - [`535ab04`](https://github.com/eea/volto-cca-policy/commit/535ab04547c00cdbf109c07a8c6cfe425ab04916)]
32
+ - Refs #161485 - filter test add one more [Tripon Eugen - [`fa93935`](https://github.com/eea/volto-cca-policy/commit/fa93935e380cfe13203a3a241b85102c3d48d36f)]
33
+ - Refs #161485 - filter test change check element [Tripon Eugen - [`e40a029`](https://github.com/eea/volto-cca-policy/commit/e40a02902e61338a1bacec8b1e17171194528c93)]
34
+ - Refs #161485 - filter test for sonarqube [Tripon Eugen - [`f764310`](https://github.com/eea/volto-cca-policy/commit/f7643109e63ebeb881d6ea825ba00eb7a2a18646)]
35
+ - Refs #161485 - filter test for sonarqube [Tripon Eugen - [`2b85fcc`](https://github.com/eea/volto-cca-policy/commit/2b85fcc99aaf5e030a982ea67c796bde28053552)]
36
+ - Refs #161485 - filter test for sonarqube [Tripon Eugen - [`2566360`](https://github.com/eea/volto-cca-policy/commit/25663608f5f851dec8a5d83d740008ebff5df233)]
37
+ - Refs #161485 - filter test for sonarqube [Tripon Eugen - [`b09873c`](https://github.com/eea/volto-cca-policy/commit/b09873c7f3b764030897bd042a3169b411b9deec)]
38
+ - Refs #161485 - filter test for sonarqube [Tripon Eugen - [`7df5146`](https://github.com/eea/volto-cca-policy/commit/7df5146e0f6b27accf8fd5a5964f5454c078900a)]
39
+ - Refs #161485 - sonarqube [Tripon Eugen - [`20b5781`](https://github.com/eea/volto-cca-policy/commit/20b5781e07ed0bbb0017ba4644122171dda4d6c5)]
40
+ - Refs #161485 - sonarqube [Tripon Eugen - [`26eab80`](https://github.com/eea/volto-cca-policy/commit/26eab80e3fd2ef1d8bcf7f7c1fc959598e90474a)]
41
+ - Refs #161485 - duplicated lines [Tripon Eugen - [`0b2f187`](https://github.com/eea/volto-cca-policy/commit/0b2f187771a9c9bb0a4eedb84d5ebdb4ccbe81aa)]
42
+ - Refs #161485 - update health facets [Tripon Eugen - [`2c132bb`](https://github.com/eea/volto-cca-policy/commit/2c132bb71822d8873cda6ffe562c0522e3f0c151)]
43
+ - Refs #161485 - update health facets from develop [Tripon Eugen - [`a974d79`](https://github.com/eea/volto-cca-policy/commit/a974d7988e558e4a02eca9807331740214854ea6)]
44
+ - Refs #161485 - facets comment custom sort [Tripon Eugen - [`80d78c9`](https://github.com/eea/volto-cca-policy/commit/80d78c9c9b9118ea505a42af47263d05748e52bf)]
45
+ - Refs #263399 - Fix eslint errors. [GhitaB - [`d0595d1`](https://github.com/eea/volto-cca-policy/commit/d0595d12018bdec0582370204aa8afce3cb1010b)]
46
+ - Refs #263399 - Fix eslint errors. [GhitaB - [`c881386`](https://github.com/eea/volto-cca-policy/commit/c8813864b93a53d5f581b33fee45140790834d51)]
47
+ - Add physical-breadcrumbs [Tiberiu Ichim - [`3f365f8`](https://github.com/eea/volto-cca-policy/commit/3f365f8c9529ff082b6599d0c425d7ef1bafc951)]
48
+ - Revert "test: Update jest,Jenkinsfile,lint to volto-addons-template PR30". [GhitaB - [`fd821d1`](https://github.com/eea/volto-cca-policy/commit/fd821d1629dca31bb2de6e06752e6e57d3d44651)]
49
+ - Improve code - fix duplicate common facets: objectProvides, language, issued_date. [GhitaB - [`935855a`](https://github.com/eea/volto-cca-policy/commit/935855a9e6a745ca598cf50f7fac216fd11ade08)]
50
+ - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`9533869`](https://github.com/eea/volto-cca-policy/commit/95338695df80637079e3b032cb40e9db8e678635)]
51
+ - Improve code - fix duplicate common facets: include_archived. [GhitaB - [`1a72756`](https://github.com/eea/volto-cca-policy/commit/1a7275684cefae5584a47c2af926bcd93243a934)]
52
+ - Improve code - fix duplicate common facets: include_archived. [GhitaB - [`1a3785a`](https://github.com/eea/volto-cca-policy/commit/1a3785a46cf912588ff68f62bdbf03f17012e550)]
53
+ - Improve code - fix duplicate /Blocks/withResponsiveContainer.js. [GhitaB - [`7d375f2`](https://github.com/eea/volto-cca-policy/commit/7d375f2ed38931be198f8c9d5c40366edc9c3185)]
54
+ - Improve code /components/theme/Views/CaseStudyView.jsx. [GhitaB - [`875f512`](https://github.com/eea/volto-cca-policy/commit/875f512eb1bed848ef76aa90700ba72ac63d01e9)]
55
+ - Clean code in Blocks/TransRegionSelect/countries.js. [GhitaB - [`2af2206`](https://github.com/eea/volto-cca-policy/commit/2af2206154f22a4bbbd8c25f8cd9aec0640a1df2)]
56
+ - Revert "test: Update jest,Jenkinsfile,lint to volto-addons-template PR30" [David Ichim - [`ab43cb2`](https://github.com/eea/volto-cca-policy/commit/ab43cb21236dc39d51e01003807f8f1020a4e64b)]
57
+ - Set main search as default [Tiberiu Ichim - [`2877ce4`](https://github.com/eea/volto-cca-policy/commit/2877ce43b178899df48fc655594a50d696ccc2ea)]
58
+ - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`9c94b78`](https://github.com/eea/volto-cca-policy/commit/9c94b78d04c18691fa04b9fdaaf61a052cbc89a6)]
59
+ - Fix custom facet values in health observatory [Tiberiu Ichim - [`c6ddacf`](https://github.com/eea/volto-cca-policy/commit/c6ddacf318e24b1b32cc58c2cda5b5acabd9ffad)]
60
+ - Comment code [Tiberiu Ichim - [`f552df1`](https://github.com/eea/volto-cca-policy/commit/f552df196f15e4d9726ec5f1060314a6f92f8e0f)]
61
+ - Fix facets for main search [Tiberiu Ichim - [`2defd05`](https://github.com/eea/volto-cca-policy/commit/2defd05596f490dd5b434a4f4a4156d423578f36)]
62
+ - Update menu for translated search menu (fix show children) [Ghiță Bizău - [`d03f8c3`](https://github.com/eea/volto-cca-policy/commit/d03f8c322790e67c91d0e58803640237444bdd52)]
63
+ - Add dependency on volto-searchlib [Tiberiu Ichim - [`955edee`](https://github.com/eea/volto-cca-policy/commit/955edee904da8cb0292b6ffef5c9f493101baf43)]
64
+ - Cleanup facets in cca search [Tiberiu Ichim - [`bf0e7cb`](https://github.com/eea/volto-cca-policy/commit/bf0e7cb7805b7844fe741d44b4b05ec29447d96d)]
65
+ - Refs #161485 - observatory search update settings [Tripon Eugen - [`06f483f`](https://github.com/eea/volto-cca-policy/commit/06f483fe95f1b791cbd20206099730175df945cf)]
66
+ - Refs #161485 - observatory search update settings [Tripon Eugen - [`b4f3530`](https://github.com/eea/volto-cca-policy/commit/b4f353025c52e2a85268750fb97074963bb2dd32)]
7
67
  ### [0.1.67](https://github.com/eea/volto-cca-policy/compare/0.1.66...0.1.67) - 26 January 2024
8
68
 
9
69
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.67",
3
+ "version": "0.1.69",
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",
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import configureStore from 'redux-mock-store';
4
+ import { render } from '@testing-library/react';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+ import { Provider } from 'react-intl-redux';
7
+ import Filter from './Filter';
8
+
9
+ const mockStore = configureStore();
10
+
11
+ describe('Filter', () => {
12
+ it('should render the component', () => {
13
+ const data = {
14
+ thematicMapMode: 'hhap',
15
+ setThematicMapMode(param) {
16
+ return param;
17
+ },
18
+ };
19
+
20
+ const store = mockStore({
21
+ userSession: { token: '1234' },
22
+ intl: {
23
+ locale: 'en',
24
+ messages: {},
25
+ },
26
+ });
27
+
28
+ const { container } = render(
29
+ <Provider store={store}>
30
+ <MemoryRouter>
31
+ <Filter {...data} />
32
+ </MemoryRouter>
33
+ </Provider>,
34
+ );
35
+ expect(container.querySelector('#sections-selector')).toBeInTheDocument();
36
+ });
37
+ });
@@ -7,11 +7,8 @@ import { compose } from 'redux';
7
7
  import { clientOnly } from '@eeacms/volto-cca-policy/helpers';
8
8
  import withResponsiveContainer from './../withResponsiveContainer.js';
9
9
  import { addAppURL } from '@plone/volto/helpers';
10
- import {
11
- getFocusCountriesFeature,
12
- getFocusCountryNames,
13
- renderCountriesBox,
14
- } from './map-utils.js';
10
+ import { getFocusCountryNames, renderCountriesBox } from './map-utils.js';
11
+ import { getFocusCountriesFeature } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
15
12
 
16
13
  import Filter from './Filter';
17
14
 
@@ -1,45 +1,9 @@
1
+ import {
2
+ euCountryNames,
3
+ removeTooltip,
4
+ } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
1
5
  export function getFocusCountryNames() {
2
- return [
3
- 'Albania',
4
- 'Austria',
5
- 'Belgium',
6
- 'Bosnia-Herzegovina',
7
- 'Bosnia and Herzegovina',
8
- 'Bulgaria',
9
- 'Cyprus',
10
- 'Croatia',
11
- 'Czechia',
12
- 'Denmark',
13
- 'Estonia',
14
- 'Finland',
15
- 'France',
16
- 'Germany',
17
- 'Greece',
18
- 'Hungary',
19
- 'Iceland',
20
- 'Ireland',
21
- 'Italy',
22
- 'Latvia',
23
- 'Lithuania',
24
- 'Luxembourg',
25
- 'Malta',
26
- 'Montenegro',
27
- 'Netherlands',
28
- 'North Macedonia',
29
- 'Poland',
30
- 'Portugal',
31
- 'Romania',
32
- 'Serbia',
33
- 'Slovakia',
34
- 'Slovenia',
35
- 'Spain',
36
- 'Sweden',
37
- 'United Kingdom',
38
- 'Liechtenstein',
39
- 'Norway',
40
- 'Switzerland',
41
- 'Turkey',
42
- ];
6
+ return euCountryNames;
43
7
  }
44
8
 
45
9
  export function getFocusCountriesFeature(world) {
@@ -123,9 +87,175 @@ export function renderCountriesBox(opts, d3, d3Geo) {
123
87
  renderCountry(map, country, path, countries, x, y, d3, countries_metadata);
124
88
  });
125
89
 
90
+ var mo = {
91
+ svg: svg,
92
+ world: world,
93
+ viewport: [width, height],
94
+ countries: ['Malta', 'Liechtenstein', 'Luxembourg'],
95
+ start: [width + 10, 10],
96
+ side: 'left',
97
+ // 'size': 80,
98
+ // 'space': 6,
99
+ };
100
+ drawMaplets(mo, d3);
101
+
126
102
  return path;
127
103
  }
128
104
 
105
+ function filterCountriesByNames(countries, filterIds) {
106
+ var features = {
107
+ type: 'FeatureCollection',
108
+ features: [],
109
+ };
110
+
111
+ // console.log('filterids', filterIds);
112
+ // filterIds has "Kosovo (under UNSCR 1244/99)" SHRT_ENGL is Kosovo
113
+ // filterIds has "Bosnia-Herzegovina", SHRT_ENGL is "Bosnia and Herzegovina"
114
+
115
+ // debugger;
116
+ countries.forEach(function (c) {
117
+ // var correct_name =
118
+ // correct_country_names[c.properties.SHRT_ENGL] || c.properties.SHRT_ENGL;
119
+ if (filterIds.indexOf(c.properties.SHRT_ENGL) === -1) {
120
+ return;
121
+ }
122
+ features.features.push(c);
123
+ });
124
+ return features;
125
+ }
126
+
127
+ function drawMaplets(opts, d3) {
128
+ var svg = opts.svg;
129
+ var world = opts.world;
130
+ var viewport = opts.viewport;
131
+ var start = opts.start;
132
+ var side = opts.side;
133
+
134
+ var g = svg // the map will be drawn in this group
135
+ .append('g')
136
+ .attr('class', 'maplet-container');
137
+ var countries = opts.countries;
138
+
139
+ // debugger;
140
+
141
+ countries.forEach(function (name, index) {
142
+ var feature = filterCountriesByNames(world, [name]);
143
+ var boxw = 50;
144
+ var boxh = 50;
145
+ var space = 10;
146
+
147
+ var mapletWorld = world.filter(function (country) {
148
+ return country.properties.SHRT_ENGL === name;
149
+ });
150
+
151
+ var msp = getMapletStartingPoint(
152
+ viewport,
153
+ start,
154
+ index,
155
+ side,
156
+ space,
157
+ [boxw, boxh],
158
+ 0,
159
+ );
160
+
161
+ var zo = {
162
+ world: mapletWorld,
163
+ svg: g,
164
+ coordinates: {
165
+ x: msp.x,
166
+ y: msp.y,
167
+ width: boxw,
168
+ height: boxh,
169
+ },
170
+ focusCountries: {
171
+ names: [name],
172
+ feature: feature,
173
+ },
174
+ zoom: 0.5,
175
+ isMaplet: true,
176
+ };
177
+ drawMaplet(zo, d3);
178
+ });
179
+ }
180
+
181
+ function drawMaplet(opts, d3) {
182
+ var msp = opts.coordinates;
183
+ var svg = opts.svg;
184
+ svg
185
+ .append('rect')
186
+ .attr('class', 'maplet-outline')
187
+ .attr('x', msp.x)
188
+ .attr('y', msp.y)
189
+ .attr('width', msp.width)
190
+ .attr('height', msp.height);
191
+
192
+ // var path = renderCountriesBox(opts, d3);
193
+ // renderCountryLabel(opts.focusCountries.feature.features[0], path, true);
194
+ }
195
+
196
+ function getMapletStartingPoint(
197
+ viewport, // an array of two integers, width and height
198
+ startPoint, // an array of two numbers, x, y for position in viewport
199
+ index, // integer, position in layout
200
+ side, // one of ['top', 'bottom', 'left', right']
201
+ spacer, // integer with amount of space to leave between Maplets
202
+ boxDim, // array of two numbers, box width and box height
203
+ titleHeight, // height of title box
204
+ ) {
205
+ // return value is array of x,y
206
+ // x: horizontal coordinate
207
+ // y: vertical coordinate
208
+
209
+ var bws = boxDim[0] + spacer; // box width including space to the right
210
+ var bhs = boxDim[1] + spacer + titleHeight;
211
+
212
+ var mutator = travelToOppositeMutator(startPoint, viewport, [bws, bhs]);
213
+
214
+ var mutPoint = [startPoint[0], startPoint[1]];
215
+
216
+ for (var i = 0; i < index; i++) {
217
+ mutPoint = mutator(mutPoint, index);
218
+ }
219
+
220
+ // TODO: this could be improved, there are many edge cases
221
+ switch (side) {
222
+ case 'top':
223
+ mutPoint[1] = startPoint[1];
224
+ break;
225
+ case 'bottom':
226
+ mutPoint[1] = startPoint[1] - bhs;
227
+ break;
228
+ case 'left':
229
+ mutPoint[0] = startPoint[0];
230
+ break;
231
+ case 'right':
232
+ default:
233
+ mutPoint[0] = startPoint[0] - bws;
234
+ break;
235
+ }
236
+
237
+ return {
238
+ x: mutPoint[0],
239
+ y: mutPoint[1],
240
+ };
241
+ }
242
+
243
+ function travelToOppositeMutator(start, viewport, delta) {
244
+ // point: the point we want to mutate
245
+ // start: starting point (the initial anchor point)
246
+ // viewport: array of width, height
247
+ // delta: array of dimensions to travel
248
+
249
+ var center = [viewport[0] / 2, viewport[1] / 2];
250
+
251
+ var dirx = start[0] > center[0] ? -1 : 1;
252
+ var diry = start[1] > center[1] ? -1 : 1;
253
+ return function (point) {
254
+ var res = [point[0] + delta[0] * dirx, point[1] + delta[1] * diry];
255
+ return res;
256
+ };
257
+ }
258
+
129
259
  function renderGraticule(container, klass, steps, pathTransformer, d3Geo) {
130
260
  container // draw primary graticule lines
131
261
  .append('g')
@@ -376,13 +506,6 @@ function showMapTooltip(d, countries_metadata, d3) {
376
506
  d3.event.stopPropagation();
377
507
  }
378
508
 
379
- function removeTooltip() {
380
- const elem = document.getElementById('map-tooltip');
381
- if (elem) {
382
- elem.parentElement.removeChild(elem);
383
- }
384
- }
385
-
386
509
  function createTooltip(opts) {
387
510
  const x = opts['coords'][0];
388
511
  const y = opts['coords'][1];
@@ -1,52 +1,15 @@
1
1
  import React, { useRef, useEffect } from 'react';
2
- import flags from './flags.js';
3
2
  import './styles.css';
4
3
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
5
4
  import { compose } from 'redux';
6
5
  import { clientOnly } from '@eeacms/volto-cca-policy/helpers';
7
6
  import withResponsiveContainer from './../withResponsiveContainer.js';
7
+ import { renderCountriesBox } from './map-utils.js';
8
8
  import {
9
9
  getFocusCountriesFeature,
10
10
  getFocusCountryNames,
11
- renderCountriesBox,
12
- } from './map-utils.js';
13
-
14
- const withCountriesData = (WrappedComponent) => {
15
- function WithCountriesDataWrapped(props) {
16
- let [cpath, setCpath] = React.useState();
17
-
18
- useEffect(() => {
19
- if (!cpath) {
20
- import('./euro-countries-simplified.js').then((mod) => {
21
- const _cpath = mod.default;
22
- _cpath.features = _cpath.features.map(function (c) {
23
- //console.log(c);
24
- var name = c.properties.SHRT_ENGL;
25
- if (!name) {
26
- // console.log('No flag for', c.properties);
27
- return c;
28
- } else if (name === 'Czechia') {
29
- name = 'Czech Republic';
30
- }
31
- var cname = name.replace(' ', '_');
32
- flags.forEach(function (f) {
33
- if (f.indexOf(cname) > -1) {
34
- c.url = f;
35
- //console.log(c.url);
36
- }
37
- });
38
- return c;
39
- });
40
-
41
- setCpath(_cpath);
42
- });
43
- }
44
- }, [cpath]);
45
-
46
- return cpath ? <WrappedComponent {...props} cpath={cpath} /> : null;
47
- }
48
- return WithCountriesDataWrapped;
49
- };
11
+ withCountriesData,
12
+ } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
50
13
 
51
14
  const CountryMapObservatoryView = (props) => {
52
15
  const svgRef = useRef(null);
@@ -1,52 +1,4 @@
1
- export function getFocusCountryNames() {
2
- return [
3
- 'Austria',
4
- 'Belgium',
5
- 'Cyprus',
6
- 'Czechia',
7
- 'Denmark',
8
- 'Estonia',
9
- 'Finland',
10
- 'France',
11
- 'Germany',
12
- 'Greece',
13
- 'Hungary',
14
- 'Iceland',
15
- 'Ireland',
16
- 'Italy',
17
- 'Lithuania',
18
- 'Luxembourg',
19
- 'Malta',
20
- 'Netherlands',
21
- 'Poland',
22
- 'Portugal',
23
- 'Romania',
24
- 'Slovakia',
25
- 'Slovenia',
26
- 'Spain',
27
- 'Sweden',
28
- 'United Kingdom',
29
- 'Liechtenstein',
30
- 'Norway',
31
- 'Switzerland',
32
- 'Turkey',
33
- ];
34
- }
35
-
36
- export function getFocusCountriesFeature(world) {
37
- const focusCountryNames = getFocusCountryNames();
38
- let features = {
39
- type: 'FeatureCollection',
40
- features: [],
41
- };
42
- world.features.forEach(function (c) {
43
- if (focusCountryNames.indexOf(c.properties.SHRT_ENGL) === -1) {
44
- return;
45
- }
46
- features.features.push(c);
47
- });
48
- return features;
49
- }
1
+ import { getFocusCountryNames } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
50
2
 
51
3
  export function renderCountriesBox(opts, d3, d3Geo) {
52
4
  var coords = opts.coordinates;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import configureStore from 'redux-mock-store';
4
+ import { render } from '@testing-library/react';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+ import { Provider } from 'react-intl-redux';
7
+ import Filter from './Filter';
8
+
9
+ const mockStore = configureStore();
10
+
11
+ describe('Filter', () => {
12
+ it('should render the component', () => {
13
+ const data = {
14
+ thematicMapMode: 'hhap',
15
+ setThematicMapMode(param) {
16
+ return param;
17
+ },
18
+ };
19
+
20
+ const store = mockStore({
21
+ userSession: { token: '1234' },
22
+ intl: {
23
+ locale: 'en',
24
+ messages: {},
25
+ },
26
+ });
27
+
28
+ const { container } = render(
29
+ <Provider store={store}>
30
+ <MemoryRouter>
31
+ <Filter {...data} />
32
+ </MemoryRouter>
33
+ </Provider>,
34
+ );
35
+ expect(container.querySelector('#sections-selector')).toBeInTheDocument();
36
+ });
37
+ });
@@ -1,5 +1,4 @@
1
1
  import React, { useRef, useEffect } from 'react';
2
- import flags from './flags.js';
3
2
  import './styles.css';
4
3
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
5
4
  import { Grid } from 'semantic-ui-react';
@@ -7,11 +6,12 @@ import { compose } from 'redux';
7
6
  import { clientOnly } from '@eeacms/volto-cca-policy/helpers';
8
7
  import withResponsiveContainer from './../withResponsiveContainer.js';
9
8
  import { addAppURL } from '@plone/volto/helpers';
9
+ import { renderCountriesBox } from './map-utils.js';
10
10
  import {
11
11
  getFocusCountriesFeature,
12
12
  getFocusCountryNames,
13
- renderCountriesBox,
14
- } from './map-utils.js';
13
+ withCountriesData,
14
+ } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
15
15
 
16
16
  import Filter from './Filter';
17
17
 
@@ -20,43 +20,6 @@ import { useCountriesMetadata } from './hooks';
20
20
  const countries_metadata_url =
21
21
  '/en/countries-regions/countries/@@countries-metadata-extract?langflag=1';
22
22
 
23
- const withCountriesData = (WrappedComponent) => {
24
- function WithCountriesDataWrapped(props) {
25
- let [cpath, setCpath] = React.useState();
26
-
27
- useEffect(() => {
28
- if (!cpath) {
29
- import('./euro-countries-simplified.js').then((mod) => {
30
- const _cpath = mod.default;
31
- _cpath.features = _cpath.features.map(function (c) {
32
- //console.log(c);
33
- var name = c.properties.SHRT_ENGL;
34
- if (!name) {
35
- // console.log('No flag for', c.properties);
36
- return c;
37
- } else if (name === 'Czechia') {
38
- name = 'Czech Republic';
39
- }
40
- var cname = name.replace(' ', '_');
41
- flags.forEach(function (f) {
42
- if (f.indexOf(cname) > -1) {
43
- c.url = f;
44
- //console.log(c.url);
45
- }
46
- });
47
- return c;
48
- });
49
-
50
- setCpath(_cpath);
51
- });
52
- }
53
- }, [cpath]);
54
-
55
- return cpath ? <WrappedComponent {...props} cpath={cpath} /> : null;
56
- }
57
- return WithCountriesDataWrapped;
58
- };
59
-
60
23
  const CountryMapObservatoryView = (props) => {
61
24
  const svgRef = useRef(null);
62
25
  const { d3, d3Geo, size, cpath } = props;
@@ -1,55 +1,4 @@
1
- export function getFocusCountryNames() {
2
- return [
3
- 'Austria',
4
- 'Belgium',
5
- 'Bulgaria',
6
- 'Cyprus',
7
- 'Croatia',
8
- 'Czechia',
9
- 'Denmark',
10
- 'Estonia',
11
- 'Finland',
12
- 'France',
13
- 'Germany',
14
- 'Greece',
15
- 'Hungary',
16
- 'Iceland',
17
- 'Ireland',
18
- 'Italy',
19
- 'Latvia',
20
- 'Lithuania',
21
- 'Luxembourg',
22
- 'Malta',
23
- 'Netherlands',
24
- 'Poland',
25
- 'Portugal',
26
- 'Romania',
27
- 'Slovakia',
28
- 'Slovenia',
29
- 'Spain',
30
- 'Sweden',
31
- 'United Kingdom',
32
- 'Liechtenstein',
33
- 'Norway',
34
- 'Switzerland',
35
- 'Turkey',
36
- ];
37
- }
38
-
39
- export function getFocusCountriesFeature(world) {
40
- const focusCountryNames = getFocusCountryNames();
41
- let features = {
42
- type: 'FeatureCollection',
43
- features: [],
44
- };
45
- world.features.forEach(function (c) {
46
- if (focusCountryNames.indexOf(c.properties.SHRT_ENGL) === -1) {
47
- return;
48
- }
49
- features.features.push(c);
50
- });
51
- return features;
52
- }
1
+ import { removeTooltip } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
53
2
 
54
3
  // tooltip with country names on hover
55
4
  let countryNameTooltip = null;
@@ -477,13 +426,6 @@ function showMapTooltip(d, countries_metadata, d3) {
477
426
  d3.event.stopPropagation();
478
427
  }
479
428
 
480
- function removeTooltip() {
481
- const elem = document.getElementById('map-tooltip');
482
- if (elem) {
483
- elem.parentElement.removeChild(elem);
484
- }
485
- }
486
-
487
429
  function createTooltip(opts) {
488
430
  const x = opts['coords'][0];
489
431
  const y = opts['coords'][1];