@eeacms/volto-marine-policy 2.0.4 → 2.0.5

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,19 @@ 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
+ ### [2.0.5](https://github.com/eea/volto-marine-policy/compare/2.0.4...2.0.5) - 11 April 2025
8
+
9
+ #### :house: Internal changes
10
+
11
+ - style: Automated code fix [eea-jenkins - [`3f5d2ae`](https://github.com/eea/volto-marine-policy/commit/3f5d2ae0b755628580ddb0976c113be5300f2bfc)]
12
+ - style: Automated code fix [eea-jenkins - [`6b67afb`](https://github.com/eea/volto-marine-policy/commit/6b67afba55d6aeefc36af776e33833f40552f3c6)]
13
+ - style: Automated code fix [eea-jenkins - [`532ca8a`](https://github.com/eea/volto-marine-policy/commit/532ca8afa6cc4a6f9e93a09bc107eef37328b326)]
14
+
15
+ #### :hammer_and_wrench: Others
16
+
17
+ - eslint [laszlocseh - [`188282d`](https://github.com/eea/volto-marine-policy/commit/188282d7d80201395f7025eb3540a2df8bf70275)]
18
+ - demo sites map indicators filter [laszlocseh - [`7d97ac7`](https://github.com/eea/volto-marine-policy/commit/7d97ac772e308c0b18a49034067925fb72abecc0)]
19
+ - updates to demo sites map [laszlocseh - [`ab5ac18`](https://github.com/eea/volto-marine-policy/commit/ab5ac1874f97ceeafce6c639ec033b9f7dde09ab)]
7
20
  ### [2.0.4](https://github.com/eea/volto-marine-policy/compare/2.0.3...2.0.4) - 8 April 2025
8
21
 
9
22
  #### :rocket: New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-marine-policy",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "@eeacms/volto-marine-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -3,8 +3,7 @@ import { Grid } from 'semantic-ui-react'; // Dropdown,
3
3
  import { addAppURL } from '@plone/volto/helpers';
4
4
  import config from '@plone/volto/registry';
5
5
  import DemoSitesMap from './DemoSitesMap';
6
- import { ActiveFilters, DemoSitesFilters, SearchBox } from './DemoSitesFilters';
7
- // import DemoSitesList from './DemoSitesListing';
6
+ import { ActiveFilters, DemoSitesFilters } from './DemoSitesFilters';
8
7
 
9
8
  import { filterCases, getFilters } from './utils';
10
9
  import { useCases } from './hooks';
@@ -19,7 +18,6 @@ export default function DemoSitesExplorerView(props) {
19
18
  let cases = useCases(addAppURL(cases_url));
20
19
  const { demoSitesIds } = props; // case studies from measure view
21
20
  const [selectedCase, onSelectedCase] = React.useState(null);
22
- const [searchInput, setSearchInput] = React.useState('');
23
21
  const hideFilters = demoSitesIds ? true : false;
24
22
 
25
23
  const [activeFilters, setActiveFilters] = React.useState({
@@ -46,33 +44,15 @@ export default function DemoSitesExplorerView(props) {
46
44
  ]);
47
45
 
48
46
  React.useEffect(() => {
49
- let activeItems = filterCases(
50
- cases,
51
- activeFilters,
52
- demoSitesIds,
53
- searchInput,
54
- );
47
+ let activeItems = filterCases(cases, activeFilters, demoSitesIds);
55
48
 
56
49
  setActiveItems(activeItems);
57
- }, [demoSitesIds, activeFilters, cases, searchInput]);
50
+ }, [demoSitesIds, activeFilters, cases]);
58
51
 
59
52
  if (__SERVER__) return '';
60
53
 
61
54
  return (
62
55
  <div className="searchlib-block">
63
- <Grid.Row>
64
- {hideFilters ? null : (
65
- <SearchBox
66
- filters={filters}
67
- activeFilters={activeFilters}
68
- setActiveFilters={setActiveFilters}
69
- searchInput={searchInput}
70
- setSearchInput={setSearchInput}
71
- onSelectedCase={onSelectedCase}
72
- map={map}
73
- />
74
- )}
75
- </Grid.Row>
76
56
  <Grid.Row>
77
57
  {hideFilters ? null : (
78
58
  <ActiveFilters
@@ -102,7 +82,6 @@ export default function DemoSitesExplorerView(props) {
102
82
  hideFilters={hideFilters}
103
83
  selectedCase={selectedCase}
104
84
  onSelectedCase={onSelectedCase}
105
- searchInput={searchInput}
106
85
  map={map}
107
86
  setMap={setMap}
108
87
  />
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { centerAndResetMapZoom, scrollToElement } from './utils';
3
+ import { centerAndResetMapZoom } from './utils';
4
4
 
5
5
  const normalizeSearchInput = (searchInput) => {
6
6
  let normInput = searchInput
@@ -87,7 +87,7 @@ export function DemoSitesFilter(props) {
87
87
  });
88
88
  }
89
89
  setActiveFilters(temp);
90
- scrollToElement('search-input');
90
+ // scrollToElement('search-input');
91
91
  centerAndResetMapZoom(map);
92
92
  }}
93
93
  />
@@ -181,7 +181,7 @@ export function SearchBox(props) {
181
181
  // const popupOverlay = document.getElementById('popup-overlay');
182
182
  // popupOverlay.style.visibility = 'hidden';
183
183
  setSearchInput(searchInput);
184
- scrollToElement('search-input');
184
+ // scrollToElement('search-input');
185
185
  centerAndResetMapZoom(map);
186
186
  }}
187
187
  ></input>
@@ -199,7 +199,7 @@ export function SearchBox(props) {
199
199
  searchInputElement.value = '';
200
200
  setSearchInput('');
201
201
  setShowClearButton(false);
202
- scrollToElement('search-input');
202
+ // scrollToElement('search-input');
203
203
  centerAndResetMapZoom(map);
204
204
  }}
205
205
  ></i>
@@ -219,7 +219,7 @@ export function SearchBox(props) {
219
219
  );
220
220
 
221
221
  setSearchInput(searchInputVal);
222
- scrollToElement('search-input');
222
+ // scrollToElement('search-input');
223
223
  centerAndResetMapZoom(map);
224
224
  }}
225
225
  onKeyDown={() => {}}
@@ -261,7 +261,7 @@ export function ActiveFilters(props) {
261
261
  project_filter: [],
262
262
  country_filter: [],
263
263
  });
264
- scrollToElement('search-input');
264
+ // scrollToElement('search-input');
265
265
  };
266
266
 
267
267
  const removeFilter = (filterName, filterCode) => {
@@ -310,7 +310,7 @@ export function ActiveFilters(props) {
310
310
  onKeyPress={() => {}}
311
311
  onClick={() => {
312
312
  removeFilter('objective_filter', filterCode);
313
- scrollToElement('search-input');
313
+ // scrollToElement('search-input');
314
314
  }}
315
315
  role="button"
316
316
  className="close icon"
@@ -335,7 +335,7 @@ export function ActiveFilters(props) {
335
335
  onKeyPress={() => {}}
336
336
  onClick={() => {
337
337
  removeFilter('indicator_filter', filterCode);
338
- scrollToElement('search-input');
338
+ // scrollToElement('search-input');
339
339
  }}
340
340
  role="button"
341
341
  className="close icon"
@@ -360,7 +360,7 @@ export function ActiveFilters(props) {
360
360
  onKeyPress={() => {}}
361
361
  onClick={() => {
362
362
  removeFilter('project_filter', filterCode);
363
- scrollToElement('search-input');
363
+ // scrollToElement('search-input');
364
364
  }}
365
365
  role="button"
366
366
  className="close icon"
@@ -385,7 +385,7 @@ export function ActiveFilters(props) {
385
385
  onKeyPress={() => {}}
386
386
  onClick={() => {
387
387
  removeFilter('country_filter', filterCode);
388
- scrollToElement('search-input');
388
+ // scrollToElement('search-input');
389
389
  }}
390
390
  role="button"
391
391
  className="close icon"
@@ -1,10 +1,5 @@
1
1
  import React from 'react';
2
- import {
3
- centerAndResetMapZoom,
4
- scrollToElement,
5
- zoomMapToFeatures,
6
- isValidURL,
7
- } from './utils';
2
+ import { centerAndResetMapZoom, zoomMapToFeatures, isValidURL } from './utils';
8
3
 
9
4
  const showPageNr = (pageNr, currentPage, numberOfPages) => {
10
5
  // show first 5 pages
@@ -157,7 +152,7 @@ export default function DemoSitesList(props) {
157
152
  onKeyDown={() => {}}
158
153
  onClick={() => {
159
154
  // scroll to the map
160
- scrollToElement('search-input');
155
+ // scrollToElement('search-input');
161
156
  // reset map zoom
162
157
  onSelectedCase(null);
163
158
  centerAndResetMapZoom(map);
@@ -274,7 +269,7 @@ export default function DemoSitesList(props) {
274
269
  .array_[9].getFeatures()
275
270
  .clear();
276
271
  // scroll to the map
277
- scrollToElement('ol-map-container');
272
+ // scrollToElement('ol-map-container');
278
273
 
279
274
  zoomMapToFeatures(map, [item], 5000);
280
275
  onSelectedCase(item.values_);
@@ -7,10 +7,9 @@ import { openlayers as ol } from '@eeacms/volto-openlayers-map';
7
7
 
8
8
  import InfoOverlay from './InfoOverlay';
9
9
  import FeatureInteraction from './FeatureInteraction';
10
- import DemoSitesList from './DemoSitesListing';
11
10
  import { useMapContext } from '@eeacms/volto-openlayers-map/api';
12
11
 
13
- import { centerAndResetMapZoom, getFeatures, scrollToElement } from './utils';
12
+ import { centerAndResetMapZoom, getFeatures } from './utils';
14
13
 
15
14
  const styleCache = {};
16
15
  const MapContextGateway = ({ setMap }) => {
@@ -28,7 +27,6 @@ export default function DemoSitesMap(props) {
28
27
  hideFilters,
29
28
  selectedCase,
30
29
  onSelectedCase,
31
- searchInput,
32
30
  map,
33
31
  setMap,
34
32
  } = props;
@@ -135,7 +133,7 @@ export default function DemoSitesMap(props) {
135
133
  String(resetMapButtonClass),
136
134
  )}
137
135
  onClick={() => {
138
- scrollToElement('search-input');
136
+ // scrollToElement('search-input');
139
137
  onSelectedCase(null);
140
138
  centerAndResetMapZoom(map);
141
139
  map.getInteractions().array_[9].getFeatures().clear();
@@ -165,22 +163,12 @@ export default function DemoSitesMap(props) {
165
163
  <MapContextGateway setMap={setMap} />
166
164
  </Layers>
167
165
  </MapWithSelection>
168
- {hideFilters ? null : (
169
- <DemoSitesList
170
- map={map}
171
- activeItems={activeItems}
172
- selectedCase={selectedCase}
173
- onSelectedCase={onSelectedCase}
174
- pointsSource={pointsSource}
175
- searchInput={searchInput}
176
- />
177
- )}
178
166
  </div>
179
167
  ) : null;
180
168
  }
181
169
 
182
170
  const selectedClusterStyle = (selectedFeature) => {
183
- function _clusterStyle(feature) {
171
+ function _clusterStyle(feature, selectedFeature) {
184
172
  const size = feature.get('features').length;
185
173
  let style = styleCache[size];
186
174
 
@@ -193,7 +181,7 @@ const selectedClusterStyle = (selectedFeature) => {
193
181
  }),
194
182
  fill: new ol.style.Fill({
195
183
  // 309ebc blue 3 + green 3 mix
196
- color: '#309ebc', // #006BB8 #309ebc
184
+ color: '#006BB8', // #006BB8 #309ebc
197
185
  }),
198
186
  }),
199
187
  text: new ol.style.Text({
@@ -207,18 +195,21 @@ const selectedClusterStyle = (selectedFeature) => {
207
195
  }
208
196
 
209
197
  if (size === 1) {
210
- // let color = feature.values_.features[0].values_['color'];
211
- let color = '#50B0A4'; // #0083E0 #50B0A4
198
+ let color = feature.values_.features[0].values_['color'];
199
+ let width = feature.values_.features[0].values_['width'];
200
+ let radius = feature.values_.features[0].values_['radius'];
201
+ // console.log(color)
202
+ // let color = '#0083E0'; // #0083E0 #50B0A4
212
203
 
213
204
  return new ol.style.Style({
214
205
  image: new ol.style.Circle({
215
- radius: 6,
206
+ radius: radius,
216
207
  fill: new ol.style.Fill({
217
208
  color: '#fff',
218
209
  }),
219
210
  stroke: new ol.style.Stroke({
220
211
  color: color,
221
- width: 6,
212
+ width: width,
222
213
  }),
223
214
  }),
224
215
  });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { isValidURL } from './utils';
2
+ import { isValidURL, truncateText } from './utils';
3
3
 
4
4
  export default function FeatureDisplay({ feature }) {
5
5
  return feature ? (
@@ -7,7 +7,7 @@ export default function FeatureDisplay({ feature }) {
7
7
  <h3>
8
8
  <strong>
9
9
  <a target="_blank" rel="noopener noreferrer" href={feature.path}>
10
- {feature.title}
10
+ {truncateText(feature.title)}
11
11
  </a>
12
12
  </strong>
13
13
  </h3>
@@ -66,10 +66,10 @@ export default function FeatureDisplay({ feature }) {
66
66
  ''
67
67
  )}
68
68
 
69
- {/* <div>
70
- <h4>NWRMs implemented</h4>
69
+ <div>
70
+ <h4>Indicators</h4>
71
71
  <ul>
72
- {feature.nwrms_implemented.map((item, index) => {
72
+ {feature.indicators.map((item, index) => {
73
73
  return (
74
74
  <li key={index}>
75
75
  <a
@@ -83,9 +83,9 @@ export default function FeatureDisplay({ feature }) {
83
83
  );
84
84
  })}
85
85
  </ul>
86
- </div> */}
86
+ </div>
87
87
  {/* <div>
88
- <h4>Sectors </h4>
88
+ <h4>Indicators</h4>
89
89
  <ul>
90
90
  {feature.sectors.map((item, index) => {
91
91
  return <li key={index}>{item}</li>;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { openlayers as ol } from '@eeacms/volto-openlayers-map';
3
3
  import { useMapContext } from '@eeacms/volto-openlayers-map/api';
4
- import { scrollToElement, zoomMapToFeatures } from './utils';
4
+ import { zoomMapToFeatures } from './utils';
5
5
 
6
6
  export const useStyles = () => {
7
7
  const selected = React.useMemo(
@@ -65,7 +65,7 @@ export default function FeatureInteraction({
65
65
  window.location.href = url;
66
66
  }
67
67
  onFeatureSelect(selectedFeature);
68
- scrollToElement('ol-map-container');
68
+ // scrollToElement('ol-map-container');
69
69
  // map.getView().animate({
70
70
  // duration: 10,
71
71
  // center: selectedFeature.geometry.flatCoordinates,
@@ -87,7 +87,7 @@
87
87
  display: block !important;
88
88
  // width: 100%;
89
89
  // height: 100%;
90
- background-color: #dae8f4;
90
+ background-color: #fefefe;
91
91
 
92
92
  #popup-overlay {
93
93
  position: relative !important;
@@ -1,5 +1,12 @@
1
1
  import { openlayers as ol } from '@eeacms/volto-openlayers-map';
2
2
 
3
+ export const truncateText = (str, max = 50) => {
4
+ if (str.length <= max) {
5
+ return str;
6
+ }
7
+ return str.substring(0, max) + '...';
8
+ };
9
+
3
10
  export function isValidURL(string) {
4
11
  try {
5
12
  new URL(string);
@@ -40,6 +47,22 @@ export function zoomMapToFeatures(map, features, threshold = 500) {
40
47
 
41
48
  export function getFeatures(cases) {
42
49
  const Feature = ol.ol.Feature;
50
+ const colors = {
51
+ 'Carbon-neutral and circular blue economy': '#004b7f',
52
+ 'Digital twin of the ocean': '#004b7f',
53
+ 'Prevent and eliminate pollution of waters': '#fdaf20',
54
+ 'Protect and restore marine and freshwater ecosystems': '#007b6c',
55
+ 'Public mobilisation and engagement': '#004b7f',
56
+ };
57
+ const width = {
58
+ 'Demo site': 6,
59
+ 'Associated region': 8,
60
+ };
61
+
62
+ const radius = {
63
+ 'Demo site': 6,
64
+ 'Associated region': 5,
65
+ };
43
66
 
44
67
  return cases.map((c, index) => {
45
68
  const {
@@ -65,7 +88,9 @@ export function getFeatures(cases) {
65
88
  description: c.properties.description,
66
89
  index: index,
67
90
  path: c.properties.path,
68
- color: c.properties.nwrm_type === 'Light' ? '#50B0A4' : '#0083E0',
91
+ color: colors[c.properties.objective] || '#B83230',
92
+ width: width[c.properties.type_is_region],
93
+ radius: radius[c.properties.type_is_region],
69
94
  },
70
95
  false,
71
96
  );
@@ -73,53 +98,38 @@ export function getFeatures(cases) {
73
98
  });
74
99
  }
75
100
 
76
- export function filterCases(cases, activeFilters, demoSitesIds, searchInput) {
101
+ export function filterCases(cases, activeFilters, demoSitesIds) {
77
102
  const data = cases.filter((_case) => {
78
- let flag_searchInput = false;
79
103
  let flag_objective = false;
80
- // let flag_indicator = false;
104
+ let flag_indicator = false;
81
105
  let flag_project = false;
82
106
  let flag_country = false;
83
107
  let flag_case = demoSitesIds
84
108
  ? demoSitesIds.includes(_case.properties.url.split('/').pop())
85
109
  : true;
86
110
 
87
- if (!searchInput) {
88
- flag_searchInput = true;
89
- } else {
90
- if (_case.properties.title.toLowerCase().match(searchInput)) {
91
- flag_searchInput = true;
92
- // } else if (
93
- // _case.properties.description.toLowerCase().match(searchInput)
94
- // ) {
95
- // flag_searchInput = true;
96
- }
97
- }
98
-
99
111
  // debugger;
100
112
  if (!activeFilters.objective_filter.length) {
101
113
  flag_objective = true;
102
114
  } else {
103
- let objective = _case.properties.objective?.map((item) => {
104
- return item['id'].toString();
105
- });
115
+ let objective = _case.properties.objective;
106
116
 
107
117
  activeFilters.objective_filter.forEach((filter) => {
108
- if (objective?.includes(filter)) flag_objective = true;
118
+ if (objective === filter) flag_objective = true;
109
119
  });
110
120
  }
111
121
 
112
- // if (!activeFilters.sectors.length) {
113
- // flag_sectors = true;
114
- // } else {
115
- // let sectors = _case.properties.sectors?.map((item) => {
116
- // return item.toString();
117
- // });
122
+ if (!activeFilters.indicator_filter.length) {
123
+ flag_indicator = true;
124
+ } else {
125
+ let indicators = _case.properties.indicators?.map((item) => {
126
+ return item['id'].toString();
127
+ });
118
128
 
119
- // activeFilters.sectors.forEach((filter) => {
120
- // if (sectors?.includes(filter)) flag_sectors = true;
121
- // });
122
- // }
129
+ activeFilters.indicator_filter.forEach((filter) => {
130
+ if (indicators?.includes(filter)) flag_indicator = true;
131
+ });
132
+ }
123
133
 
124
134
  if (!activeFilters.project_filter.length) {
125
135
  flag_project = true;
@@ -145,9 +155,9 @@ export function filterCases(cases, activeFilters, demoSitesIds, searchInput) {
145
155
 
146
156
  return flag_case &&
147
157
  flag_objective &&
158
+ flag_indicator &&
148
159
  flag_country &&
149
- flag_project &&
150
- flag_searchInput
160
+ flag_project
151
161
  ? _case
152
162
  : false;
153
163
  });
@@ -166,23 +176,31 @@ export function getFilters(cases) {
166
176
  for (let key of Object.keys(cases)) {
167
177
  const _case = cases[key];
168
178
  // debugger;
169
- // let nwrms_implemented = _case.properties.measures;
170
- // nwrms_implemented.map((item) => {
171
- // if (!_filters.nwrms_implemented.hasOwnProperty(item['id'])) {
172
- // _filters.nwrms_implemented[item['id']] = item['title'];
173
- // }
174
- // return [];
175
- // });
176
179
 
177
- let project = _case.properties.project;
180
+ let indicators = _case.properties.indicators;
181
+ indicators.map((item) => {
182
+ if (
183
+ item['title'] &&
184
+ !_filters.indicator_filter.hasOwnProperty(item['id'])
185
+ ) {
186
+ _filters.indicator_filter[item['id']] = item['title'];
187
+ }
188
+ return [];
189
+ });
178
190
 
179
- if (!_filters.project_filter.hasOwnProperty(project)) {
191
+ let objective = _case.properties.objective;
192
+ if (objective && !_filters.objective_filter.hasOwnProperty(objective)) {
193
+ _filters.objective_filter[objective] = objective;
194
+ }
195
+
196
+ let project = _case.properties.project;
197
+ if (project && !_filters.project_filter.hasOwnProperty(project)) {
180
198
  _filters.project_filter[project] = project;
181
199
  }
182
200
 
183
- let countries = _case.properties.country;
201
+ let countries = _case.properties.country || [];
184
202
  countries.map((item) => {
185
- if (!_filters.country_filter.hasOwnProperty(item)) {
203
+ if (item && !_filters.country_filter.hasOwnProperty(item)) {
186
204
  _filters.country_filter[item] = item;
187
205
  }
188
206
  return [];