@eeacms/volto-n2k 1.0.4 → 1.0.6

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,7 +4,17 @@ 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
- ### [1.0.4](https://github.com/eea/volto-n2k/compare/1.0.3...1.0.4) - 17 November 2022
7
+ ### [1.0.6](https://github.com/eea/volto-n2k/compare/1.0.5...1.0.6) - 14 December 2022
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - update [Miu Razvan - [`e743c1c`](https://github.com/eea/volto-n2k/commit/e743c1c6acd838b359c93b8a922bbbcf247e28a2)]
12
+ ### [1.0.5](https://github.com/eea/volto-n2k/compare/1.0.4...1.0.5) - 13 December 2022
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - Don't run cypress [Miu Razvan - [`3afcc02`](https://github.com/eea/volto-n2k/commit/3afcc02e64e90046e109a71bcc69b6160566197d)]
17
+ ### [1.0.4](https://github.com/eea/volto-n2k/compare/1.0.3...1.0.4) - 7 December 2022
8
18
 
9
19
  #### :hammer_and_wrench: Others
10
20
 
@@ -125,7 +135,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
125
135
  - Update [razvanMiu - [`42ab50e`](https://github.com/eea/volto-n2k/commit/42ab50e6681a47251d15ac06b836c6f8c27157fa)]
126
136
  - Added bubble chart [razvanMiu - [`89fba5e`](https://github.com/eea/volto-n2k/commit/89fba5e5db41aa955ba2d0ed58c9f0042c461504)]
127
137
  - Group species by id_eunis in species list [razvanMiu - [`543c957`](https://github.com/eea/volto-n2k/commit/543c9573b53acd8eecc9afbb6ae7beeddba53966)]
128
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`2ca3e4c`](https://github.com/eea/volto-n2k/commit/2ca3e4c092211f92339791d71db81f5b4ca2d562)]
129
138
  - update maps - species and habitats distribution maps [Claudia Ifrim - [`ad12eb1`](https://github.com/eea/volto-n2k/commit/ad12eb141907d6f28444f1eafc3f687735d2a68d)]
130
139
  - update format for common name and author [Claudia Ifrim - [`26b7a2f`](https://github.com/eea/volto-n2k/commit/26b7a2f3d20c7701b57fb24f39fc7dfeceec3ce8)]
131
140
  - update format for species name (common / scientific) [Claudia Ifrim - [`abdedcf`](https://github.com/eea/volto-n2k/commit/abdedcfe645665031dedf050fd2c5cdde8c14a50)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-n2k",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "volto-n2k: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import { connect } from 'react-redux';
3
3
  import { generatePath } from 'react-router';
4
4
  import { Grid } from 'semantic-ui-react';
@@ -7,9 +7,20 @@ import { withLocalStorage } from '@eeacms/volto-n2k/hocs';
7
7
  import hiker from './images/hiker.webp';
8
8
  import { tiles, tileProps, getStyle } from './index';
9
9
 
10
+ function removeTrailingSlash(str) {
11
+ return str.replace(/\/+$/, '');
12
+ }
13
+
10
14
  const DefaultView = (props) => {
11
15
  const currentLang = props.localStorage.get('N2K_LANGUAGE');
12
16
 
17
+ useEffect(() => {
18
+ if (removeTrailingSlash(props.location.pathname) === '/natura2000') {
19
+ props.history.push(`/natura2000/${currentLang || 'en'}`);
20
+ }
21
+ /* eslint-disable-next-line */
22
+ }, []);
23
+
13
24
  return (
14
25
  <>
15
26
  <div
@@ -15,7 +15,6 @@ const View = (props) => {
15
15
  cdda_designation_national_language = [],
16
16
  site_type = [],
17
17
  site_code = [],
18
- area_km2 = [],
19
18
  area_ha = [],
20
19
  year_stablished = [],
21
20
  number_protected_habitat_types = [],
@@ -70,14 +69,8 @@ const View = (props) => {
70
69
 
71
70
  <div className="site-detail">
72
71
  <div className="upper">
73
- {isNumber(area_km2[0]) || isNumber(area_ha[0]) ? (
74
- area_km2 > 1 ? (
75
- <div>
76
- {area_km2} km<sup>2</sup>
77
- </div>
78
- ) : (
79
- <div>{area_ha} ha</div>
80
- )
72
+ {isNumber(area_ha[0]) ? (
73
+ <div>{area_ha} ha</div>
81
74
  ) : (
82
75
  <div>No data</div>
83
76
  )}
@@ -93,7 +86,7 @@ const View = (props) => {
93
86
  <div>-</div>
94
87
  )}
95
88
  </div>
96
- <div className="lower">Year established</div>
89
+ <div className="lower">Site established</div>
97
90
  </div>
98
91
 
99
92
  {site_type[0] === 'CDDA' && (
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import findIndex from 'lodash/findIndex';
2
3
  import { Icon } from '@plone/volto/components';
3
4
  import { Link } from 'react-router-dom';
4
5
  import cx from 'classnames';
@@ -9,7 +10,7 @@ import './style.less';
9
10
 
10
11
  const View = (props) => {
11
12
  const [habitats, setHabitats] = React.useState({});
12
- const [selectedHabitat, setSelectedHabitat] = React.useState(null);
13
+ const [expandedHabitats, setExpandedHabitats] = React.useState([]);
13
14
  const { provider_data = {}, placeholder = 'No results' } = props;
14
15
 
15
16
  React.useEffect(() => {
@@ -31,54 +32,70 @@ const View = (props) => {
31
32
  {Object.keys(habitats)?.length ? (
32
33
  Object.keys(habitats)
33
34
  .sort()
34
- .map((habitat) => (
35
- <div className="habitat" key={habitat}>
36
- <div
37
- className={cx({
38
- 'habitat-toolbar': true,
39
- marginless: selectedHabitat !== habitat,
40
- })}
41
- >
42
- <div className="habitat-name">
43
- <h3>{habitat}</h3>
44
- <p className="count">{habitats[habitat].length}</p>
35
+ .map((habitat) => {
36
+ const expanded = expandedHabitats.includes(habitat);
37
+ return (
38
+ <div className="habitat" key={habitat}>
39
+ <div
40
+ className={cx({
41
+ 'habitat-toolbar': true,
42
+ marginless: !expanded,
43
+ })}
44
+ >
45
+ <div className="habitat-name">
46
+ <h3>{habitat}</h3>
47
+ <p className="count">{habitats[habitat].length}</p>
48
+ </div>
49
+ <Icon
50
+ name={expanded ? upKeySVG : downKeySVG}
51
+ onClick={(e) => {
52
+ const index = findIndex(
53
+ expandedHabitats,
54
+ (name) => name === habitat,
55
+ );
56
+ if (index === -1) {
57
+ setExpandedHabitats((prevExpandedHabitats) => [
58
+ ...prevExpandedHabitats,
59
+ habitat,
60
+ ]);
61
+ } else {
62
+ setExpandedHabitats((prevExpandedHabitats) => {
63
+ const newExpandedHabitats = [...prevExpandedHabitats];
64
+ newExpandedHabitats.splice(index, 1);
65
+ return newExpandedHabitats;
66
+ });
67
+ }
68
+ e.preventDefault();
69
+ e.stopPropagation();
70
+ }}
71
+ color="#8C8C8C"
72
+ size="32px"
73
+ />
45
74
  </div>
46
- <Icon
47
- name={selectedHabitat === habitat ? upKeySVG : downKeySVG}
48
- onClick={(e) => {
49
- setSelectedHabitat(
50
- selectedHabitat === habitat ? null : habitat,
51
- );
52
- e.preventDefault();
53
- e.stopPropagation();
54
- }}
55
- color="#8C8C8C"
56
- size="32px"
57
- />
58
- </div>
59
75
 
60
- {selectedHabitat === habitat
61
- ? habitats[habitat].map((item, index) => (
62
- <div
63
- className="habitat-item"
64
- key={`${habitat}-${index}-item`}
65
- >
66
- <Link
67
- className="description"
68
- to={`/natura2000/habitats/h/${item.code_2000}`}
76
+ {expanded
77
+ ? habitats[habitat].map((item, index) => (
78
+ <div
79
+ className="habitat-item"
80
+ key={`${habitat}-${index}-item`}
69
81
  >
70
- {item.habitat_description}
71
- </Link>
72
- <p className="coverage">
73
- {item.coverage_ha.toFixed(2)} ha (
74
- {(item.coverage_ha / 100).toFixed(4)} km
75
- <sup>2</sup>)
76
- </p>
77
- </div>
78
- ))
79
- : ''}
80
- </div>
81
- ))
82
+ <Link
83
+ className="description"
84
+ to={`/natura2000/habitats/h/${item.code_2000}`}
85
+ >
86
+ {item.habitat_description} ({item.code_2000})
87
+ </Link>
88
+ <p className="coverage">
89
+ {item.coverage_ha.toFixed(2)} ha (
90
+ {(item.coverage_ha / 100).toFixed(4)} km
91
+ <sup>2</sup>)
92
+ </p>
93
+ </div>
94
+ ))
95
+ : ''}
96
+ </div>
97
+ );
98
+ })
82
99
  ) : (
83
100
  <p>{placeholder}</p>
84
101
  )}
@@ -303,10 +303,10 @@ class Navigation extends Component {
303
303
  : '#'
304
304
  }
305
305
  openLinkInNewTab={true}
306
- title="Deep dive"
306
+ title="Go to expert view"
307
307
  className="item firstLevel deep-dive"
308
308
  >
309
- DEEP DIVE
309
+ GO TO EXPERT VIEW
310
310
  </UniversalLink>
311
311
  </>
312
312
  ) : (