@eeacms/volto-cca-policy 0.1.102 → 0.2.0
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 +61 -8
- package/README.md +0 -1
- package/package.json +1 -1
- package/src/components/manage/Blocks/C3SIndicatorsGlossaryBlock/C3SIndicatorsGlossaryBlockView.jsx +13 -26
- package/src/components/manage/Blocks/C3SIndicatorsListingBlock/C3SIndicatorsListingBlockEdit.jsx +32 -0
- package/src/components/manage/Blocks/C3SIndicatorsListingBlock/C3SIndicatorsListingBlockView.jsx +36 -0
- package/src/components/manage/Blocks/C3SIndicatorsListingBlock/index.js +29 -0
- package/src/components/manage/Blocks/C3SIndicatorsListingBlock/schema.js +14 -0
- package/src/components/manage/Blocks/C3SIndicatorsOverviewBlock/C3SIndicatorsOverviewBlockView.jsx +11 -40
- package/src/components/manage/Blocks/C3SIndicatorsOverviewBlock/schema.js +21 -21
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.js +32 -6
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.jsx +133 -54
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.test.jsx +50 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.jsx +1 -1
- package/src/components/manage/Blocks/CaseStudyExplorer/FeatureDisplay.jsx +25 -22
- package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.jsx +0 -3
- package/src/components/manage/Blocks/CaseStudyExplorer/hooks.js +2 -2
- package/src/components/manage/Blocks/CaseStudyExplorer/styles.less +41 -4
- package/src/components/manage/Blocks/CaseStudyExplorer/utils.js +23 -3
- package/src/components/manage/Blocks/CollectionStatistics/CollectionStatsView.jsx +1 -1
- package/src/components/manage/Blocks/CollectionStatistics/CollectionStatsView.test.jsx +93 -0
- package/src/components/manage/Blocks/CountryProfileDetail/Edit.js +5 -0
- package/src/components/manage/Blocks/CountryProfileDetail/View.js +67 -0
- package/src/components/manage/Blocks/CountryProfileDetail/index.js +25 -0
- package/src/components/manage/Blocks/RASTBlock/ContextNavigation.jsx +3 -1
- package/src/components/manage/Blocks/RASTBlock/RASTAccordion.jsx +22 -17
- package/src/components/manage/Blocks/RASTBlock/RASTMap.jsx +17 -11
- package/src/components/manage/Blocks/RASTBlock/RASTMap.test.jsx +81 -0
- package/src/components/manage/Blocks/RASTBlock/RASTView.jsx +8 -0
- package/src/components/manage/Blocks/RASTBlock/schema.js +14 -1
- package/src/components/manage/Blocks/SearchAceContent/SearchAceContentView.jsx +3 -3
- package/src/components/manage/Blocks/TransRegionSelect/TransRegionSelectView.jsx +37 -88
- package/src/components/manage/Blocks/index.js +8 -0
- package/src/components/theme/BannerTitle/BannerTitle.jsx +28 -17
- package/src/components/theme/Header/Header.jsx +11 -2
- package/src/components/theme/TranslationDisclaimer/LanguagePreference.jsx +40 -53
- package/src/components/theme/TranslationDisclaimer/TranslationDisclaimer.jsx +20 -78
- package/src/components/theme/TranslationDisclaimer/TranslationInfo.jsx +124 -0
- package/src/components/theme/Views/AdaptationOptionView.jsx +10 -5
- package/src/components/theme/Views/C3SIndicatorView.jsx +10 -7
- package/src/components/theme/Views/CaseStudyView.jsx +11 -5
- package/src/components/theme/Views/CcaEventView.jsx +1 -5
- package/src/components/theme/Views/DatabaseItemView.jsx +3 -5
- package/src/components/theme/Views/EventView.jsx +0 -2
- package/src/components/theme/Views/NewsItemView.jsx +0 -2
- package/src/components/theme/Views/ProjectView.jsx +3 -5
- package/src/components/theme/Widgets/GeolocationWidget.jsx +1 -6
- package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/Header.jsx +1 -1
- package/src/customizations/volto/components/theme/View/DefaultView.jsx +1 -6
- package/src/index.js +23 -6
- package/src/search/index.js +3 -0
- package/src/slate-styles.less +15 -0
- package/theme/assets/images/Header/climate-adapt-logo-white.svg +61 -0
- package/theme/assets/images/Header/observatory-logo.svg +1 -0
- package/theme/assets/images/Header/observatory-white-logo.svg +1 -0
- package/theme/globals/observatory.less +1 -1
- package/theme/globals/site.overrides +10 -7
- package/theme/globals/views.less +72 -24
- package/src/components/manage/Blocks/TransRegionSelect/countries.json +0 -150
- package/src/components/manage/Widgets/CreatableSelectWidget.jsx +0 -316
- package/src/components/manage/Widgets/CreatableSelectWidget.test.jsx +0 -89
|
@@ -1,66 +1,145 @@
|
|
|
1
|
+
import React, { FormEvent } from 'react';
|
|
1
2
|
import { useIntl, FormattedMessage } from 'react-intl';
|
|
3
|
+
import { Accordion, Icon, Checkbox } from 'semantic-ui-react';
|
|
2
4
|
|
|
3
5
|
export default function CaseStudyFilters(props) {
|
|
4
6
|
const { filters, activeFilters, setActiveFilters } = props;
|
|
7
|
+
|
|
8
|
+
const resetFilters = () => {
|
|
9
|
+
let clone = { ...activeFilters };
|
|
10
|
+
Object.keys(activeFilters).forEach((element) => {
|
|
11
|
+
clone[element] = [];
|
|
12
|
+
});
|
|
13
|
+
setActiveFilters(clone);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let nrActiveFilters = 0;
|
|
17
|
+
Object.values(activeFilters).forEach((element) => {
|
|
18
|
+
nrActiveFilters += element.length;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const [activeIndex, setActiveIndex] = React.useState([]);
|
|
22
|
+
|
|
23
|
+
function handleClick(e, titleProps) {
|
|
24
|
+
let index = Object.create(activeIndex);
|
|
25
|
+
if (index.includes(titleProps.index)) {
|
|
26
|
+
index = index.filter(function (item) {
|
|
27
|
+
return item !== titleProps.index;
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
index.push(titleProps.index);
|
|
31
|
+
}
|
|
32
|
+
setActiveIndex(index);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const checkboxChangeHandler = (_event: FormEvent<HTMLInputElement>, data) => {
|
|
36
|
+
const temp = JSON.parse(JSON.stringify(activeFilters));
|
|
37
|
+
|
|
38
|
+
if (data.checked) {
|
|
39
|
+
temp[data.name].push(data.value);
|
|
40
|
+
} else {
|
|
41
|
+
temp[data.name] = temp[data.name].filter((value) => {
|
|
42
|
+
if (value !== data.value) return value;
|
|
43
|
+
return null;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
setActiveFilters(temp);
|
|
47
|
+
};
|
|
48
|
+
|
|
5
49
|
const intl = useIntl();
|
|
6
50
|
return (
|
|
7
51
|
<>
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
52
|
+
<Accordion exclusive={false} className="secondary">
|
|
53
|
+
<Accordion.Title
|
|
54
|
+
active={activeIndex.includes(0)}
|
|
55
|
+
index={0}
|
|
56
|
+
onClick={handleClick}
|
|
57
|
+
>
|
|
58
|
+
<Icon name="dropdown" />
|
|
59
|
+
<FormattedMessage
|
|
60
|
+
id="Adaptation sectors"
|
|
61
|
+
defaultMessage="Adaptation sectors"
|
|
62
|
+
/>
|
|
63
|
+
</Accordion.Title>
|
|
64
|
+
<Accordion.Content active={activeIndex.includes(0)}>
|
|
65
|
+
{Object.entries(filters?.sectors || {}).map(
|
|
66
|
+
([value, label], index) => (
|
|
67
|
+
<Checkbox
|
|
68
|
+
label={intl.formatMessage({ id: label })}
|
|
69
|
+
value={value}
|
|
70
|
+
checked={activeFilters.sectors.includes(value)}
|
|
71
|
+
name="sectors"
|
|
72
|
+
onChange={checkboxChangeHandler}
|
|
73
|
+
/>
|
|
74
|
+
),
|
|
75
|
+
)}
|
|
76
|
+
</Accordion.Content>
|
|
77
|
+
<Accordion.Title
|
|
78
|
+
active={activeIndex.includes(1)}
|
|
79
|
+
index={1}
|
|
80
|
+
onClick={handleClick}
|
|
81
|
+
>
|
|
82
|
+
<Icon name="dropdown" />
|
|
83
|
+
<FormattedMessage
|
|
84
|
+
id="Climate impacts"
|
|
85
|
+
defaultMessage="Climate impacts"
|
|
33
86
|
/>
|
|
34
|
-
</
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
setActiveFilters(temp);
|
|
60
|
-
}}
|
|
87
|
+
</Accordion.Title>
|
|
88
|
+
<Accordion.Content active={activeIndex.includes(1)}>
|
|
89
|
+
{Object.entries(filters?.impacts || {}).map(
|
|
90
|
+
([value, label], index) => (
|
|
91
|
+
// <p key={index}>
|
|
92
|
+
<Checkbox
|
|
93
|
+
label={intl.formatMessage({ id: label })}
|
|
94
|
+
checked={activeFilters.impacts.includes(value)}
|
|
95
|
+
value={value}
|
|
96
|
+
name="impacts"
|
|
97
|
+
onChange={checkboxChangeHandler}
|
|
98
|
+
/>
|
|
99
|
+
// </p>
|
|
100
|
+
),
|
|
101
|
+
)}
|
|
102
|
+
</Accordion.Content>
|
|
103
|
+
<Accordion.Title
|
|
104
|
+
active={activeIndex.includes(2)}
|
|
105
|
+
index={2}
|
|
106
|
+
onClick={handleClick}
|
|
107
|
+
>
|
|
108
|
+
<Icon name="dropdown" />
|
|
109
|
+
<FormattedMessage
|
|
110
|
+
id="Key type measures"
|
|
111
|
+
defaultMessage="Key type measures"
|
|
61
112
|
/>
|
|
62
|
-
</
|
|
63
|
-
|
|
113
|
+
</Accordion.Title>
|
|
114
|
+
<Accordion.Content active={activeIndex.includes(2)}>
|
|
115
|
+
{Object.entries(filters?.measures || {}).map(
|
|
116
|
+
([key, values], index) => (
|
|
117
|
+
<div className="subcategory">
|
|
118
|
+
<p>
|
|
119
|
+
<strong>{intl.formatMessage({ id: key })}</strong>
|
|
120
|
+
</p>
|
|
121
|
+
{Object.entries(values).map(([valKey, valData]) => (
|
|
122
|
+
<Checkbox
|
|
123
|
+
label={intl.formatMessage({ id: valData.value })}
|
|
124
|
+
value={valData.key}
|
|
125
|
+
checked={activeFilters.measures.includes(valData.key)}
|
|
126
|
+
name="measures"
|
|
127
|
+
onChange={checkboxChangeHandler}
|
|
128
|
+
/>
|
|
129
|
+
))}
|
|
130
|
+
</div>
|
|
131
|
+
),
|
|
132
|
+
)}
|
|
133
|
+
</Accordion.Content>
|
|
134
|
+
</Accordion>
|
|
135
|
+
{nrActiveFilters ? (
|
|
136
|
+
<button
|
|
137
|
+
className="ui primary button reset"
|
|
138
|
+
onClick={(_e) => resetFilters()}
|
|
139
|
+
>
|
|
140
|
+
Reset
|
|
141
|
+
</button>
|
|
142
|
+
) : null}
|
|
64
143
|
</>
|
|
65
144
|
);
|
|
66
145
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
import CaseStudyFilters from './CaseStudyFilters';
|
|
8
|
+
|
|
9
|
+
const mockStore = configureStore();
|
|
10
|
+
|
|
11
|
+
describe('CaseStudyFilters', () => {
|
|
12
|
+
it('should render the component', () => {
|
|
13
|
+
const data = {
|
|
14
|
+
filters: {
|
|
15
|
+
// sectors: [{ HEALTH: 'Health' }],
|
|
16
|
+
// impacts: [{ DROUGHT: 'Drought' }],
|
|
17
|
+
sectors: [],
|
|
18
|
+
impacts: [],
|
|
19
|
+
measures: {
|
|
20
|
+
// Measure1: [
|
|
21
|
+
// { key: 'M11', value: 'm11' },
|
|
22
|
+
// { key: 'M12', value: 'm12' },
|
|
23
|
+
// ],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
activeFilters: {
|
|
27
|
+
sectors: [],
|
|
28
|
+
impacts: [],
|
|
29
|
+
measures: [],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const store = mockStore({
|
|
34
|
+
userSession: { token: '1234' },
|
|
35
|
+
intl: {
|
|
36
|
+
locale: 'en',
|
|
37
|
+
messages: {},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const { container } = render(
|
|
42
|
+
<Provider store={store}>
|
|
43
|
+
<MemoryRouter>
|
|
44
|
+
<CaseStudyFilters {...data} />
|
|
45
|
+
</MemoryRouter>
|
|
46
|
+
</Provider>,
|
|
47
|
+
);
|
|
48
|
+
expect(container).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -12,7 +12,7 @@ export default function CaseStudyMap(props) {
|
|
|
12
12
|
const { items, activeItems } = props;
|
|
13
13
|
const [selectedCase, onSelectedCase] = React.useState();
|
|
14
14
|
|
|
15
|
-
const features = getFeatures(items);
|
|
15
|
+
const features = getFeatures(items);
|
|
16
16
|
|
|
17
17
|
const [tileWMSSources] = React.useState([
|
|
18
18
|
// , setTileWMSSources
|
|
@@ -4,33 +4,35 @@ import { FormattedMessage } from 'react-intl';
|
|
|
4
4
|
export default function FeatureDisplay({ feature }) {
|
|
5
5
|
return feature ? (
|
|
6
6
|
<div id="csepopup">
|
|
7
|
-
<
|
|
7
|
+
<p>
|
|
8
|
+
<strong>{feature.title}</strong> <a href={feature.url}>open DB</a>
|
|
9
|
+
</p>
|
|
8
10
|
<span className="img">
|
|
9
11
|
<center>
|
|
10
12
|
<img src={feature.image} alt={feature.title} />
|
|
11
13
|
</center>
|
|
12
14
|
</span>
|
|
15
|
+
<p style={{ marginBottom: '10px' }}>
|
|
16
|
+
<span className="blue">
|
|
17
|
+
<FormattedMessage
|
|
18
|
+
id="Adaptation sectors"
|
|
19
|
+
defaultMessage="Adaptation sectors"
|
|
20
|
+
/>
|
|
21
|
+
{': '}
|
|
22
|
+
</span>
|
|
23
|
+
<span>{feature.adaptations}</span>
|
|
24
|
+
</p>
|
|
25
|
+
<p style={{ marginBottom: '10px' }}>
|
|
26
|
+
<span className="blue">
|
|
27
|
+
<FormattedMessage
|
|
28
|
+
id="Climate impacts"
|
|
29
|
+
defaultMessage="Climate impacts"
|
|
30
|
+
/>
|
|
31
|
+
{': '}
|
|
32
|
+
</span>
|
|
33
|
+
<span>{feature.impacts}</span>
|
|
34
|
+
</p>
|
|
13
35
|
<p>
|
|
14
|
-
<p style={{ marginBottom: '10px' }}>
|
|
15
|
-
<span className="blue">
|
|
16
|
-
<FormattedMessage
|
|
17
|
-
id="Adaptation sectors"
|
|
18
|
-
defaultMessage="Adaptation sectors"
|
|
19
|
-
/>
|
|
20
|
-
{': '}
|
|
21
|
-
</span>
|
|
22
|
-
<span>{feature.adaptations}</span>
|
|
23
|
-
</p>
|
|
24
|
-
<p style={{ marginBottom: '10px' }}>
|
|
25
|
-
<span className="blue">
|
|
26
|
-
<FormattedMessage
|
|
27
|
-
id="Climate impacts"
|
|
28
|
-
defaultMessage="Climate impacts"
|
|
29
|
-
/>
|
|
30
|
-
{': '}
|
|
31
|
-
</span>
|
|
32
|
-
<span>{feature.impacts}</span>
|
|
33
|
-
</p>
|
|
34
36
|
<span className="blue">
|
|
35
37
|
<FormattedMessage
|
|
36
38
|
id="Adaptation options"
|
|
@@ -40,7 +42,8 @@ export default function FeatureDisplay({ feature }) {
|
|
|
40
42
|
</span>
|
|
41
43
|
<span
|
|
42
44
|
dangerouslySetInnerHTML={{
|
|
43
|
-
__html: feature.adaptation_options_links.
|
|
45
|
+
__html: feature.adaptation_options_links.replaceAll('<>', '; '),
|
|
46
|
+
// __html: feature.adaptation_options_links,
|
|
44
47
|
}}
|
|
45
48
|
></span>
|
|
46
49
|
</p>
|
|
@@ -60,7 +60,6 @@ export default function FeatureInteraction({ onFeatureSelect }) {
|
|
|
60
60
|
if (subfeatures.length === 1) {
|
|
61
61
|
const selectedFeature = subfeatures[0].values_;
|
|
62
62
|
onFeatureSelect(selectedFeature);
|
|
63
|
-
// console.log('onfeatureselect');
|
|
64
63
|
} else {
|
|
65
64
|
// zoom to extent of cluster points
|
|
66
65
|
const extent = getExtentOfFeatures(subfeatures);
|
|
@@ -68,12 +67,10 @@ export default function FeatureInteraction({ onFeatureSelect }) {
|
|
|
68
67
|
let extentBuffer =
|
|
69
68
|
(extent[3] - extent[1] + extent[2] - extent[0]) / 4;
|
|
70
69
|
extentBuffer = extentBuffer < 500 ? 500 : extentBuffer;
|
|
71
|
-
// console.log('extentBuffer', { extent, extentBuffer });
|
|
72
70
|
const paddedExtent = ol.extent.buffer(extent, extentBuffer);
|
|
73
71
|
|
|
74
72
|
// const paddedExtent = ol.extent.buffer(extent, 50000);
|
|
75
73
|
map.getView().fit(paddedExtent, { ...map.getSize(), duration: 1000 });
|
|
76
|
-
// console.log('onclusterzoom');
|
|
77
74
|
}
|
|
78
75
|
});
|
|
79
76
|
|
|
@@ -4,7 +4,7 @@ import superagent from 'superagent';
|
|
|
4
4
|
const cases_url = '@@case-studies-map.arcgis.json';
|
|
5
5
|
|
|
6
6
|
export function useCases(url) {
|
|
7
|
-
const [cases, setCases] = React.useState([]);
|
|
7
|
+
const [cases, setCases] = React.useState([[], []]);
|
|
8
8
|
|
|
9
9
|
React.useEffect(() => {
|
|
10
10
|
superagent
|
|
@@ -12,7 +12,7 @@ export function useCases(url) {
|
|
|
12
12
|
.set('accept', 'json')
|
|
13
13
|
.then((resp) => {
|
|
14
14
|
const res = JSON.parse(resp.text);
|
|
15
|
-
setCases(res.features);
|
|
15
|
+
setCases({ features: res.features, filters: res.filters });
|
|
16
16
|
});
|
|
17
17
|
}, []);
|
|
18
18
|
|
|
@@ -5,12 +5,19 @@
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
#csepopup {
|
|
8
|
+
border-bottom: 6px solid #005c96;
|
|
9
|
+
|
|
8
10
|
p {
|
|
11
|
+
padding: 0 10px 0 10px;
|
|
9
12
|
font-size: 13px;
|
|
10
13
|
|
|
11
14
|
p {
|
|
12
15
|
margin-bottom: 10px;
|
|
13
16
|
}
|
|
17
|
+
|
|
18
|
+
a {
|
|
19
|
+
text-decoration: underline;
|
|
20
|
+
}
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
span.blue {
|
|
@@ -33,16 +40,18 @@
|
|
|
33
40
|
position: relative;
|
|
34
41
|
padding: 10px;
|
|
35
42
|
border-bottom: 1px solid #d8d8d8;
|
|
43
|
+
margin-top: 0 !important;
|
|
36
44
|
margin-bottom: 0 !important;
|
|
37
|
-
background-color: #
|
|
38
|
-
|
|
45
|
+
background-color: #fff;
|
|
46
|
+
clear: both;
|
|
47
|
+
color: #005c96;
|
|
39
48
|
cursor: pointer;
|
|
40
49
|
font-size: 14px;
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
p {
|
|
44
|
-
padding: 2px;
|
|
45
|
-
padding-
|
|
53
|
+
// padding: 2px;
|
|
54
|
+
padding-bottom: 10px;
|
|
46
55
|
clear: both;
|
|
47
56
|
line-height: 20px;
|
|
48
57
|
|
|
@@ -56,4 +65,32 @@
|
|
|
56
65
|
float: right;
|
|
57
66
|
}
|
|
58
67
|
}
|
|
68
|
+
|
|
69
|
+
div.title {
|
|
70
|
+
width: 100%;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ui.accordion > .title > .icon {
|
|
74
|
+
line-height: 1rem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ui.accordion p {
|
|
78
|
+
margin: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ui.accordion .subcategory {
|
|
82
|
+
margin-bottom: 30px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
button.reset {
|
|
86
|
+
margin-top: 20px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ui.checkbox {
|
|
90
|
+
width: 100%;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.section-case-study-explorer #popup-overlay {
|
|
95
|
+
padding: 0;
|
|
59
96
|
}
|
|
@@ -19,6 +19,7 @@ export function getFeatures(cases) {
|
|
|
19
19
|
impacts: c.properties.impacts_str,
|
|
20
20
|
adaptation_options_links: c.properties.adaptation_options_links,
|
|
21
21
|
index: index,
|
|
22
|
+
url: c.properties.url,
|
|
22
23
|
},
|
|
23
24
|
false,
|
|
24
25
|
);
|
|
@@ -29,7 +30,12 @@ export function getFeatures(cases) {
|
|
|
29
30
|
|
|
30
31
|
export function filterCases(cases, activeFilters) {
|
|
31
32
|
const data = cases.filter((_case) => {
|
|
32
|
-
if (
|
|
33
|
+
if (
|
|
34
|
+
activeFilters.sectors.length === 0 &&
|
|
35
|
+
activeFilters.measures.length === 0 &&
|
|
36
|
+
activeFilters.impacts.length === 0
|
|
37
|
+
)
|
|
38
|
+
return _case;
|
|
33
39
|
|
|
34
40
|
let flag = false;
|
|
35
41
|
|
|
@@ -41,6 +47,10 @@ export function filterCases(cases, activeFilters) {
|
|
|
41
47
|
if (_case.properties.impacts.includes(',' + filter + ',')) flag = true;
|
|
42
48
|
});
|
|
43
49
|
|
|
50
|
+
activeFilters.measures.forEach((filter) => {
|
|
51
|
+
if (_case.properties.ktms.includes(',' + filter + ',')) flag = true;
|
|
52
|
+
});
|
|
53
|
+
|
|
44
54
|
return flag ? _case : false;
|
|
45
55
|
});
|
|
46
56
|
|
|
@@ -48,10 +58,11 @@ export function filterCases(cases, activeFilters) {
|
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
export function getFilters(cases) {
|
|
51
|
-
let _filters = { sectors: {}, impacts: {} };
|
|
61
|
+
let _filters = { sectors: {}, impacts: {}, measures: {} };
|
|
52
62
|
|
|
53
63
|
for (let key of Object.keys(cases)) {
|
|
54
64
|
const _case = cases[key];
|
|
65
|
+
|
|
55
66
|
let sectorKeys = _case.properties.sectors.split(',');
|
|
56
67
|
let sectorNames = _case.properties.sectors_str.split(',');
|
|
57
68
|
for (let i = 0; i < sectorNames.length; i++) {
|
|
@@ -59,15 +70,24 @@ export function getFilters(cases) {
|
|
|
59
70
|
_filters.sectors[sectorKeys[i + 1]] = sectorNames[i];
|
|
60
71
|
}
|
|
61
72
|
}
|
|
73
|
+
|
|
62
74
|
let impactKeys = _case.properties.impacts.split(',');
|
|
63
75
|
let impactNames = _case.properties.impacts_str.split(',');
|
|
64
|
-
|
|
65
76
|
for (let i = 0; i < impactNames.length; i++) {
|
|
66
77
|
if (!_filters.impacts.hasOwnProperty(impactKeys[i + 1])) {
|
|
67
78
|
_filters.impacts[impactKeys[i + 1]] = impactNames[i];
|
|
68
79
|
}
|
|
69
80
|
}
|
|
81
|
+
|
|
82
|
+
// let ktmKeys = _case.properties.ktms.split(',');
|
|
83
|
+
// let ktmNames = _case.properties.impacts_str.split(',');
|
|
84
|
+
// for (let i = 0; i < ktmKeys.length; i++) {
|
|
85
|
+
// if (!_filters.ktms.hasOwnProperty(ktmKeys[i])) {
|
|
86
|
+
// _filters.ktms[ktmKeys[i]] = 1;
|
|
87
|
+
// }
|
|
88
|
+
// }
|
|
70
89
|
}
|
|
90
|
+
// console.log('getFilters:', _filters);
|
|
71
91
|
|
|
72
92
|
return _filters;
|
|
73
93
|
}
|
|
@@ -90,7 +90,7 @@ export default function CollectionStatsView(props) {
|
|
|
90
90
|
let stats = useStats(getBaseUrl(pathname), id, data);
|
|
91
91
|
|
|
92
92
|
const groupDefinition =
|
|
93
|
-
config.blocks.blocksConfig.collectionStats
|
|
93
|
+
config.blocks.blocksConfig.collectionStats?.groups?.[field] || {};
|
|
94
94
|
const { cleanup, icons = {}, iconComponent: IconComponent } = groupDefinition;
|
|
95
95
|
|
|
96
96
|
if (cleanup) stats = cleanup(stats);
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
import CollectionStatsView from './CollectionStatsView';
|
|
8
|
+
import config from '@plone/volto/registry';
|
|
9
|
+
import applyConfig from './index';
|
|
10
|
+
|
|
11
|
+
const mockStore = configureStore();
|
|
12
|
+
|
|
13
|
+
applyConfig(config);
|
|
14
|
+
|
|
15
|
+
describe('CollectionStatsView', () => {
|
|
16
|
+
it('should render the component', () => {
|
|
17
|
+
const data = {
|
|
18
|
+
id: 'id-1',
|
|
19
|
+
data: {
|
|
20
|
+
aggregateField: {
|
|
21
|
+
label: 'Portal type',
|
|
22
|
+
value: 'portal_type',
|
|
23
|
+
},
|
|
24
|
+
href: [
|
|
25
|
+
{
|
|
26
|
+
'@id': '/en/observatory/advanced-search',
|
|
27
|
+
title: 'Resource catalogue',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
query: {
|
|
31
|
+
query: [
|
|
32
|
+
{
|
|
33
|
+
i: 'include_in_observatory',
|
|
34
|
+
o: 'plone.app.querystring.operation.boolean.isTrue',
|
|
35
|
+
v: '',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
i: 'path',
|
|
39
|
+
o: 'plone.app.querystring.operation.string.absolutePath',
|
|
40
|
+
v: '/en',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
i: 'review_state',
|
|
44
|
+
o: 'plone.app.querystring.operation.selection.any',
|
|
45
|
+
v: ['published'],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
sort_order: 'ascending',
|
|
49
|
+
queryParameterStyle: 'EEASemanticSearch',
|
|
50
|
+
showLabel: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
path: '/some-location',
|
|
54
|
+
pathname: '/some-location',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const store = mockStore({
|
|
58
|
+
userSession: { token: '1234' },
|
|
59
|
+
intl: {
|
|
60
|
+
locale: 'en',
|
|
61
|
+
messages: {},
|
|
62
|
+
},
|
|
63
|
+
querystats: {
|
|
64
|
+
'id-1': {
|
|
65
|
+
items: {
|
|
66
|
+
Event: 82,
|
|
67
|
+
'News Item': 116,
|
|
68
|
+
'eea.climateadapt.aceproject': 60,
|
|
69
|
+
'eea.climateadapt.adaptationoption': 1,
|
|
70
|
+
'eea.climateadapt.c3sindicator': 9,
|
|
71
|
+
'eea.climateadapt.casestudy': 32,
|
|
72
|
+
'eea.climateadapt.guidancedocument': 21,
|
|
73
|
+
'eea.climateadapt.indicator': 14,
|
|
74
|
+
'eea.climateadapt.informationportal': 27,
|
|
75
|
+
'eea.climateadapt.organisation': 22,
|
|
76
|
+
'eea.climateadapt.publicationreport': 187,
|
|
77
|
+
'eea.climateadapt.tool': 14,
|
|
78
|
+
'eea.climateadapt.video': 17,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const { container } = render(
|
|
85
|
+
<Provider store={store}>
|
|
86
|
+
<MemoryRouter>
|
|
87
|
+
<CollectionStatsView {...data} />
|
|
88
|
+
</MemoryRouter>
|
|
89
|
+
</Provider>,
|
|
90
|
+
);
|
|
91
|
+
expect(container.querySelector('.collection-stats')).toBeInTheDocument();
|
|
92
|
+
});
|
|
93
|
+
});
|