@eeacms/volto-marine-policy 2.0.5 → 2.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 +10 -0
- package/package.json +1 -1
- package/src/components/Blocks/DemoSitesExplorer/DemoSitesExplorerView.js +20 -21
- package/src/components/Blocks/DemoSitesExplorer/DemoSitesFilters.jsx +25 -20
- package/src/components/Blocks/DemoSitesExplorer/DemoSitesMap.jsx +17 -19
- package/src/components/Blocks/DemoSitesExplorer/FeatureDisplay.jsx +1 -1
- package/src/components/Blocks/DemoSitesExplorer/FeatureInteraction.jsx +7 -12
- package/src/components/Blocks/DemoSitesExplorer/InfoOverlay.jsx +3 -6
- package/src/components/Blocks/DemoSitesExplorer/utils.js +35 -8
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ 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.6](https://github.com/eea/volto-marine-policy/compare/2.0.5...2.0.6) - 14 April 2025
|
|
8
|
+
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
- style: Automated code fix [eea-jenkins - [`ae829bf`](https://github.com/eea/volto-marine-policy/commit/ae829bf49e357dc02128ff0dc4227e146ed06c0d)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- fix eslint [laszlocseh - [`6e84248`](https://github.com/eea/volto-marine-policy/commit/6e8424833cbe25badb6bc4ba040048422878895f)]
|
|
16
|
+
- updates to demo sites map viewer [laszlocseh - [`19dc3da`](https://github.com/eea/volto-marine-policy/commit/19dc3dac8ac9ef8f91961d0ecf7878cf7b9660a4)]
|
|
7
17
|
### [2.0.5](https://github.com/eea/volto-marine-policy/compare/2.0.4...2.0.5) - 11 April 2025
|
|
8
18
|
|
|
9
19
|
#### :house: Internal changes
|
package/package.json
CHANGED
|
@@ -14,11 +14,12 @@ export default function DemoSitesExplorerView(props) {
|
|
|
14
14
|
const cases_url = config.settings.prefixPath
|
|
15
15
|
? '/@@demo-sites-map.arcgis.json'
|
|
16
16
|
: '/marine/@@demo-sites-map.arcgis.json';
|
|
17
|
-
|
|
18
17
|
let cases = useCases(addAppURL(cases_url));
|
|
19
|
-
const { demoSitesIds } = props; // case studies from measure view
|
|
20
18
|
const [selectedCase, onSelectedCase] = React.useState(null);
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
const { properties } = props;
|
|
21
|
+
const hideFilters = properties['@type'] === 'indicator_mo' ? true : false;
|
|
22
|
+
const indicatorOnly = hideFilters ? properties['title'] : null;
|
|
22
23
|
|
|
23
24
|
const [activeFilters, setActiveFilters] = React.useState({
|
|
24
25
|
objective_filter: [],
|
|
@@ -32,7 +33,7 @@ export default function DemoSitesExplorerView(props) {
|
|
|
32
33
|
const [map, setMap] = React.useState();
|
|
33
34
|
|
|
34
35
|
React.useEffect(() => {
|
|
35
|
-
const _filters = getFilters(cases);
|
|
36
|
+
const _filters = getFilters(cases, indicatorOnly);
|
|
36
37
|
setFilters(_filters);
|
|
37
38
|
}, [
|
|
38
39
|
cases,
|
|
@@ -41,36 +42,34 @@ export default function DemoSitesExplorerView(props) {
|
|
|
41
42
|
activeFilters.project_filter,
|
|
42
43
|
activeFilters.country_filter,
|
|
43
44
|
activeItems.length,
|
|
45
|
+
indicatorOnly,
|
|
44
46
|
]);
|
|
45
47
|
|
|
46
48
|
React.useEffect(() => {
|
|
47
|
-
let activeItems = filterCases(cases, activeFilters,
|
|
49
|
+
let activeItems = filterCases(cases, activeFilters, indicatorOnly);
|
|
48
50
|
|
|
49
51
|
setActiveItems(activeItems);
|
|
50
|
-
}, [
|
|
52
|
+
}, [activeFilters, cases, indicatorOnly]);
|
|
51
53
|
|
|
52
54
|
if (__SERVER__) return '';
|
|
53
55
|
|
|
54
56
|
return (
|
|
55
57
|
<div className="searchlib-block">
|
|
56
58
|
<Grid.Row>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
59
|
+
<ActiveFilters
|
|
60
|
+
filters={filters}
|
|
61
|
+
activeFilters={activeFilters}
|
|
62
|
+
setActiveFilters={setActiveFilters}
|
|
63
|
+
/>
|
|
64
64
|
</Grid.Row>
|
|
65
65
|
<Grid.Row stretched={true} id="cse-filter">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)}
|
|
66
|
+
<DemoSitesFilters
|
|
67
|
+
filters={filters}
|
|
68
|
+
activeFilters={activeFilters}
|
|
69
|
+
hideFilters={hideFilters}
|
|
70
|
+
setActiveFilters={setActiveFilters}
|
|
71
|
+
map={map}
|
|
72
|
+
/>
|
|
74
73
|
</Grid.Row>
|
|
75
74
|
<Grid.Row>
|
|
76
75
|
{cases.length ? (
|
|
@@ -101,7 +101,7 @@ export function DemoSitesFilter(props) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export function DemoSitesFilters(props) {
|
|
104
|
-
const { filters, activeFilters, setActiveFilters, map } = props;
|
|
104
|
+
const { filters, activeFilters, hideFilters, setActiveFilters, map } = props;
|
|
105
105
|
|
|
106
106
|
React.useEffect(() => {
|
|
107
107
|
window.addEventListener('click', (event) => {
|
|
@@ -117,24 +117,30 @@ export function DemoSitesFilters(props) {
|
|
|
117
117
|
|
|
118
118
|
return (
|
|
119
119
|
<>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
120
|
+
{!hideFilters ? (
|
|
121
|
+
<DemoSitesFilter
|
|
122
|
+
filterTitle="Objective"
|
|
123
|
+
filterName="objective_filter"
|
|
124
|
+
filters={filters}
|
|
125
|
+
activeFilters={activeFilters}
|
|
126
|
+
setActiveFilters={setActiveFilters}
|
|
127
|
+
map={map}
|
|
128
|
+
/>
|
|
129
|
+
) : (
|
|
130
|
+
''
|
|
131
|
+
)}
|
|
132
|
+
{!hideFilters ? (
|
|
133
|
+
<DemoSitesFilter
|
|
134
|
+
filterTitle="Indicator"
|
|
135
|
+
filterName="indicator_filter"
|
|
136
|
+
filters={filters}
|
|
137
|
+
activeFilters={activeFilters}
|
|
138
|
+
setActiveFilters={setActiveFilters}
|
|
139
|
+
map={map}
|
|
140
|
+
/>
|
|
141
|
+
) : (
|
|
142
|
+
''
|
|
143
|
+
)}
|
|
138
144
|
<DemoSitesFilter
|
|
139
145
|
filterTitle="Project"
|
|
140
146
|
filterName="project_filter"
|
|
@@ -143,7 +149,6 @@ export function DemoSitesFilters(props) {
|
|
|
143
149
|
setActiveFilters={setActiveFilters}
|
|
144
150
|
map={map}
|
|
145
151
|
/>
|
|
146
|
-
|
|
147
152
|
<DemoSitesFilter
|
|
148
153
|
filterTitle="Country"
|
|
149
154
|
filterName="country_filter"
|
|
@@ -126,23 +126,21 @@ export default function DemoSitesMap(props) {
|
|
|
126
126
|
>
|
|
127
127
|
<Controls attribution={false} />
|
|
128
128
|
<Layers>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
</button>
|
|
145
|
-
)}
|
|
129
|
+
<button
|
|
130
|
+
className={cx(
|
|
131
|
+
'reset-map-button ui button secondary',
|
|
132
|
+
String(resetMapButtonClass),
|
|
133
|
+
)}
|
|
134
|
+
onClick={() => {
|
|
135
|
+
// scrollToElement('search-input');
|
|
136
|
+
onSelectedCase(null);
|
|
137
|
+
centerAndResetMapZoom(map);
|
|
138
|
+
map.getInteractions().array_[9].getFeatures().clear();
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<span className="result-info-title">Reset map</span>
|
|
142
|
+
<i className="icon ri-map-2-line"></i>
|
|
143
|
+
</button>
|
|
146
144
|
<InfoOverlay
|
|
147
145
|
selectedFeature={selectedCase}
|
|
148
146
|
onFeatureSelect={onSelectedCase}
|
|
@@ -151,8 +149,8 @@ export default function DemoSitesMap(props) {
|
|
|
151
149
|
/>
|
|
152
150
|
<FeatureInteraction
|
|
153
151
|
onFeatureSelect={onSelectedCase}
|
|
154
|
-
hideFilters={hideFilters}
|
|
155
|
-
selectedCase={selectedCase}
|
|
152
|
+
// hideFilters={hideFilters}
|
|
153
|
+
// selectedCase={selectedCase}
|
|
156
154
|
/>
|
|
157
155
|
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
158
156
|
<Layer.Vector
|
|
@@ -35,18 +35,14 @@ export const useStyles = () => {
|
|
|
35
35
|
return { selected, selectStyle };
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export default function FeatureInteraction({
|
|
39
|
-
onFeatureSelect,
|
|
40
|
-
hideFilters,
|
|
41
|
-
selectedCase,
|
|
42
|
-
}) {
|
|
38
|
+
export default function FeatureInteraction({ onFeatureSelect }) {
|
|
43
39
|
// console.log('featureinteraction', selectedCase);
|
|
44
40
|
const { map } = useMapContext();
|
|
45
41
|
const { selectStyle } = useStyles();
|
|
46
42
|
|
|
47
43
|
const select = new ol.interaction.Select({
|
|
48
44
|
condition: ol.condition.click,
|
|
49
|
-
style:
|
|
45
|
+
style: selectStyle,
|
|
50
46
|
});
|
|
51
47
|
|
|
52
48
|
React.useEffect(() => {
|
|
@@ -59,11 +55,10 @@ export default function FeatureInteraction({
|
|
|
59
55
|
const subfeatures = feature.values_.features;
|
|
60
56
|
if (subfeatures.length === 1) {
|
|
61
57
|
const selectedFeature = subfeatures[0].values_;
|
|
62
|
-
if (hideFilters) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
58
|
+
// if (hideFilters) {
|
|
59
|
+
// const url = window.location.origin + selectedFeature.path;
|
|
60
|
+
// window.location.href = url;
|
|
61
|
+
// }
|
|
67
62
|
onFeatureSelect(selectedFeature);
|
|
68
63
|
// scrollToElement('ol-map-container');
|
|
69
64
|
// map.getView().animate({
|
|
@@ -89,7 +84,7 @@ export default function FeatureInteraction({
|
|
|
89
84
|
|
|
90
85
|
return () => map.removeInteraction(select);
|
|
91
86
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
92
|
-
}, [map, selectStyle, onFeatureSelect
|
|
87
|
+
}, [map, selectStyle, onFeatureSelect]);
|
|
93
88
|
|
|
94
89
|
return null;
|
|
95
90
|
}
|
|
@@ -8,7 +8,7 @@ export default function InfoOverlay({
|
|
|
8
8
|
selectedFeature,
|
|
9
9
|
onFeatureSelect,
|
|
10
10
|
layerId,
|
|
11
|
-
hideFilters,
|
|
11
|
+
// hideFilters,
|
|
12
12
|
}) {
|
|
13
13
|
const { map } = useMapContext();
|
|
14
14
|
const [tooltip, setTooltipRef] = React.useState();
|
|
@@ -38,10 +38,7 @@ export default function InfoOverlay({
|
|
|
38
38
|
const features = target.getFeaturesAtPixel(pixel);
|
|
39
39
|
// const popupOverlay = overlay.element; // document.getElementById('popup-overlay');
|
|
40
40
|
|
|
41
|
-
if (
|
|
42
|
-
features.length &&
|
|
43
|
-
!hideFilters // && !isCluster(features)
|
|
44
|
-
) {
|
|
41
|
+
if (features.length) {
|
|
45
42
|
setShowTooltip(true);
|
|
46
43
|
} else {
|
|
47
44
|
// handle a click in an overlay popup
|
|
@@ -58,7 +55,7 @@ export default function InfoOverlay({
|
|
|
58
55
|
map.un('click', handler);
|
|
59
56
|
map.removeOverlay(overlay);
|
|
60
57
|
};
|
|
61
|
-
}, [map, tooltip, onFeatureSelect
|
|
58
|
+
}, [map, tooltip, onFeatureSelect]); //
|
|
62
59
|
|
|
63
60
|
const [isClient, setIsClient] = React.useState(false);
|
|
64
61
|
React.useEffect(() => setIsClient(true), []);
|
|
@@ -98,15 +98,22 @@ export function getFeatures(cases) {
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export function filterCases(cases, activeFilters,
|
|
101
|
+
export function filterCases(cases, activeFilters, indicatorOnly) {
|
|
102
102
|
const data = cases.filter((_case) => {
|
|
103
103
|
let flag_objective = false;
|
|
104
104
|
let flag_indicator = false;
|
|
105
105
|
let flag_project = false;
|
|
106
106
|
let flag_country = false;
|
|
107
|
-
let
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
let flag_indicatorOnly = false;
|
|
108
|
+
|
|
109
|
+
if (indicatorOnly) {
|
|
110
|
+
let indicators = _case.properties.indicators?.map((item) => {
|
|
111
|
+
return item['title'].toString();
|
|
112
|
+
});
|
|
113
|
+
if (indicators?.includes(indicatorOnly)) flag_indicatorOnly = true;
|
|
114
|
+
} else {
|
|
115
|
+
flag_indicatorOnly = true;
|
|
116
|
+
}
|
|
110
117
|
|
|
111
118
|
// debugger;
|
|
112
119
|
if (!activeFilters.objective_filter.length) {
|
|
@@ -153,7 +160,7 @@ export function filterCases(cases, activeFilters, demoSitesIds) {
|
|
|
153
160
|
});
|
|
154
161
|
}
|
|
155
162
|
|
|
156
|
-
return
|
|
163
|
+
return flag_indicatorOnly &&
|
|
157
164
|
flag_objective &&
|
|
158
165
|
flag_indicator &&
|
|
159
166
|
flag_country &&
|
|
@@ -165,7 +172,7 @@ export function filterCases(cases, activeFilters, demoSitesIds) {
|
|
|
165
172
|
return data;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
|
-
export function getFilters(cases) {
|
|
175
|
+
export function getFilters(cases, indicatorOnly) {
|
|
169
176
|
let _filters = {
|
|
170
177
|
objective_filter: {},
|
|
171
178
|
indicator_filter: {},
|
|
@@ -195,13 +202,33 @@ export function getFilters(cases) {
|
|
|
195
202
|
|
|
196
203
|
let project = _case.properties.project;
|
|
197
204
|
if (project && !_filters.project_filter.hasOwnProperty(project)) {
|
|
198
|
-
|
|
205
|
+
if (!indicatorOnly) {
|
|
206
|
+
_filters.project_filter[project] = project;
|
|
207
|
+
} else {
|
|
208
|
+
let indicators = _case.properties.indicators?.map((item) => {
|
|
209
|
+
return item['title'].toString();
|
|
210
|
+
});
|
|
211
|
+
if (indicators?.includes(indicatorOnly)) {
|
|
212
|
+
_filters.project_filter[project] = project;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// _filters.project_filter[project] = project;
|
|
199
216
|
}
|
|
200
217
|
|
|
201
218
|
let countries = _case.properties.country || [];
|
|
202
219
|
countries.map((item) => {
|
|
203
220
|
if (item && !_filters.country_filter.hasOwnProperty(item)) {
|
|
204
|
-
|
|
221
|
+
if (!indicatorOnly) {
|
|
222
|
+
_filters.country_filter[item] = item;
|
|
223
|
+
} else {
|
|
224
|
+
let indicators = _case.properties.indicators?.map((item) => {
|
|
225
|
+
return item['title'].toString();
|
|
226
|
+
});
|
|
227
|
+
if (indicators?.includes(indicatorOnly)) {
|
|
228
|
+
_filters.country_filter[item] = item;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// _filters.country_filter[item] = item;
|
|
205
232
|
}
|
|
206
233
|
return [];
|
|
207
234
|
});
|