@eeacms/volto-cca-policy 0.2.45 → 0.2.47
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 +11 -8
- package/package.json +1 -1
- package/src/components/theme/Views/CcaEventView.jsx +6 -0
- package/src/components/theme/Widgets/GeolocationWidget.jsx +39 -70
- package/src/components/theme/Widgets/GeolocationWidget.test.jsx +45 -0
- package/src/components/theme/Widgets/GeolocationWidgetMapContainer.jsx +63 -0
- package/src/components/theme/Widgets/__mocks__/GeolocationWidgetMapContainer.jsx +3 -0
- package/src/index.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +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
|
+
### [0.2.47](https://github.com/eea/volto-cca-policy/compare/0.2.46...0.2.47) - 2 July 2024
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Tests [Tiberiu Ichim - [`d2cb56d`](https://github.com/eea/volto-cca-policy/commit/d2cb56d7b939c79fc025890110adb281cc68f570)]
|
|
12
|
+
- Tests [Tiberiu Ichim - [`73a4c47`](https://github.com/eea/volto-cca-policy/commit/73a4c47d243e866305c951b37c70ea75873b93db)]
|
|
13
|
+
- Tests [Tiberiu Ichim - [`afc6684`](https://github.com/eea/volto-cca-policy/commit/afc66846fc40bedeefb18e4a2f7fc8c0ec5c59f1)]
|
|
14
|
+
- Tests [Tiberiu Ichim - [`72e29dd`](https://github.com/eea/volto-cca-policy/commit/72e29dd6bfed94b67c92c5f6e02fcfc3bad299bb)]
|
|
15
|
+
- Show subtitle in the cca event title block [Tiberiu Ichim - [`e3fee69`](https://github.com/eea/volto-cca-policy/commit/e3fee690b3562138d67d01c8fa00453285631614)]
|
|
16
|
+
### [0.2.46](https://github.com/eea/volto-cca-policy/compare/0.2.45...0.2.46) - 1 July 2024
|
|
17
|
+
|
|
7
18
|
### [0.2.45](https://github.com/eea/volto-cca-policy/compare/0.2.44...0.2.45) - 24 June 2024
|
|
8
19
|
|
|
9
20
|
### [0.2.44](https://github.com/eea/volto-cca-policy/compare/0.2.43...0.2.44) - 20 June 2024
|
|
@@ -1409,13 +1420,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
1409
1420
|
- Refs #260715 rast-block wip [Tripon Eugen - [`f19d54e`](https://github.com/eea/volto-cca-policy/commit/f19d54e0b9a6a86bf344eb85b6a1cda7f3de91bf)]
|
|
1410
1421
|
- Refs #260715 rast-block wip [Tripon Eugen - [`2828537`](https://github.com/eea/volto-cca-policy/commit/2828537b6c084cd1a82162d552fb4ef025b71f9f)]
|
|
1411
1422
|
- Refs #260715 rast-block updates [Tripon Eugen - [`1e803e5`](https://github.com/eea/volto-cca-policy/commit/1e803e5bd3d3fb7558f261c76c68866be7beb8b5)]
|
|
1412
|
-
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`0a15e1b`](https://github.com/eea/volto-cca-policy/commit/0a15e1b2ad081233685e80d5b3c60a8663f6b896)]
|
|
1413
|
-
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`9554e44`](https://github.com/eea/volto-cca-policy/commit/9554e44c92a621a52b2adb5a4830fb084ee5734b)]
|
|
1414
1423
|
### [0.1.49](https://github.com/eea/volto-cca-policy/compare/0.1.48...0.1.49) - 15 November 2023
|
|
1415
1424
|
|
|
1416
1425
|
#### :house: Internal changes
|
|
1417
1426
|
|
|
1418
|
-
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`7b820a6`](https://github.com/eea/volto-cca-policy/commit/7b820a6369c2ddd5203b1a4abe352cb4bb43db7a)]
|
|
1419
1427
|
- chore: husky, lint-staged use fixed versions [valentinab25 - [`f0a8061`](https://github.com/eea/volto-cca-policy/commit/f0a8061c275c236deb00087c23fac9860a073106)]
|
|
1420
1428
|
|
|
1421
1429
|
#### :hammer_and_wrench: Others
|
|
@@ -1432,9 +1440,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
1432
1440
|
- Refs #259267 - jenkins test [Tripon Eugen - [`cacd31e`](https://github.com/eea/volto-cca-policy/commit/cacd31e7b1afe0983674ed5c7632d2e1d7fa752e)]
|
|
1433
1441
|
- Refs #259267 - jenkins [Tripon Eugen - [`5b3affe`](https://github.com/eea/volto-cca-policy/commit/5b3affee8401239de10097884c1b7f2349d15ec0)]
|
|
1434
1442
|
- Refs #259267 - add When, lead image and title to files [Tripon Eugen - [`2cedb23`](https://github.com/eea/volto-cca-policy/commit/2cedb237f898af9057e13fba94b615ef71077204)]
|
|
1435
|
-
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`4d607a5`](https://github.com/eea/volto-cca-policy/commit/4d607a576e9d0a5c34e48c41b409e7df616ee3d6)]
|
|
1436
|
-
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`b7f74d5`](https://github.com/eea/volto-cca-policy/commit/b7f74d53513a6edbfbca5cb6d19687929bb1e5db)]
|
|
1437
|
-
- test: [JENKINS] Improve cypress time [valentinab25 - [`db65617`](https://github.com/eea/volto-cca-policy/commit/db656173391f65157098d95d388c25f6429753d8)]
|
|
1438
1443
|
- Refs #259267 - cca event blocks attachments and check not mandatoty fields [Tripon Eugen - [`3138e5a`](https://github.com/eea/volto-cca-policy/commit/3138e5afb5bfbdbed14e27ed457b16867b7fa414)]
|
|
1439
1444
|
- Refs #256681 - Fix error in CCA Event view menu. ([React Intl] An id must be provided to format a message.) [GhitaB - [`517eeb8`](https://github.com/eea/volto-cca-policy/commit/517eeb817264a47bbfd6b9b7d22aaf22d44ed224)]
|
|
1440
1445
|
- Refs #161485 - Fix ECDE name conflict. [GhitaB - [`8bfd99f`](https://github.com/eea/volto-cca-policy/commit/8bfd99ff68bb82a04d1c0ed625fa514fcf46289e)]
|
|
@@ -1651,7 +1656,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
1651
1656
|
|
|
1652
1657
|
#### :house: Internal changes
|
|
1653
1658
|
|
|
1654
|
-
- chore: [JENKINS] Remove alpha testing version [valentinab25 - [`ad1ced0`](https://github.com/eea/volto-cca-policy/commit/ad1ced0971ba116c13a3b5fcc039172cc915c919)]
|
|
1655
1659
|
|
|
1656
1660
|
#### :hammer_and_wrench: Others
|
|
1657
1661
|
|
|
@@ -2132,7 +2136,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
2132
2136
|
#### :hammer_and_wrench: Others
|
|
2133
2137
|
|
|
2134
2138
|
- Refs #158294 - Update supported languages list. [GhitaB - [`0a4f91f`](https://github.com/eea/volto-cca-policy/commit/0a4f91f39b7edc367bd4c127d6a8f273c7788361)]
|
|
2135
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`8f1f9ce`](https://github.com/eea/volto-cca-policy/commit/8f1f9ce6c22805670cc0800d3c779b6d619d0f31)]
|
|
2136
2139
|
### [0.1.1](https://github.com/eea/volto-cca-policy/compare/0.1.0...0.1.1) - 13 December 2022
|
|
2137
2140
|
|
|
2138
2141
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -51,6 +51,12 @@ function CcaEventView(props) {
|
|
|
51
51
|
blocks: filtered_blocks,
|
|
52
52
|
blocks_layout: filtered_blocks_layout,
|
|
53
53
|
} = filterBlocks(content, 'tabs_block');
|
|
54
|
+
const titleBlock = Object.values(filtered_blocks).find(
|
|
55
|
+
(block) => block['@type'] === 'title',
|
|
56
|
+
);
|
|
57
|
+
if (titleBlock && !titleBlock.subtitle && content.subtitle) {
|
|
58
|
+
titleBlock.subtitle = content.subtitle;
|
|
59
|
+
}
|
|
54
60
|
|
|
55
61
|
return (
|
|
56
62
|
<div className="cca-event-view">
|
|
@@ -1,93 +1,59 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Input } from 'semantic-ui-react';
|
|
4
|
+
import config from '@plone/volto/registry';
|
|
4
5
|
|
|
5
6
|
import { injectIntl } from 'react-intl';
|
|
6
7
|
import { FormFieldWrapper } from '@plone/volto/components';
|
|
8
|
+
import MapContainer from '@eeacms/volto-cca-policy/components/theme/Widgets/GeolocationWidgetMapContainer';
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Layer,
|
|
12
|
-
Map,
|
|
13
|
-
Layers,
|
|
14
|
-
} from '@eeacms/volto-openlayers-map/api';
|
|
15
|
-
import { openlayers as ol } from '@eeacms/volto-openlayers-map';
|
|
16
|
-
|
|
17
|
-
const MapContainer = (props) => {
|
|
18
|
-
const { longitude, latitude, source } = props;
|
|
19
|
-
return (
|
|
20
|
-
<Map
|
|
21
|
-
view={{
|
|
22
|
-
center: ol.proj.fromLonLat([longitude, latitude]),
|
|
23
|
-
showFullExtent: true,
|
|
24
|
-
zoom: 15,
|
|
25
|
-
}}
|
|
26
|
-
pixelRatio={1}
|
|
27
|
-
controls={ol.control.defaults({ attribution: false })}
|
|
28
|
-
>
|
|
29
|
-
<Layers>
|
|
30
|
-
<Controls attribution={false} zoom={false} />
|
|
31
|
-
<Interactions
|
|
32
|
-
doubleClickZoom={true}
|
|
33
|
-
dragAndDrop={false}
|
|
34
|
-
dragPan={true}
|
|
35
|
-
keyboardPan={true}
|
|
36
|
-
keyboardZoom={true}
|
|
37
|
-
mouseWheelZoom={true}
|
|
38
|
-
pointer={true}
|
|
39
|
-
select={false}
|
|
40
|
-
/>
|
|
41
|
-
<Layer.Tile source={source} zIndex={0} />
|
|
42
|
-
</Layers>
|
|
43
|
-
</Map>
|
|
44
|
-
);
|
|
10
|
+
const defaultValue = {
|
|
11
|
+
latitude: 55.6761,
|
|
12
|
+
longitude: 12.5683,
|
|
45
13
|
};
|
|
46
14
|
|
|
47
15
|
const GeolocationWidget = (props) => {
|
|
48
16
|
const { id, value, onChange } = props;
|
|
49
17
|
|
|
50
|
-
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
51
18
|
const [address, setAddress] = useState('');
|
|
52
19
|
|
|
53
20
|
const handleAddressChange = (event) => {
|
|
54
21
|
setAddress(event.target.value);
|
|
55
22
|
};
|
|
56
23
|
|
|
57
|
-
const
|
|
58
|
-
latitude: 55.6761,
|
|
59
|
-
longitude: 12.5683,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const handleSearch = (e) => {
|
|
24
|
+
const handleSearch = async (e) => {
|
|
63
25
|
e.preventDefault();
|
|
64
26
|
|
|
65
|
-
|
|
66
|
-
.then((response) => {
|
|
67
|
-
const { lat, lon } = response.data[0];
|
|
68
|
-
onChange(id, { latitude: lat, longitude: lon });
|
|
69
|
-
})
|
|
70
|
-
.catch((error) => {
|
|
71
|
-
// console.error(error);
|
|
72
|
-
});
|
|
73
|
-
};
|
|
27
|
+
const url = `https://nominatim.openstreetmap.org/search?q=${address}&format=json`;
|
|
74
28
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
29
|
+
const { corsProxyPath = '/cors-proxy', host, port } = config.settings;
|
|
30
|
+
const base = __SERVER__
|
|
31
|
+
? `http://${host}:${port}`
|
|
32
|
+
: `${window.location.protocol}//${window.location.host}`;
|
|
33
|
+
|
|
34
|
+
const path = `${base}${corsProxyPath}/${url}`;
|
|
35
|
+
|
|
36
|
+
let locations;
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(path);
|
|
39
|
+
locations = await response.json();
|
|
40
|
+
} catch (e) {
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.log('error in fetching location', e);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (locations?.length) {
|
|
46
|
+
const { lat, lon } = locations[0];
|
|
47
|
+
onChange(id, { latitude: lat, longitude: lon });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
88
50
|
|
|
89
51
|
if (__SERVER__) return '';
|
|
90
52
|
|
|
53
|
+
const lat = value?.latitude ?? defaultValue.latitude;
|
|
54
|
+
const long = value?.longitude ?? defaultValue.longitude;
|
|
55
|
+
const mapKey = `${lat}_${long}`;
|
|
56
|
+
|
|
91
57
|
return (
|
|
92
58
|
<FormFieldWrapper {...props} className="geolocation-field">
|
|
93
59
|
<div className="ui form">
|
|
@@ -101,12 +67,9 @@ const GeolocationWidget = (props) => {
|
|
|
101
67
|
</div>
|
|
102
68
|
</div>
|
|
103
69
|
<MapContainer
|
|
104
|
-
key={
|
|
105
|
-
value?.longitude || defaultValue.longitude
|
|
106
|
-
}`}
|
|
70
|
+
key={mapKey}
|
|
107
71
|
longitude={value?.longitude || defaultValue.longitude}
|
|
108
72
|
latitude={value?.latitude || defaultValue.latitude}
|
|
109
|
-
source={tileWMSSources[0]}
|
|
110
73
|
/>
|
|
111
74
|
<div className="ui form">
|
|
112
75
|
<div className="inline fields">
|
|
@@ -115,6 +78,9 @@ const GeolocationWidget = (props) => {
|
|
|
115
78
|
type="number"
|
|
116
79
|
placeholder="latitude"
|
|
117
80
|
value={value?.latitude || defaultValue.latitude}
|
|
81
|
+
onChange={(e) =>
|
|
82
|
+
onChange(id, { ...value, latitude: e.target.value })
|
|
83
|
+
}
|
|
118
84
|
/>
|
|
119
85
|
</div>
|
|
120
86
|
<div className="field">
|
|
@@ -122,6 +88,9 @@ const GeolocationWidget = (props) => {
|
|
|
122
88
|
type="number"
|
|
123
89
|
placeholder="longitude"
|
|
124
90
|
value={value?.longitude || defaultValue.longitude}
|
|
91
|
+
onChange={(e) =>
|
|
92
|
+
onChange(id, { ...value, longitude: e.target.value })
|
|
93
|
+
}
|
|
125
94
|
/>
|
|
126
95
|
</div>
|
|
127
96
|
</div>
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
|
|
8
|
+
import GeolocationWidget from './GeolocationWidget';
|
|
9
|
+
|
|
10
|
+
global.__SERVER__ = false;
|
|
11
|
+
|
|
12
|
+
jest.mock(
|
|
13
|
+
'@eeacms/volto-cca-policy/components/theme/Widgets/GeolocationWidgetMapContainer',
|
|
14
|
+
);
|
|
15
|
+
const mockStore = configureStore();
|
|
16
|
+
|
|
17
|
+
describe('GeolocationWidget', () => {
|
|
18
|
+
it('should render the component', () => {
|
|
19
|
+
const data = {
|
|
20
|
+
id: 'location',
|
|
21
|
+
title: 'Location',
|
|
22
|
+
value: {
|
|
23
|
+
latitude: 10,
|
|
24
|
+
longitude: 50,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const store = mockStore({
|
|
29
|
+
userSession: { token: '1234' },
|
|
30
|
+
intl: {
|
|
31
|
+
locale: 'en',
|
|
32
|
+
messages: {},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const { container } = render(
|
|
37
|
+
<Provider store={store}>
|
|
38
|
+
<MemoryRouter>
|
|
39
|
+
<GeolocationWidget {...data} />
|
|
40
|
+
</MemoryRouter>
|
|
41
|
+
</Provider>,
|
|
42
|
+
);
|
|
43
|
+
expect(container).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Controls,
|
|
4
|
+
Interactions,
|
|
5
|
+
Layer,
|
|
6
|
+
Map,
|
|
7
|
+
Layers,
|
|
8
|
+
} from '@eeacms/volto-openlayers-map/api';
|
|
9
|
+
import { openlayers as ol } from '@eeacms/volto-openlayers-map';
|
|
10
|
+
|
|
11
|
+
const TileSetLoader = (props) => {
|
|
12
|
+
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
13
|
+
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
setTileWMSSources([
|
|
16
|
+
new ol.source.TileWMS({
|
|
17
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
18
|
+
params: {
|
|
19
|
+
LAYERS: 'OSMBlossomComposite',
|
|
20
|
+
TILED: true,
|
|
21
|
+
},
|
|
22
|
+
serverType: 'geoserver',
|
|
23
|
+
transition: 0,
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
return tileWMSSources ? (
|
|
29
|
+
<MapContainer {...props} source={tileWMSSources[0]} />
|
|
30
|
+
) : null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const MapContainer = (props) => {
|
|
34
|
+
const { longitude, latitude, source } = props;
|
|
35
|
+
return (
|
|
36
|
+
<Map
|
|
37
|
+
view={{
|
|
38
|
+
center: ol.proj.fromLonLat([longitude, latitude]),
|
|
39
|
+
showFullExtent: true,
|
|
40
|
+
zoom: 15,
|
|
41
|
+
}}
|
|
42
|
+
pixelRatio={1}
|
|
43
|
+
controls={ol.control.defaults({ attribution: false })}
|
|
44
|
+
>
|
|
45
|
+
<Layers>
|
|
46
|
+
<Controls attribution={false} zoom={false} />
|
|
47
|
+
<Interactions
|
|
48
|
+
doubleClickZoom={true}
|
|
49
|
+
dragAndDrop={false}
|
|
50
|
+
dragPan={true}
|
|
51
|
+
keyboardPan={true}
|
|
52
|
+
keyboardZoom={true}
|
|
53
|
+
mouseWheelZoom={true}
|
|
54
|
+
pointer={true}
|
|
55
|
+
select={false}
|
|
56
|
+
/>
|
|
57
|
+
<Layer.Tile source={source} zIndex={0} />
|
|
58
|
+
</Layers>
|
|
59
|
+
</Map>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default TileSetLoader;
|
package/src/index.js
CHANGED
|
@@ -70,6 +70,11 @@ const applyConfig = (config) => {
|
|
|
70
70
|
];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
config.settings.allowed_cors_destinations = [
|
|
74
|
+
...(config.settings.allowed_cors_destinations || []),
|
|
75
|
+
'nominatim.openstreetmap.org',
|
|
76
|
+
];
|
|
77
|
+
|
|
73
78
|
// if (!config.settings.loadables.d3)
|
|
74
79
|
// config.settings.loadables.d3 = loadable.lib(() => import('d3'));
|
|
75
80
|
// if (!config.settings.loadables.d3Geo)
|