@eeacms/volto-cca-policy 1.0.37 → 1.0.39
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 +27 -1
- package/locales/bg/LC_MESSAGES/volto.po +35 -0
- package/locales/cs/LC_MESSAGES/volto.po +35 -0
- package/locales/da/LC_MESSAGES/volto.po +35 -0
- package/locales/de/LC_MESSAGES/volto.po +35 -0
- package/locales/el/LC_MESSAGES/volto.po +35 -0
- package/locales/en/LC_MESSAGES/volto.po +35 -0
- package/locales/es/LC_MESSAGES/volto.po +35 -0
- package/locales/et/LC_MESSAGES/volto.po +35 -0
- package/locales/fi/LC_MESSAGES/volto.po +35 -0
- package/locales/fr/LC_MESSAGES/volto.po +35 -0
- package/locales/ga/LC_MESSAGES/volto.po +35 -0
- package/locales/hr/LC_MESSAGES/volto.po +35 -0
- package/locales/hu/LC_MESSAGES/volto.po +35 -0
- package/locales/is/LC_MESSAGES/volto.po +35 -0
- package/locales/it/LC_MESSAGES/volto.po +35 -0
- package/locales/lt/LC_MESSAGES/volto.po +35 -0
- package/locales/lv/LC_MESSAGES/volto.po +35 -0
- package/locales/mt/LC_MESSAGES/volto.po +35 -0
- package/locales/nl/LC_MESSAGES/volto.po +35 -0
- package/locales/nn/LC_MESSAGES/volto.po +35 -0
- package/locales/pl/LC_MESSAGES/volto.po +35 -0
- package/locales/pt/LC_MESSAGES/volto.po +35 -0
- package/locales/ro/LC_MESSAGES/volto.po +35 -0
- package/locales/sk/LC_MESSAGES/volto.po +35 -0
- package/locales/sl/LC_MESSAGES/volto.po +35 -0
- package/locales/sv/LC_MESSAGES/volto.po +35 -0
- package/locales/tr/LC_MESSAGES/volto.po +35 -0
- package/locales/volto.pot +36 -1
- package/package.json +1 -1
- package/src/components/Search/NavigatorCatalogue/NavigatorCatalogueMapState.jsx +72 -0
- package/src/components/Search/NavigatorCatalogue/NavigatorCatalogueMapState.test.jsx +46 -0
- package/src/components/Search/NavigatorCatalogue/NavigatorCatalogueMapView.jsx +30 -3
- package/src/components/Search/NavigatorCatalogue/NavigatorCatalogueMapView.test.jsx +99 -16
- package/src/components/Search/NavigatorCatalogue/NavigatorGeographicCoverageFacet.jsx +47 -39
- package/src/components/Search/NavigatorCatalogue/NavigatorGeographicCoverageFacet.test.jsx +65 -1
- package/src/components/Search/NavigatorCatalogue/utils.js +40 -8
- package/src/components/Search/NavigatorGuide/NavigatorGuideContentView.test.jsx +67 -0
- package/src/components/theme/CompareTools/CompareToolsView.test.jsx +59 -0
- package/theme/globals/navigator.less +83 -1
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Button, Card, Icon } from 'semantic-ui-react';
|
|
3
3
|
import { defineMessages, useIntl } from 'react-intl';
|
|
4
4
|
import { Term } from '@eeacms/search/components';
|
|
5
|
-
import { useSearchContext } from '@eeacms/search/lib/hocs';
|
|
5
|
+
import { useSearchContext, useViews } from '@eeacms/search/lib/hocs';
|
|
6
6
|
import { markSelectedFacetValuesFromFilters } from '@eeacms/search/lib/search/helpers';
|
|
7
7
|
import {
|
|
8
8
|
CHARACTERISATION_FIELD,
|
|
@@ -70,6 +70,7 @@ const FacetOption = ({ field, option, onChange }) => {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
const ExpandableFacetGroup = ({
|
|
73
|
+
defaultOpen = false,
|
|
73
74
|
field,
|
|
74
75
|
id,
|
|
75
76
|
label,
|
|
@@ -78,11 +79,11 @@ const ExpandableFacetGroup = ({
|
|
|
78
79
|
onChange,
|
|
79
80
|
}) => {
|
|
80
81
|
const hasSelection = options.some(({ selected }) => selected);
|
|
81
|
-
const [isOpen, setIsOpen] = React.useState(hasSelection);
|
|
82
|
+
const [isOpen, setIsOpen] = React.useState(hasSelection || defaultOpen);
|
|
82
83
|
|
|
83
84
|
React.useEffect(() => {
|
|
84
|
-
if (hasSelection) setIsOpen(true);
|
|
85
|
-
}, [hasSelection]);
|
|
85
|
+
if (hasSelection || defaultOpen) setIsOpen(true);
|
|
86
|
+
}, [defaultOpen, hasSelection]);
|
|
86
87
|
|
|
87
88
|
return (
|
|
88
89
|
<div className="navigator-geographic-facet-group">
|
|
@@ -119,16 +120,10 @@ const ExpandableFacetGroup = ({
|
|
|
119
120
|
);
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
const NavigatorActiveFilters = ({ filters, onRemove }) => {
|
|
123
|
+
const NavigatorActiveFilters = ({ fields, filters, onRemove }) => {
|
|
123
124
|
const intl = useIntl();
|
|
124
|
-
const geographicFields = [
|
|
125
|
-
CHARACTERISATION_FIELD,
|
|
126
|
-
TRANSNATIONAL_REGION_FIELD,
|
|
127
|
-
COUNTRIES_FIELD,
|
|
128
|
-
];
|
|
129
125
|
const activeFilters = filters.filter(
|
|
130
|
-
({ field, values }) =>
|
|
131
|
-
geographicFields.includes(field) && values?.length > 0,
|
|
126
|
+
({ field, values }) => fields.includes(field) && values?.length > 0,
|
|
132
127
|
);
|
|
133
128
|
|
|
134
129
|
if (!activeFilters.length) return null;
|
|
@@ -190,6 +185,8 @@ const NavigatorGeographicCoverageFacet = ({
|
|
|
190
185
|
}) => {
|
|
191
186
|
const intl = useIntl();
|
|
192
187
|
const { addFilter, facets, filters = [], removeFilter } = useSearchContext();
|
|
188
|
+
const { activeViewId } = useViews();
|
|
189
|
+
const isMapView = activeViewId === 'map';
|
|
193
190
|
const transnationalOptions = getFacetOptions(
|
|
194
191
|
facets,
|
|
195
192
|
filters,
|
|
@@ -219,6 +216,7 @@ const NavigatorGeographicCoverageFacet = ({
|
|
|
219
216
|
}
|
|
220
217
|
|
|
221
218
|
clearFilter(CHARACTERISATION_FIELD);
|
|
219
|
+
if (isMapView) clearFilter(TRANSNATIONAL_REGION_FIELD);
|
|
222
220
|
addFilter(field, option.value, 'any');
|
|
223
221
|
};
|
|
224
222
|
|
|
@@ -226,25 +224,28 @@ const NavigatorGeographicCoverageFacet = ({
|
|
|
226
224
|
<fieldset
|
|
227
225
|
className={`sui-facet searchlib-multiterm-facet navigator-geographic-facet ${className}`}
|
|
228
226
|
>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
227
|
+
{!isMapView && (
|
|
228
|
+
<div className="sui-multi-checkbox-facet navigator-geographic-facet-direct-options">
|
|
229
|
+
{options.map((option) => {
|
|
230
|
+
const directOption = {
|
|
231
|
+
...option,
|
|
232
|
+
selected:
|
|
233
|
+
option.selected || selectedDirectValues.includes(option.value),
|
|
234
|
+
};
|
|
236
235
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
236
|
+
return (
|
|
237
|
+
<FacetOption
|
|
238
|
+
key={valueAsText(option.value)}
|
|
239
|
+
field={CHARACTERISATION_FIELD}
|
|
240
|
+
option={directOption}
|
|
241
|
+
onChange={updateDirectFilter}
|
|
242
|
+
/>
|
|
243
|
+
);
|
|
244
|
+
})}
|
|
245
|
+
</div>
|
|
246
|
+
)}
|
|
247
247
|
<ExpandableFacetGroup
|
|
248
|
+
defaultOpen={isMapView}
|
|
248
249
|
field={COUNTRIES_FIELD}
|
|
249
250
|
id="navigator-geographic-countries"
|
|
250
251
|
label={intl.formatMessage(countriesLabel)}
|
|
@@ -252,17 +253,24 @@ const NavigatorGeographicCoverageFacet = ({
|
|
|
252
253
|
options={countryOptions}
|
|
253
254
|
onChange={(option) => updateChildFilter(COUNTRIES_FIELD, option)}
|
|
254
255
|
/>
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
256
|
+
{!isMapView && (
|
|
257
|
+
<ExpandableFacetGroup
|
|
258
|
+
field={TRANSNATIONAL_REGION_FIELD}
|
|
259
|
+
id="navigator-geographic-transnational-regions"
|
|
260
|
+
label={intl.formatMessage(transnationalRegionsLabel)}
|
|
261
|
+
emptyMessage={intl.formatMessage(messages.noOptionsAvailable)}
|
|
262
|
+
options={transnationalOptions}
|
|
263
|
+
onChange={(option) =>
|
|
264
|
+
updateChildFilter(TRANSNATIONAL_REGION_FIELD, option)
|
|
265
|
+
}
|
|
266
|
+
/>
|
|
267
|
+
)}
|
|
265
268
|
<NavigatorActiveFilters
|
|
269
|
+
fields={[
|
|
270
|
+
CHARACTERISATION_FIELD,
|
|
271
|
+
TRANSNATIONAL_REGION_FIELD,
|
|
272
|
+
COUNTRIES_FIELD,
|
|
273
|
+
]}
|
|
266
274
|
filters={filters}
|
|
267
275
|
onRemove={(field, value, type) => removeFilter(field, value, type)}
|
|
268
276
|
/>
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import '@testing-library/jest-dom';
|
|
3
3
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
4
|
import { IntlProvider } from 'react-intl';
|
|
5
|
-
import { useSearchContext } from '@eeacms/search/lib/hocs';
|
|
5
|
+
import { useSearchContext, useViews } from '@eeacms/search/lib/hocs';
|
|
6
6
|
import NavigatorGeographicCoverageFacet from './NavigatorGeographicCoverageFacet';
|
|
7
7
|
import {
|
|
8
8
|
CHARACTERISATION_FIELD,
|
|
@@ -15,9 +15,11 @@ jest.mock('@eeacms/search/components', () => ({
|
|
|
15
15
|
}));
|
|
16
16
|
jest.mock('@eeacms/search/lib/hocs', () => ({
|
|
17
17
|
useSearchContext: jest.fn(),
|
|
18
|
+
useViews: jest.fn(),
|
|
18
19
|
}));
|
|
19
20
|
|
|
20
21
|
const renderFacet = ({
|
|
22
|
+
activeViewId = 'listing',
|
|
21
23
|
detailedOptions = true,
|
|
22
24
|
filters = [],
|
|
23
25
|
onRemove = jest.fn(),
|
|
@@ -26,6 +28,8 @@ const renderFacet = ({
|
|
|
26
28
|
const addFilter = jest.fn();
|
|
27
29
|
const removeFilter = jest.fn();
|
|
28
30
|
|
|
31
|
+
useViews.mockReturnValue({ activeViewId });
|
|
32
|
+
|
|
29
33
|
useSearchContext.mockReturnValue({
|
|
30
34
|
addFilter,
|
|
31
35
|
removeFilter,
|
|
@@ -190,4 +194,64 @@ describe('NavigatorGeographicCoverageFacet', () => {
|
|
|
190
194
|
screen.getByRole('button', { name: 'Transnational regions' }),
|
|
191
195
|
).toBeEnabled();
|
|
192
196
|
});
|
|
197
|
+
|
|
198
|
+
it('shows only countries in the map view', () => {
|
|
199
|
+
renderFacet({ activeViewId: 'map' });
|
|
200
|
+
|
|
201
|
+
expect(screen.queryByLabelText('Europe')).not.toBeInTheDocument();
|
|
202
|
+
expect(screen.queryByLabelText('Global')).not.toBeInTheDocument();
|
|
203
|
+
expect(screen.getByRole('button', { name: 'Countries' })).toHaveAttribute(
|
|
204
|
+
'aria-expanded',
|
|
205
|
+
'true',
|
|
206
|
+
);
|
|
207
|
+
expect(screen.getByLabelText('Germany')).toBeVisible();
|
|
208
|
+
expect(
|
|
209
|
+
screen.queryByRole('button', { name: 'Transnational regions' }),
|
|
210
|
+
).not.toBeInTheDocument();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('clears hidden geographic filters when selecting a country on the map', () => {
|
|
214
|
+
const { addFilter, removeFilter } = renderFacet({
|
|
215
|
+
activeViewId: 'map',
|
|
216
|
+
filters: [
|
|
217
|
+
{
|
|
218
|
+
field: TRANSNATIONAL_REGION_FIELD,
|
|
219
|
+
values: ['Alpine Space'],
|
|
220
|
+
type: 'any',
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
fireEvent.click(screen.getByLabelText('Germany'));
|
|
226
|
+
|
|
227
|
+
expect(removeFilter).toHaveBeenCalledWith(
|
|
228
|
+
CHARACTERISATION_FIELD,
|
|
229
|
+
null,
|
|
230
|
+
'any',
|
|
231
|
+
);
|
|
232
|
+
expect(removeFilter).toHaveBeenCalledWith(
|
|
233
|
+
TRANSNATIONAL_REGION_FIELD,
|
|
234
|
+
null,
|
|
235
|
+
'any',
|
|
236
|
+
);
|
|
237
|
+
expect(addFilter).toHaveBeenCalledWith(COUNTRIES_FIELD, 'Germany', 'any');
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('shows hidden active geographic filters in the map view', () => {
|
|
241
|
+
renderFacet({
|
|
242
|
+
activeViewId: 'map',
|
|
243
|
+
detailedOptions: false,
|
|
244
|
+
filters: [
|
|
245
|
+
{
|
|
246
|
+
field: CHARACTERISATION_FIELD,
|
|
247
|
+
values: ['Europe'],
|
|
248
|
+
type: 'any',
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
expect(screen.queryByLabelText('Europe')).not.toBeInTheDocument();
|
|
254
|
+
expect(screen.getByText('Active filters:')).toBeInTheDocument();
|
|
255
|
+
expect(screen.getByText('Europe')).toBeInTheDocument();
|
|
256
|
+
});
|
|
193
257
|
});
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
* Used by the map view to color-code countries
|
|
4
4
|
*/
|
|
5
5
|
export const mapColorScale = [
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
{
|
|
7
|
+
minimum: 4,
|
|
8
|
+
label: '4 or more',
|
|
9
|
+
messageKey: 'fourOrMore',
|
|
10
|
+
color: '#0F6B3F',
|
|
11
|
+
},
|
|
12
|
+
{ minimum: 3, label: '3', color: '#007B6C' },
|
|
13
|
+
{ minimum: 2, label: '2', color: '#84C79A' },
|
|
14
|
+
{ minimum: 1, label: '1', color: '#C2E3CD' },
|
|
10
15
|
{ minimum: 0, label: 'None', color: '#E1E7DF' },
|
|
11
16
|
];
|
|
12
17
|
|
|
@@ -61,6 +66,30 @@ export const filterCountryCounts = (countryCounts, filters) => {
|
|
|
61
66
|
);
|
|
62
67
|
};
|
|
63
68
|
|
|
69
|
+
const mapIncompatibleGeographicFields = new Set([
|
|
70
|
+
'cca_navigator_geographic_scope',
|
|
71
|
+
'cca_geographic_transnational_region.keyword',
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
export const hasMapIncompatibleGeographicSelection = (filters) =>
|
|
75
|
+
Boolean(
|
|
76
|
+
filters?.find(
|
|
77
|
+
({ field, values }) =>
|
|
78
|
+
mapIncompatibleGeographicFields.has(field) && values?.length > 0,
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
export const clearMapIncompatibleGeographicFilters = (searchContext) => {
|
|
83
|
+
searchContext?.filters
|
|
84
|
+
?.filter(
|
|
85
|
+
({ field, values }) =>
|
|
86
|
+
mapIncompatibleGeographicFields.has(field) && values?.length > 0,
|
|
87
|
+
)
|
|
88
|
+
.forEach(({ field, type = 'any' }) =>
|
|
89
|
+
searchContext.removeFilter(field, null, type),
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
64
93
|
export const setCountryFilter = (searchContext, countryName) => {
|
|
65
94
|
searchContext?.setFilter(
|
|
66
95
|
'cca_geographic_countries.keyword',
|
|
@@ -72,10 +101,13 @@ export const setCountryFilter = (searchContext, countryName) => {
|
|
|
72
101
|
/**
|
|
73
102
|
* Legend items for the map view
|
|
74
103
|
*/
|
|
75
|
-
export const mapLegendItems = mapColorScale.map(
|
|
76
|
-
label,
|
|
77
|
-
|
|
78
|
-
|
|
104
|
+
export const mapLegendItems = mapColorScale.map(
|
|
105
|
+
({ label, messageKey, color }) => ({
|
|
106
|
+
label,
|
|
107
|
+
messageKey,
|
|
108
|
+
color,
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
79
111
|
|
|
80
112
|
const unwrapRawValue = (value) =>
|
|
81
113
|
value?.raw === undefined ? value : value.raw;
|
|
@@ -268,3 +268,70 @@ describe('NavigatorGuideContentView climate hazards', () => {
|
|
|
268
268
|
).toHaveTextContent('Flooding');
|
|
269
269
|
});
|
|
270
270
|
});
|
|
271
|
+
|
|
272
|
+
describe('NavigatorGuideContentView actions', () => {
|
|
273
|
+
beforeEach(() => {
|
|
274
|
+
jest.clearAllMocks();
|
|
275
|
+
useSelector.mockReturnValue('en');
|
|
276
|
+
useSearchDriver.mockReturnValue(undefined);
|
|
277
|
+
useGuideFacetOptions.mockReturnValue({
|
|
278
|
+
'cca_adaptation_sectors.keyword': ['Water'],
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('removes a selected option from the current step', () => {
|
|
283
|
+
const removeFilter = jest.fn();
|
|
284
|
+
useAtom.mockReturnValue([0, jest.fn()]);
|
|
285
|
+
useHistory.mockReturnValue({ push: jest.fn() });
|
|
286
|
+
|
|
287
|
+
renderGuide(
|
|
288
|
+
{ title: 'Guide tool', href: '/tools/guide-tool' },
|
|
289
|
+
{
|
|
290
|
+
removeFilter,
|
|
291
|
+
facets: {
|
|
292
|
+
'cca_adaptation_sectors.keyword': [
|
|
293
|
+
{ data: [{ value: 'Water', count: 4 }] },
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
fireEvent.click(screen.getByText('Water'));
|
|
300
|
+
|
|
301
|
+
expect(removeFilter).toHaveBeenCalledWith(
|
|
302
|
+
'cca_adaptation_sectors.keyword',
|
|
303
|
+
'Water',
|
|
304
|
+
'all',
|
|
305
|
+
);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('opens catalogue results with only supported Guide filters', () => {
|
|
309
|
+
const history = { push: jest.fn() };
|
|
310
|
+
useAtom.mockReturnValue([0, jest.fn()]);
|
|
311
|
+
useHistory.mockReturnValue(history);
|
|
312
|
+
|
|
313
|
+
renderGuide(
|
|
314
|
+
{ title: 'Guide tool', href: '/tools/guide-tool' },
|
|
315
|
+
{
|
|
316
|
+
filters: [
|
|
317
|
+
{
|
|
318
|
+
field: 'cca_adaptation_sectors.keyword',
|
|
319
|
+
values: ['Water'],
|
|
320
|
+
type: 'all',
|
|
321
|
+
},
|
|
322
|
+
{ field: 'unrelated.keyword', values: ['Ignored'], type: 'any' },
|
|
323
|
+
],
|
|
324
|
+
},
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
fireEvent.click(screen.getByRole('button', { name: 'Skip to results' }));
|
|
328
|
+
|
|
329
|
+
expect(history.push).toHaveBeenCalledWith(
|
|
330
|
+
expect.objectContaining({
|
|
331
|
+
pathname: '/en/navigator/tool-catalogue',
|
|
332
|
+
search: expect.any(String),
|
|
333
|
+
}),
|
|
334
|
+
);
|
|
335
|
+
expect(history.push.mock.calls[0][0].search).not.toContain('unrelated');
|
|
336
|
+
});
|
|
337
|
+
});
|
|
@@ -12,6 +12,7 @@ import { useAtom } from 'jotai';
|
|
|
12
12
|
import { useDispatch, useSelector } from 'react-redux';
|
|
13
13
|
import { useHistory, useLocation } from 'react-router-dom';
|
|
14
14
|
import CompareToolsView from './CompareToolsView';
|
|
15
|
+
import { exportComparisonTable } from '../../Search/NavigatorCatalogue/utils';
|
|
15
16
|
import { fetchResultsByUid } from './utils';
|
|
16
17
|
|
|
17
18
|
jest.mock('jotai', () => ({
|
|
@@ -62,6 +63,11 @@ jest.mock('./utils', () => ({
|
|
|
62
63
|
getPathname: (url) => url?.split('?')[0] || '',
|
|
63
64
|
}));
|
|
64
65
|
|
|
66
|
+
jest.mock('../../Search/NavigatorCatalogue/utils', () => ({
|
|
67
|
+
...jest.requireActual('../../Search/NavigatorCatalogue/utils'),
|
|
68
|
+
exportComparisonTable: jest.fn(),
|
|
69
|
+
}));
|
|
70
|
+
|
|
65
71
|
describe('CompareToolsView', () => {
|
|
66
72
|
beforeEach(() => {
|
|
67
73
|
jest.clearAllMocks();
|
|
@@ -246,4 +252,57 @@ describe('CompareToolsView', () => {
|
|
|
246
252
|
expect(thumbnail.querySelector('img')).not.toBeInTheDocument();
|
|
247
253
|
expect(thumbnail.querySelector('.ri-file-line')).toBeInTheDocument();
|
|
248
254
|
});
|
|
255
|
+
|
|
256
|
+
it('removes a tool from the selection and URL', async () => {
|
|
257
|
+
const setSelectedTools = jest.fn();
|
|
258
|
+
const history = { push: jest.fn() };
|
|
259
|
+
useAtom.mockReturnValue([[], setSelectedTools]);
|
|
260
|
+
useHistory.mockReturnValue(history);
|
|
261
|
+
|
|
262
|
+
render(
|
|
263
|
+
<IntlProvider locale="en">
|
|
264
|
+
<CompareToolsView />
|
|
265
|
+
</IntlProvider>,
|
|
266
|
+
);
|
|
267
|
+
await screen.findByRole('table', { name: 'Compare tools' });
|
|
268
|
+
|
|
269
|
+
fireEvent.click(
|
|
270
|
+
screen.getByRole('button', {
|
|
271
|
+
name: 'Remove Tool one from comparison',
|
|
272
|
+
}),
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
const updateSelection = setSelectedTools.mock.calls[0][0];
|
|
276
|
+
expect(updateSelection([{ uid: 'one' }, { uid: 'two' }])).toEqual([
|
|
277
|
+
{ uid: 'two' },
|
|
278
|
+
]);
|
|
279
|
+
expect(history.push).toHaveBeenCalledWith({
|
|
280
|
+
pathname: '/en/navigator/compare',
|
|
281
|
+
search: '?uid=two',
|
|
282
|
+
hash: '',
|
|
283
|
+
state: {},
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('exports comparison data with only applicable table options', async () => {
|
|
288
|
+
render(
|
|
289
|
+
<IntlProvider locale="en">
|
|
290
|
+
<CompareToolsView />
|
|
291
|
+
</IntlProvider>,
|
|
292
|
+
);
|
|
293
|
+
await screen.findByRole('table', { name: 'Compare tools' });
|
|
294
|
+
|
|
295
|
+
fireEvent.click(screen.getByRole('button', { name: 'Export table' }));
|
|
296
|
+
|
|
297
|
+
expect(exportComparisonTable).toHaveBeenCalledTimes(1);
|
|
298
|
+
const [exportedTools] = exportComparisonTable.mock.calls[0];
|
|
299
|
+
expect(exportedTools[0].comparisonOptions).toEqual(
|
|
300
|
+
expect.objectContaining({
|
|
301
|
+
cca_type_of_outputs: ['Maps and graphs'],
|
|
302
|
+
cca_adaptation_support_cycle_step: [
|
|
303
|
+
'Step 2: Assessing Climate Change Risks and Vulnerabilities',
|
|
304
|
+
],
|
|
305
|
+
}),
|
|
306
|
+
);
|
|
307
|
+
});
|
|
249
308
|
});
|
|
@@ -620,11 +620,89 @@
|
|
|
620
620
|
}
|
|
621
621
|
|
|
622
622
|
.navigator-catalogue-map-loading {
|
|
623
|
-
text-align: center;
|
|
624
623
|
display: flex;
|
|
625
624
|
flex-direction: column;
|
|
626
625
|
gap: 1em;
|
|
626
|
+
text-align: center;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.navigator-catalogue-map-state {
|
|
630
|
+
position: relative;
|
|
631
|
+
min-height: 600px;
|
|
632
|
+
|
|
633
|
+
.navigator-catalogue-map-content {
|
|
634
|
+
transition:
|
|
635
|
+
filter 0.2s ease,
|
|
636
|
+
opacity 0.2s ease;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
&.is-disabled .navigator-catalogue-map-content {
|
|
640
|
+
filter: grayscale(35%);
|
|
641
|
+
opacity: 0.4;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
.navigator-catalogue-map-overlay {
|
|
646
|
+
position: absolute;
|
|
647
|
+
z-index: 1001;
|
|
648
|
+
display: flex;
|
|
649
|
+
align-items: center;
|
|
650
|
+
justify-content: center;
|
|
651
|
+
padding: 2rem;
|
|
652
|
+
background: fade(#fff, 55%);
|
|
653
|
+
inset: 0;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.navigator-catalogue-map-notice {
|
|
657
|
+
display: flex;
|
|
658
|
+
width: 100%;
|
|
659
|
+
max-width: 700px;
|
|
660
|
+
box-sizing: border-box;
|
|
661
|
+
flex-direction: column;
|
|
662
|
+
align-items: center;
|
|
663
|
+
justify-content: center;
|
|
664
|
+
padding: 3rem 2rem;
|
|
665
|
+
border: 1px solid fade(#dce7ee, 80%);
|
|
666
|
+
background-color: #fff;
|
|
667
|
+
box-shadow: 0 10px 28px fade(#dce7ee, 18%);
|
|
668
|
+
cursor: default;
|
|
669
|
+
text-align: center;
|
|
670
|
+
|
|
671
|
+
// .map-notice-icon {
|
|
672
|
+
// display: inline-flex;
|
|
673
|
+
// width: 72px;
|
|
674
|
+
// height: 72px;
|
|
675
|
+
// align-items: center;
|
|
676
|
+
// justify-content: center;
|
|
677
|
+
// border-radius: 50%;
|
|
678
|
+
// background: @secondaryColor;
|
|
679
|
+
// color: #fff;
|
|
680
|
+
|
|
681
|
+
// i.icon {
|
|
682
|
+
// width: auto;
|
|
683
|
+
// height: auto;
|
|
684
|
+
// margin: 0 !important;
|
|
685
|
+
// font-size: 2rem;
|
|
686
|
+
// line-height: 1;
|
|
687
|
+
// }
|
|
688
|
+
// }
|
|
689
|
+
|
|
690
|
+
h4 {
|
|
691
|
+
margin: 0 0 0.75rem;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
p {
|
|
695
|
+
max-width: 620px;
|
|
696
|
+
margin: 0;
|
|
697
|
+
font-size: 1rem;
|
|
698
|
+
line-height: 1.6;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.ui.button.map-notice-clear-button {
|
|
702
|
+
margin: 1.5rem 0 0;
|
|
703
|
+
}
|
|
627
704
|
}
|
|
705
|
+
|
|
628
706
|
.navigator-catalogue-map-tooltip {
|
|
629
707
|
position: absolute;
|
|
630
708
|
z-index: 1000;
|
|
@@ -678,7 +756,11 @@
|
|
|
678
756
|
display: inline-block;
|
|
679
757
|
width: 16px;
|
|
680
758
|
height: 16px;
|
|
759
|
+
box-sizing: border-box;
|
|
681
760
|
flex-shrink: 0;
|
|
761
|
+
border: 1px solid color-mix(in srgb, var(--legend-color) 92%, black 8%);
|
|
762
|
+
border-radius: 2px;
|
|
763
|
+
background-color: var(--legend-color);
|
|
682
764
|
}
|
|
683
765
|
}
|
|
684
766
|
}
|