@eeacms/volto-embed 9.0.5 → 9.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 +19 -17
- package/cypress.config.js +1 -1
- package/package.json +1 -1
- package/src/Blocks/EmbedMaps/View.jsx +67 -5
- package/src/Blocks/EmbedMaps/View.test.js +31 -0
- package/src/Blocks/EmbedMaps/schema.js +27 -0
- package/src/Blocks/Maps/Edit.test.js +26 -0
- package/src/EmbedMap/EmbedMap.jsx +17 -4
- package/src/EmbedMap/EmbedMap.test.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,25 @@ 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
|
-
### [9.0.
|
|
7
|
+
### [9.0.6](https://github.com/eea/volto-embed/compare/9.0.5...9.0.6) - 10 January 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat: filter embed map by data query + add option to give extra parameters [kreafox - [`c2331fb`](https://github.com/eea/volto-embed/commit/c2331fb1f3413c54d365cdbc701b37991e98dfda)]
|
|
12
|
+
|
|
13
|
+
#### :bug: Bug Fixes
|
|
14
|
+
|
|
15
|
+
- fix: handle case with multiple values [kreafox - [`ab3bfc4`](https://github.com/eea/volto-embed/commit/ab3bfc4b645671550fec3534ae7e25a6d7274ee5)]
|
|
16
|
+
- fix: missing map on view [kreafox - [`7481650`](https://github.com/eea/volto-embed/commit/748165070f109f2b09039882bb22451c520cbbba)]
|
|
17
|
+
|
|
18
|
+
#### :hammer_and_wrench: Others
|
|
19
|
+
|
|
20
|
+
- test: increase coverage [kreafox - [`2d8e43c`](https://github.com/eea/volto-embed/commit/2d8e43cf3988564306b6aa7b885b0ff398043ce0)]
|
|
21
|
+
- test: increase coverage [kreafox - [`1fa9052`](https://github.com/eea/volto-embed/commit/1fa9052a3c015361e3a7eae043c418b696262fbe)]
|
|
22
|
+
- test: increase cypress timeout [kreafox - [`9bb40a5`](https://github.com/eea/volto-embed/commit/9bb40a5df2b29a55edec24a57fcd6e65f270f13c)]
|
|
23
|
+
- test: updates [kreafox - [`5b54d02`](https://github.com/eea/volto-embed/commit/5b54d02c6b6392e25f07ef1e286bdbced999592e)]
|
|
24
|
+
- test: update snapshot [kreafox - [`338f23e`](https://github.com/eea/volto-embed/commit/338f23ee5c6c75ccb6ee2d8d474298553fe3bd53)]
|
|
25
|
+
### [9.0.5](https://github.com/eea/volto-embed/compare/9.0.4...9.0.5) - 14 December 2023
|
|
8
26
|
|
|
9
27
|
#### :bug: Bug Fixes
|
|
10
28
|
|
|
@@ -57,13 +75,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
57
75
|
- update [Miu Razvan - [`926beb8`](https://github.com/eea/volto-embed/commit/926beb87d2c44907aebe57369312eea7bf22d656)]
|
|
58
76
|
- update [Miu Razvan - [`da351ae`](https://github.com/eea/volto-embed/commit/da351ae9ffaaef756f7a665618a03fd04cb9b01d)]
|
|
59
77
|
- use volto-datablocks@develop dependency [Miu Razvan - [`b379d84`](https://github.com/eea/volto-embed/commit/b379d8478657dd39dad066181b349cee7ac2531d)]
|
|
60
|
-
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`ddf685a`](https://github.com/eea/volto-embed/commit/ddf685a9481d780a1df2e4f991f93676478c3e05)]
|
|
61
78
|
## [8.0.0](https://github.com/eea/volto-embed/compare/7.0.2...8.0.0) - 17 November 2023
|
|
62
79
|
|
|
63
80
|
#### :hammer_and_wrench: Others
|
|
64
81
|
|
|
65
82
|
- tests: add cypress tests [nileshgulia1 - [`e4b2803`](https://github.com/eea/volto-embed/commit/e4b28033114170639787d77976dc13b7f697f704)]
|
|
66
|
-
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`83d91d5`](https://github.com/eea/volto-embed/commit/83d91d5716a9ce8ebbbff01a7838711298684be4)]
|
|
67
83
|
- fix error [Claudia Ifrim - [`553f3af`](https://github.com/eea/volto-embed/commit/553f3af004af034c721dcd6b01de55c258a88c49)]
|
|
68
84
|
- bump version [Miu Razvan - [`363694a`](https://github.com/eea/volto-embed/commit/363694ae50cdec941fb53b396b75e9a4554d44fb)]
|
|
69
85
|
### [7.0.2](https://github.com/eea/volto-embed/compare/7.0.1...7.0.2) - 10 November 2023
|
|
@@ -73,7 +89,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
73
89
|
#### :hammer_and_wrench: Others
|
|
74
90
|
|
|
75
91
|
- add missing less variable [Miu Razvan - [`47683a7`](https://github.com/eea/volto-embed/commit/47683a7816581d117bb88f16e3087864aaa52f5e)]
|
|
76
|
-
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`ba168e4`](https://github.com/eea/volto-embed/commit/ba168e49554a51a6015a98a77dc0ceab76320218)]
|
|
77
92
|
## [7.0.0](https://github.com/eea/volto-embed/compare/6.0.1...7.0.0) - 6 November 2023
|
|
78
93
|
|
|
79
94
|
#### :rocket: New Features
|
|
@@ -83,15 +98,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
83
98
|
#### :house: Internal changes
|
|
84
99
|
|
|
85
100
|
- style: Automated code fix [eea-jenkins - [`c34d6f4`](https://github.com/eea/volto-embed/commit/c34d6f47fd33f728d40254a12c05fe385b27f2e9)]
|
|
86
|
-
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`673f3ff`](https://github.com/eea/volto-embed/commit/673f3ff355baa8d3646e4558ff2be00f36b5a45a)]
|
|
87
101
|
- chore: husky, lint-staged use fixed versions [valentinab25 - [`31169f7`](https://github.com/eea/volto-embed/commit/31169f73887837463daee76d63b6516046ad49aa)]
|
|
88
102
|
|
|
89
103
|
#### :hammer_and_wrench: Others
|
|
90
104
|
|
|
91
105
|
- update tests [Miu Razvan - [`c906b79`](https://github.com/eea/volto-embed/commit/c906b79149e853f718d924871ce2e633e5e427c8)]
|
|
92
106
|
- update tests [Miu Razvan - [`11625b6`](https://github.com/eea/volto-embed/commit/11625b65846388a846d1bdf7ebb2e1f8bd103c91)]
|
|
93
|
-
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`5e7a155`](https://github.com/eea/volto-embed/commit/5e7a15505334c9b81f07172116b49eaefc692ebf)]
|
|
94
|
-
- test: [JENKINS] Improve cypress time [valentinab25 - [`eeb6dcb`](https://github.com/eea/volto-embed/commit/eeb6dcb4b0f8af07496450e6e7783932ebe88bf7)]
|
|
95
107
|
- Release 7.0.0 [Alin Voinea - [`cbc5c79`](https://github.com/eea/volto-embed/commit/cbc5c79f1b66daf0d599d9de5a1bc7d137bafed8)]
|
|
96
108
|
- add act in unit tests [Miu Razvan - [`ecf5b2f`](https://github.com/eea/volto-embed/commit/ecf5b2fe553d99ad6a11570d3d34852d557fbe85)]
|
|
97
109
|
- update [Miu Razvan - [`049cc14`](https://github.com/eea/volto-embed/commit/049cc140bb6ffea4eb3f1555e693e9973ef63d0e)]
|
|
@@ -114,7 +126,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
114
126
|
|
|
115
127
|
- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`dc2de20`](https://github.com/eea/volto-embed/commit/dc2de2084b53043f240ee1efa2588b5037326ed7)]
|
|
116
128
|
- test: Fix package.json scripts to use makefile [Alin Voinea - [`b4ffca2`](https://github.com/eea/volto-embed/commit/b4ffca24bb8cc4ba2007cc1040cc7b55dc7cc779)]
|
|
117
|
-
- test: Fix eslint and yarn i18n [Alin Voinea - [`1563d0a`](https://github.com/eea/volto-embed/commit/1563d0ab1f54e775a16705bfd3d267303eb2a526)]
|
|
118
129
|
- i18n: Add en [Alin Voinea - [`b4e0694`](https://github.com/eea/volto-embed/commit/b4e0694ee40ecc195536fd1826adfab8876c5061)]
|
|
119
130
|
- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`8f228ca`](https://github.com/eea/volto-embed/commit/8f228ca0644cee0f777a01114895583f387a395c)]
|
|
120
131
|
- test: increase test coverage - refs #254313 [ana-oprea - [`30354d8`](https://github.com/eea/volto-embed/commit/30354d8a10a78e4fc322e37f4be20ff85cd00bbc)]
|
|
@@ -143,9 +154,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
143
154
|
|
|
144
155
|
- Add react-countup to resolutions [kreafox - [`36eb637`](https://github.com/eea/volto-embed/commit/36eb637c0cb9413b0b0e0ce53e621b2289929d65)]
|
|
145
156
|
- Move generic classes to privacy-protection [kreafox - [`715d559`](https://github.com/eea/volto-embed/commit/715d559e370bf7a3489b64d357b0a6cd7b1a3af2)]
|
|
146
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5715b4d`](https://github.com/eea/volto-embed/commit/5715b4d3fcc14a34e031c383275c685d88f4db44)]
|
|
147
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`ef24ac0`](https://github.com/eea/volto-embed/commit/ef24ac05b17f4f4dbf05ceafbee677012a7f28f5)]
|
|
148
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`81f957b`](https://github.com/eea/volto-embed/commit/81f957b51aef7be59214530b774de8547bee3f5f)]
|
|
149
157
|
### [5.0.2](https://github.com/eea/volto-embed/compare/5.0.1...5.0.2) - 20 March 2023
|
|
150
158
|
|
|
151
159
|
#### :hammer_and_wrench: Others
|
|
@@ -160,7 +168,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
160
168
|
- update .project.eslintrc.js [Miu Razvan - [`628fd40`](https://github.com/eea/volto-embed/commit/628fd402b00d075ce319b9be92ff5f0e4d0ca2c4)]
|
|
161
169
|
- rename schema.jsx [Miu Razvan - [`62794e3`](https://github.com/eea/volto-embed/commit/62794e398eab5117132e5622cab735f6cf4f79fd)]
|
|
162
170
|
- improving code quality as per sonarqube reported issues [tedw87 - [`c7842f7`](https://github.com/eea/volto-embed/commit/c7842f7795f344e9d30538ddf2da04e97e319ebe)]
|
|
163
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`fe3a2de`](https://github.com/eea/volto-embed/commit/fe3a2de6180796c3d6b569733d2b9365a669c23e)]
|
|
164
171
|
## [5.0.0](https://github.com/eea/volto-embed/compare/4.0.4...5.0.0) - 31 October 2022
|
|
165
172
|
|
|
166
173
|
#### :hammer_and_wrench: Others
|
|
@@ -180,8 +187,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
180
187
|
|
|
181
188
|
- use specific alpha for addon test [andreiggr - [`e6df633`](https://github.com/eea/volto-embed/commit/e6df633aa4d2b0ee7eeb6b5aafa21528f14cd1df)]
|
|
182
189
|
- add optional height to privacy container [andreiggr - [`e2ac711`](https://github.com/eea/volto-embed/commit/e2ac711db4e461b474cade42109346a73bb8ecbd)]
|
|
183
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`9f3f358`](https://github.com/eea/volto-embed/commit/9f3f35882fb367d72c7916abe7cbf366dbd8d5b6)]
|
|
184
|
-
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`7677140`](https://github.com/eea/volto-embed/commit/767714006abf7cbe336c5ab00d76c7232d5bc798)]
|
|
185
190
|
### [4.0.2](https://github.com/eea/volto-embed/compare/4.0.1...4.0.2) - 15 July 2022
|
|
186
191
|
|
|
187
192
|
#### :hammer_and_wrench: Others
|
|
@@ -221,7 +226,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
221
226
|
|
|
222
227
|
- Update package.json [Nilesh - [`0ec673a`](https://github.com/eea/volto-embed/commit/0ec673a8178731b8c1e010101caee2a3c9fafaca)]
|
|
223
228
|
- Update package.json [Nilesh - [`b8b94ec`](https://github.com/eea/volto-embed/commit/b8b94ec64672229f464b9108b4ac01a848827c00)]
|
|
224
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`cfe04d8`](https://github.com/eea/volto-embed/commit/cfe04d885255bb8e472a3b268b98e3d7b9022437)]
|
|
225
229
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`bf197dd`](https://github.com/eea/volto-embed/commit/bf197dd6516f9c18994add19b1141e061a96e2b6)]
|
|
226
230
|
- no hardcoded text [Daniela Mormocea - [`4001bb4`](https://github.com/eea/volto-embed/commit/4001bb414df05c1516f95e4dcec4a328406dc63f)]
|
|
227
231
|
- fix [Daniela Mormocea - [`a41ca9a`](https://github.com/eea/volto-embed/commit/a41ca9a2795a59f2633fb97938244e335dca8c43)]
|
|
@@ -295,8 +299,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
295
299
|
- revert use of custom bg image [nileshgulia1 - [`63a74b7`](https://github.com/eea/volto-embed/commit/63a74b7e671d85b602b0190c7a18e6d6ad71341b)]
|
|
296
300
|
- PrivacyProtection update & accept bg image [Andrei Grigore - [`f3f05d1`](https://github.com/eea/volto-embed/commit/f3f05d1d21fc88b90de3f68a995242b6c359e03a)]
|
|
297
301
|
- fix loading of cookies [nileshgulia1 - [`46348d8`](https://github.com/eea/volto-embed/commit/46348d8321b4633a3d5fdcbfb2c4f01912d7ed2a)]
|
|
298
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`a1e1f50`](https://github.com/eea/volto-embed/commit/a1e1f50db8a1ebc11261c3a24c39687c00ca7eea)]
|
|
299
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`1e1471e`](https://github.com/eea/volto-embed/commit/1e1471ebab5ba6e5bf0c231ddd0de94d8fe6c846)]
|
|
300
302
|
### [2.0.1](https://github.com/eea/volto-embed/compare/2.0.0...2.0.1) - 28 May 2021
|
|
301
303
|
|
|
302
304
|
#### :hammer_and_wrench: Others
|
package/cypress.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useEffect, useMemo } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { reduce, isArray, isString } from 'lodash';
|
|
2
3
|
import { connect } from 'react-redux';
|
|
3
4
|
import { Message } from 'semantic-ui-react';
|
|
4
5
|
import { getContent } from '@plone/volto/actions';
|
|
@@ -6,6 +7,13 @@ import { flattenToAppURL } from '@plone/volto/helpers';
|
|
|
6
7
|
import EmbedMap from '@eeacms/volto-embed/EmbedMap/EmbedMap';
|
|
7
8
|
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
8
9
|
|
|
10
|
+
let timer;
|
|
11
|
+
|
|
12
|
+
const debounce = (func, ...args) => {
|
|
13
|
+
if (timer) clearTimeout(timer);
|
|
14
|
+
timer = setTimeout(func, 800, ...args);
|
|
15
|
+
};
|
|
16
|
+
|
|
9
17
|
function getMaps(props) {
|
|
10
18
|
const content = props.mapsContent || {};
|
|
11
19
|
const maps = content.maps || props.data?.maps || {};
|
|
@@ -15,9 +23,46 @@ function getMaps(props) {
|
|
|
15
23
|
};
|
|
16
24
|
}
|
|
17
25
|
|
|
26
|
+
function getParameters({ parameters, data_query }) {
|
|
27
|
+
return {
|
|
28
|
+
...reduce(
|
|
29
|
+
data_query,
|
|
30
|
+
(acc, { i, v }) => {
|
|
31
|
+
if (i && v) {
|
|
32
|
+
let value = isString(v) ? v : '';
|
|
33
|
+
if (isArray(v)) {
|
|
34
|
+
value = v.join(',');
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
...acc,
|
|
38
|
+
[i]: value,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
},
|
|
43
|
+
{},
|
|
44
|
+
),
|
|
45
|
+
...reduce(
|
|
46
|
+
parameters,
|
|
47
|
+
(acc, { field, value }) => {
|
|
48
|
+
if (field && value) {
|
|
49
|
+
return {
|
|
50
|
+
...acc,
|
|
51
|
+
[field]: value,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return acc;
|
|
55
|
+
},
|
|
56
|
+
{},
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
18
61
|
function View(props) {
|
|
19
|
-
const { id, getContent, mode } = props;
|
|
62
|
+
const { id, getContent, mode, data_query } = props;
|
|
20
63
|
const {
|
|
64
|
+
height,
|
|
65
|
+
parameters,
|
|
21
66
|
useVisibilitySensor = true,
|
|
22
67
|
with_notes = true,
|
|
23
68
|
with_sources = true,
|
|
@@ -30,14 +75,29 @@ function View(props) {
|
|
|
30
75
|
|
|
31
76
|
const maps = useMemo(() => getMaps(props), [props]);
|
|
32
77
|
|
|
78
|
+
const [queryParams, setQueryParams] = useState(() =>
|
|
79
|
+
getParameters({ parameters, data_query }),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
debounce(() => {
|
|
84
|
+
setQueryParams(
|
|
85
|
+
getParameters({
|
|
86
|
+
parameters,
|
|
87
|
+
data_query,
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
}, [data_query, parameters]);
|
|
92
|
+
|
|
33
93
|
useEffect(() => {
|
|
34
94
|
const mapsId = maps['@id'] ? flattenToAppURL(maps['@id']) : undefined;
|
|
35
|
-
if (
|
|
95
|
+
if (url && url !== mapsId) {
|
|
36
96
|
getContent(url, null, id);
|
|
37
97
|
}
|
|
38
98
|
}, [id, getContent, mode, url, maps]);
|
|
39
99
|
|
|
40
|
-
if (
|
|
100
|
+
if (mode === 'edit' && !url) {
|
|
41
101
|
return <Message>Please select a map from block editor.</Message>;
|
|
42
102
|
}
|
|
43
103
|
|
|
@@ -51,7 +111,8 @@ function View(props) {
|
|
|
51
111
|
data={{
|
|
52
112
|
...maps,
|
|
53
113
|
useVisibilitySensor,
|
|
54
|
-
|
|
114
|
+
parameters: queryParams,
|
|
115
|
+
height: height || maps.height,
|
|
55
116
|
with_notes,
|
|
56
117
|
with_sources,
|
|
57
118
|
with_more_info,
|
|
@@ -67,6 +128,7 @@ function View(props) {
|
|
|
67
128
|
export default connect(
|
|
68
129
|
(state, props) => ({
|
|
69
130
|
mapsContent: state.content.subrequests?.[props.id]?.data,
|
|
131
|
+
data_query: state.content?.data?.data_query,
|
|
70
132
|
}),
|
|
71
133
|
{ getContent },
|
|
72
134
|
)(View);
|
|
@@ -31,6 +31,37 @@ test('renders a view embed map block component', () => {
|
|
|
31
31
|
enabled: false,
|
|
32
32
|
},
|
|
33
33
|
useVisibilitySensor: false,
|
|
34
|
+
parameters: {
|
|
35
|
+
'@id': '647e4a0f-d4a0-4b8a-9965-0a016f017ebd',
|
|
36
|
+
field: 'zoomtocountry',
|
|
37
|
+
value: 'RO',
|
|
38
|
+
},
|
|
39
|
+
height: '800',
|
|
40
|
+
}}
|
|
41
|
+
data_query={[
|
|
42
|
+
{
|
|
43
|
+
i: 'Country',
|
|
44
|
+
o: 'plone.app.querystring.operation.selection.is',
|
|
45
|
+
v: ['RO'],
|
|
46
|
+
},
|
|
47
|
+
]}
|
|
48
|
+
/>
|
|
49
|
+
</Provider>,
|
|
50
|
+
);
|
|
51
|
+
const json = component.toJSON();
|
|
52
|
+
expect(json).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('renders an edit view embed map block component', () => {
|
|
56
|
+
const component = renderer.create(
|
|
57
|
+
<Provider store={global.store}>
|
|
58
|
+
<View
|
|
59
|
+
id="my-map"
|
|
60
|
+
mode="edit"
|
|
61
|
+
data={{
|
|
62
|
+
'@type': 'embed_maps',
|
|
63
|
+
url: '',
|
|
64
|
+
maps: {},
|
|
34
65
|
}}
|
|
35
66
|
/>
|
|
36
67
|
</Provider>,
|
|
@@ -11,6 +11,22 @@ const messages = defineMessages({
|
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
+
const parameters = {
|
|
15
|
+
title: 'Parameter',
|
|
16
|
+
fieldsets: [{ id: 'default', title: 'Default', fields: ['field', 'value'] }],
|
|
17
|
+
properties: {
|
|
18
|
+
field: {
|
|
19
|
+
title: 'Name',
|
|
20
|
+
type: 'text',
|
|
21
|
+
},
|
|
22
|
+
value: {
|
|
23
|
+
title: 'Value',
|
|
24
|
+
type: 'text',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: [],
|
|
28
|
+
};
|
|
29
|
+
|
|
14
30
|
export default (props) => {
|
|
15
31
|
return {
|
|
16
32
|
title: 'Embed interactive Map',
|
|
@@ -31,6 +47,11 @@ export default (props) => {
|
|
|
31
47
|
'with_enlarge',
|
|
32
48
|
],
|
|
33
49
|
},
|
|
50
|
+
{
|
|
51
|
+
id: 'parameters',
|
|
52
|
+
title: 'Parameters',
|
|
53
|
+
fields: ['parameters'],
|
|
54
|
+
},
|
|
34
55
|
],
|
|
35
56
|
properties: {
|
|
36
57
|
url: {
|
|
@@ -75,6 +96,12 @@ export default (props) => {
|
|
|
75
96
|
type: 'boolean',
|
|
76
97
|
defaultValue: true,
|
|
77
98
|
},
|
|
99
|
+
parameters: {
|
|
100
|
+
title: 'Parameters',
|
|
101
|
+
widget: 'object_list',
|
|
102
|
+
schema: parameters,
|
|
103
|
+
description: 'Set a list of parameters.',
|
|
104
|
+
},
|
|
78
105
|
},
|
|
79
106
|
|
|
80
107
|
required: [],
|
|
@@ -80,4 +80,30 @@ describe('Test Maps Block editing', () => {
|
|
|
80
80
|
const json = component.toJSON();
|
|
81
81
|
expect(json).toMatchSnapshot();
|
|
82
82
|
});
|
|
83
|
+
|
|
84
|
+
test('test-3', () => {
|
|
85
|
+
const component = renderer.create(
|
|
86
|
+
<Provider store={global.store}>
|
|
87
|
+
<Edit
|
|
88
|
+
data={{
|
|
89
|
+
'@type': 'maps',
|
|
90
|
+
url: '',
|
|
91
|
+
}}
|
|
92
|
+
pathname="/news"
|
|
93
|
+
selected={true}
|
|
94
|
+
block="1234"
|
|
95
|
+
index={1}
|
|
96
|
+
onChangeBlock={() => {}}
|
|
97
|
+
onSelectBlock={() => {}}
|
|
98
|
+
onDeleteBlock={() => {}}
|
|
99
|
+
onFocusPreviousBlock={() => {}}
|
|
100
|
+
onFocusNextBlock={() => {}}
|
|
101
|
+
handleKeyDown={() => {}}
|
|
102
|
+
content={{}}
|
|
103
|
+
/>
|
|
104
|
+
</Provider>,
|
|
105
|
+
);
|
|
106
|
+
const json = component.toJSON();
|
|
107
|
+
expect(json).toMatchSnapshot();
|
|
108
|
+
});
|
|
83
109
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { isNaN, isNumber } from 'lodash';
|
|
2
|
+
import { isNaN, isNumber, isEmpty } from 'lodash';
|
|
3
3
|
import { compose } from 'redux';
|
|
4
4
|
import { connect } from 'react-redux';
|
|
5
5
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
@@ -31,8 +31,19 @@ function getHeight(height) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function EmbedMap({ data, intl, id, screen }) {
|
|
34
|
+
const { parameters, url } = data;
|
|
34
35
|
const el = useRef();
|
|
35
36
|
const [mobile, setMobile] = useState(false);
|
|
37
|
+
const [iframeSrc, setIframeSrc] = useState(url);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const query_params = new URLSearchParams(parameters).toString();
|
|
41
|
+
if (isEmpty(parameters)) {
|
|
42
|
+
setIframeSrc(url);
|
|
43
|
+
} else {
|
|
44
|
+
setIframeSrc(url + '&' + query_params);
|
|
45
|
+
}
|
|
46
|
+
}, [url, parameters]);
|
|
36
47
|
|
|
37
48
|
useEffect(() => {
|
|
38
49
|
if (el.current) {
|
|
@@ -46,7 +57,7 @@ function EmbedMap({ data, intl, id, screen }) {
|
|
|
46
57
|
}
|
|
47
58
|
}, [screen, mobile]);
|
|
48
59
|
|
|
49
|
-
if (!
|
|
60
|
+
if (!url) return null;
|
|
50
61
|
|
|
51
62
|
return (
|
|
52
63
|
<div
|
|
@@ -72,7 +83,7 @@ function EmbedMap({ data, intl, id, screen }) {
|
|
|
72
83
|
>
|
|
73
84
|
<iframe
|
|
74
85
|
title={intl.formatMessage(messages.EmbededESRIMaps)}
|
|
75
|
-
src={
|
|
86
|
+
src={iframeSrc}
|
|
76
87
|
className="google-map"
|
|
77
88
|
frameBorder="0"
|
|
78
89
|
allowFullScreen
|
|
@@ -115,5 +126,7 @@ function EmbedMap({ data, intl, id, screen }) {
|
|
|
115
126
|
|
|
116
127
|
export default compose(
|
|
117
128
|
injectIntl,
|
|
118
|
-
connect((state) => ({
|
|
129
|
+
connect((state) => ({
|
|
130
|
+
screen: state.screen,
|
|
131
|
+
})),
|
|
119
132
|
)(EmbedMap);
|
|
@@ -37,6 +37,10 @@ test('renders map component', () => {
|
|
|
37
37
|
url:
|
|
38
38
|
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3027.7835278268726!2d14.38842915203974!3d40.634655679238854!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x133b994881d943cb%3A0x6ab93db57d3272f0!2sHotel+Mediterraneo+Sorrento!5e0!3m2!1sen!2ses!4v1550168740166',
|
|
39
39
|
useVisibilitySensor: false,
|
|
40
|
+
parameters: {
|
|
41
|
+
Country: 'RO',
|
|
42
|
+
zoomtocountry: 'RO',
|
|
43
|
+
},
|
|
40
44
|
}}
|
|
41
45
|
/>
|
|
42
46
|
</Provider>,
|