@eeacms/volto-cca-policy 0.1.102 → 0.2.1

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +0 -1
  3. package/package.json +1 -1
  4. package/src/components/manage/Blocks/C3SIndicatorsGlossaryBlock/C3SIndicatorsGlossaryBlockView.jsx +13 -26
  5. package/src/components/manage/Blocks/C3SIndicatorsListingBlock/C3SIndicatorsListingBlockEdit.jsx +32 -0
  6. package/src/components/manage/Blocks/C3SIndicatorsListingBlock/C3SIndicatorsListingBlockView.jsx +36 -0
  7. package/src/components/manage/Blocks/C3SIndicatorsListingBlock/index.js +29 -0
  8. package/src/components/manage/Blocks/C3SIndicatorsListingBlock/schema.js +14 -0
  9. package/src/components/manage/Blocks/C3SIndicatorsOverviewBlock/C3SIndicatorsOverviewBlockView.jsx +11 -40
  10. package/src/components/manage/Blocks/C3SIndicatorsOverviewBlock/schema.js +21 -21
  11. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.js +32 -6
  12. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.jsx +133 -54
  13. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.test.jsx +50 -0
  14. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.jsx +1 -1
  15. package/src/components/manage/Blocks/CaseStudyExplorer/FeatureDisplay.jsx +25 -22
  16. package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.jsx +0 -3
  17. package/src/components/manage/Blocks/CaseStudyExplorer/hooks.js +2 -2
  18. package/src/components/manage/Blocks/CaseStudyExplorer/styles.less +41 -4
  19. package/src/components/manage/Blocks/CaseStudyExplorer/utils.js +23 -3
  20. package/src/components/manage/Blocks/CollectionStatistics/CollectionStatsView.jsx +1 -1
  21. package/src/components/manage/Blocks/CollectionStatistics/CollectionStatsView.test.jsx +93 -0
  22. package/src/components/manage/Blocks/CountryProfileDetail/Edit.js +5 -0
  23. package/src/components/manage/Blocks/CountryProfileDetail/View.js +67 -0
  24. package/src/components/manage/Blocks/CountryProfileDetail/index.js +25 -0
  25. package/src/components/manage/Blocks/RASTBlock/ContextNavigation.jsx +3 -1
  26. package/src/components/manage/Blocks/RASTBlock/RASTAccordion.jsx +22 -17
  27. package/src/components/manage/Blocks/RASTBlock/RASTMap.jsx +17 -11
  28. package/src/components/manage/Blocks/RASTBlock/RASTMap.test.jsx +81 -0
  29. package/src/components/manage/Blocks/RASTBlock/RASTView.jsx +8 -0
  30. package/src/components/manage/Blocks/RASTBlock/schema.js +14 -1
  31. package/src/components/manage/Blocks/SearchAceContent/SearchAceContentView.jsx +3 -3
  32. package/src/components/manage/Blocks/TransRegionSelect/TransRegionSelectView.jsx +37 -88
  33. package/src/components/manage/Blocks/index.js +8 -0
  34. package/src/components/theme/BannerTitle/BannerTitle.jsx +28 -17
  35. package/src/components/theme/Header/Header.jsx +11 -2
  36. package/src/components/theme/TranslationDisclaimer/LanguagePreference.jsx +40 -53
  37. package/src/components/theme/TranslationDisclaimer/TranslationDisclaimer.jsx +20 -78
  38. package/src/components/theme/TranslationDisclaimer/TranslationInfo.jsx +124 -0
  39. package/src/components/theme/Views/AdaptationOptionView.jsx +10 -5
  40. package/src/components/theme/Views/C3SIndicatorView.jsx +10 -7
  41. package/src/components/theme/Views/CaseStudyView.jsx +11 -5
  42. package/src/components/theme/Views/CcaEventView.jsx +1 -5
  43. package/src/components/theme/Views/DatabaseItemView.jsx +3 -5
  44. package/src/components/theme/Views/EventView.jsx +0 -2
  45. package/src/components/theme/Views/NewsItemView.jsx +0 -2
  46. package/src/components/theme/Views/ProjectView.jsx +3 -5
  47. package/src/components/theme/Widgets/GeolocationWidget.jsx +1 -6
  48. package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/Header.jsx +1 -1
  49. package/src/customizations/volto/components/theme/View/DefaultView.jsx +1 -6
  50. package/src/index.js +23 -6
  51. package/src/search/index.js +3 -0
  52. package/src/slate-styles.less +15 -0
  53. package/theme/assets/images/Header/climate-adapt-logo-white.svg +61 -0
  54. package/theme/assets/images/Header/observatory-logo.svg +1 -0
  55. package/theme/assets/images/Header/observatory-white-logo.svg +1 -0
  56. package/theme/globals/observatory.less +1 -1
  57. package/theme/globals/site.overrides +25 -7
  58. package/theme/globals/views.less +72 -24
  59. package/src/components/manage/Blocks/TransRegionSelect/countries.json +0 -150
  60. package/src/components/manage/Widgets/CreatableSelectWidget.jsx +0 -316
  61. package/src/components/manage/Widgets/CreatableSelectWidget.test.jsx +0 -89
package/CHANGELOG.md CHANGED
@@ -4,6 +4,76 @@ 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.1](https://github.com/eea/volto-cca-policy/compare/0.2.0...0.2.1) - 5 April 2024
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: default position for disclaimer [kreafox - [`1a8ab49`](https://github.com/eea/volto-cca-policy/commit/1a8ab496d091ef9894ca31bc2f1d6d226863e720)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - Style improvements [kreafox - [`91d4e68`](https://github.com/eea/volto-cca-policy/commit/91d4e68512fdbaef0b9f1e9db8a227f629c9d17b)]
16
+ ### [0.2.0](https://github.com/eea/volto-cca-policy/compare/0.1.102...0.2.0) - 5 April 2024
17
+
18
+ #### :rocket: New Features
19
+
20
+ - feat: add option to use white variant of logo for subsites [kreafox - [`7a443d5`](https://github.com/eea/volto-cca-policy/commit/7a443d534e824f3e576a39810b116aa224ff50c7)]
21
+ - feat: use toast message for translation disclaimers [kreafox - [`941a53c`](https://github.com/eea/volto-cca-policy/commit/941a53c682b922f049740ab56ea996a0d4f7a1bf)]
22
+ - feat: add white variant of logo, add slate styles [kreafox - [`ad0dabf`](https://github.com/eea/volto-cca-policy/commit/ad0dabff55a42ff1b88ef58ac51f752252cf3344)]
23
+
24
+ #### :bug: Bug Fixes
25
+
26
+ - fix: banner title component in case of homepage [kreafox - [`868d45d`](https://github.com/eea/volto-cca-policy/commit/868d45d8652935913a9a054e6ce897a1013c5fe6)]
27
+ - fix: disclaimers on inversed homepage [kreafox - [`5d61622`](https://github.com/eea/volto-cca-policy/commit/5d6162289d8cda47452186e85b4e9439b677eebd)]
28
+
29
+ #### :nail_care: Enhancements
30
+
31
+ - change: remove CreatableSelectWidget (we can use it now from volto-eea-website-theme) [kreafox - [`6c8a242`](https://github.com/eea/volto-cca-policy/commit/6c8a242cb22b4ee65c8d391ce96e5639bba687bf)]
32
+ - change: move disclaimer to appExtras [kreafox - [`55c665f`](https://github.com/eea/volto-cca-policy/commit/55c665fec06c8174db0d8f92eefc04b5b8af1512)]
33
+
34
+ #### :house: Internal changes
35
+
36
+ - style: improve translation disclaimer on mobile [kreafox - [`604e3a1`](https://github.com/eea/volto-cca-policy/commit/604e3a1007a0b0a3daf7f6ce335c41676b6d0efc)]
37
+
38
+ #### :hammer_and_wrench: Others
39
+
40
+ - Fix test [Tiberiu Ichim - [`3e2760b`](https://github.com/eea/volto-cca-policy/commit/3e2760b4c3ebb0559283e0fea32c35f44b7cb987)]
41
+ - Refs #268061 - reactui checkbox [Tripon Eugen - [`a227576`](https://github.com/eea/volto-cca-policy/commit/a22757632d0ef96ed365ceab04845961c271450c)]
42
+ - Update README.md (just to retry tests) [Ghiță Bizău - [`db26abd`](https://github.com/eea/volto-cca-policy/commit/db26abd73d52118185340de2b3ca6335939d005e)]
43
+ - Try to fix test: Uncaught [TypeError: Cannot read properties of undefined (reading 'groups')] [GhitaB - [`d1d1e8e`](https://github.com/eea/volto-cca-policy/commit/d1d1e8eefbf96b96384a1584e25eaf0591416308)]
44
+ - RASTMap: fix Invalid DOM property stop-color. Did you mean stopColor?. [GhitaB - [`eb167d4`](https://github.com/eea/volto-cca-policy/commit/eb167d4b012643e8e6fc720767446804a9fdf260)]
45
+ - Refs #268061 - testing [Tripon Eugen - [`095371a`](https://github.com/eea/volto-cca-policy/commit/095371af6eb57b1fcfcadf70c26afdef90b2d8ef)]
46
+ - Add test. [GhitaB - [`6a50882`](https://github.com/eea/volto-cca-policy/commit/6a508821236df764d5ab07c38215f13445fc4e9a)]
47
+ - Don't fail in SSR [Tiberiu Ichim - [`8cd6b71`](https://github.com/eea/volto-cca-policy/commit/8cd6b71cba148e505a00007dfc1c164cb8df401f)]
48
+ - Refs #268061 - coverage test [Tripon Eugen - [`8374f66`](https://github.com/eea/volto-cca-policy/commit/8374f66f2feecfe672596c6b50f70ff1f3fc653e)]
49
+ - Refs #268061 - rastmap coverage unit test [Tripon Eugen - [`07bb646`](https://github.com/eea/volto-cca-policy/commit/07bb646e9c73bb1f42bd258877d0ef01cf8e6353)]
50
+ - Refs #268061 - add filter test and effect [Tripon Eugen - [`e2daa4b`](https://github.com/eea/volto-cca-policy/commit/e2daa4b9c00232ed7fc7cbfdbc7bcd3880940e67)]
51
+ - Refs #268061 - add filter test [Tripon Eugen - [`9bacc3d`](https://github.com/eea/volto-cca-policy/commit/9bacc3d4176d391d6565d32f953054b1bf348e39)]
52
+ - Refs #268061 - key type measure filter css [Tripon Eugen - [`7bd2e22`](https://github.com/eea/volto-cca-policy/commit/7bd2e2266ff18604161b6fba57fa5d7e06f068dd)]
53
+ - Refs #268061 - key type measure filter css [Tripon Eugen - [`270fd0c`](https://github.com/eea/volto-cca-policy/commit/270fd0cb252a08a443ec9a14b32c915c443511f1)]
54
+ - Refs #268061 - accordion css [Tripon Eugen - [`6665dc6`](https://github.com/eea/volto-cca-policy/commit/6665dc630e9292d6b7b2e36e4cd35f5caaa38dcd)]
55
+ - Refs #268061 - add key type measure design, popup design and filter accordion [Tripon Eugen - [`71b1b21`](https://github.com/eea/volto-cca-policy/commit/71b1b211524f3938c0a6e1c09b4e163bd15e31ae)]
56
+ - Refs #161494 - country profile detail [Tripon Eugen - [`109e56a`](https://github.com/eea/volto-cca-policy/commit/109e56ace11974d98667c5e4038d894c9cc0671a)]
57
+ - bump 0.2.0 [kreafox - [`83c5d52`](https://github.com/eea/volto-cca-policy/commit/83c5d52aa9e97ff635d7199acde4cc3d1579dae9)]
58
+ - tests: fix duplicated code issue [kreafox - [`1b291a4`](https://github.com/eea/volto-cca-policy/commit/1b291a43d7461b0b8930c6c9bb87944b8e2e73c5)]
59
+ - eslint fixes [Tiberiu Ichim - [`370410b`](https://github.com/eea/volto-cca-policy/commit/370410b41b2e5b01c11ce1ca2955bb96dcc5e529)]
60
+ - We don't need the category here, its provided by the backend [Tiberiu Ichim - [`1a60c4e`](https://github.com/eea/volto-cca-policy/commit/1a60c4e3cf298effd35608678a1270d29b6c08d9)]
61
+ - Refactor indicators listing/overview blocks [Tiberiu Ichim - [`635a812`](https://github.com/eea/volto-cca-policy/commit/635a812f87e8a7ac248b6aa4012f6c2a6de37283)]
62
+ - No need axios [Tiberiu Ichim - [`1d6e5b1`](https://github.com/eea/volto-cca-policy/commit/1d6e5b1d40a456674683bf09a623139df360c5f8)]
63
+ - Simplify c3s_indicators_overview code [Tiberiu Ichim - [`f29a446`](https://github.com/eea/volto-cca-policy/commit/f29a4462727316dbd661cbca62dd970ba9640f92)]
64
+ - test: update snapshots [kreafox - [`03cdb0b`](https://github.com/eea/volto-cca-policy/commit/03cdb0bfbd42d2f01abdc6d3e1ff1cd80126b943)]
65
+ - Don't call hook conditionally [Tiberiu Ichim - [`2256907`](https://github.com/eea/volto-cca-policy/commit/2256907e6f6a6379b2dd9e3525d0e881febca4b7)]
66
+ - Refactor TransRegionSelectView [Tiberiu Ichim - [`89b00c2`](https://github.com/eea/volto-cca-policy/commit/89b00c272b6407b215a4785e7c7ce9f212797954)]
67
+ - Refs #260715 - test coverage add RASTMap add items [Tripon Eugen - [`58a898c`](https://github.com/eea/volto-cca-policy/commit/58a898c44e3353ed14ff32531dce26bda20901f6)]
68
+ - Refs #260715 - test coverage add RASTMap [Tripon Eugen - [`3fc0193`](https://github.com/eea/volto-cca-policy/commit/3fc0193108808edaac934c5bbd6ec6002cd28917)]
69
+ - Refs #260715 - display arrow icons only if show sub_folders [Tripon Eugen - [`772a8ad`](https://github.com/eea/volto-cca-policy/commit/772a8add196bdeb8d6ebe954225bd5146a6231a1)]
70
+ - Add alias for North West Europe [Tiberiu Ichim - [`644c75b`](https://github.com/eea/volto-cca-policy/commit/644c75bf5a73f87890a6f7fb8199cea9e81634ff)]
71
+ - Refs #260715 - remove comment [Tripon Eugen - [`33283d7`](https://github.com/eea/volto-cca-policy/commit/33283d7f6367bda2ae7d20f830e9ed842ba4a625)]
72
+ - Refs #260715 - rast options show/hide subfolders [Tripon Eugen - [`18bff32`](https://github.com/eea/volto-cca-policy/commit/18bff32426a94a9a174509ffd67d92342e1f12e8)]
73
+ - Refs #260715 - rename label [Tripon Eugen - [`cba2862`](https://github.com/eea/volto-cca-policy/commit/cba28622fc26bedc895511e3e6091430bbcd973d)]
74
+ - Refs #260715 - eslint [Tripon Eugen - [`182369c`](https://github.com/eea/volto-cca-policy/commit/182369c92ecd94694bf704347675984024a9fa42)]
75
+ - Refs #260715 - rast map skip folders by index list [Tripon Eugen - [`09b0ddd`](https://github.com/eea/volto-cca-policy/commit/09b0dddb9b5355cdf68b1f5483d9e1069eeb3615)]
76
+ - Refs #267596 - set extraQueryParams [Tripon Eugen - [`4205b72`](https://github.com/eea/volto-cca-policy/commit/4205b728e863588ff279d03413cd02796b490a38)]
7
77
  ### [0.1.102](https://github.com/eea/volto-cca-policy/compare/0.1.101...0.1.102) - 27 March 2024
8
78
 
9
79
  #### :hammer_and_wrench: Others
package/README.md CHANGED
@@ -96,4 +96,3 @@ don-template/blob/master/LICENSE.md) for details.
96
96
  ## Funding
97
97
 
98
98
  [European Environment Agency (EU)](http://eea.europa.eu)
99
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.102",
3
+ "version": "0.2.1",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,35 +1,22 @@
1
1
  import React from 'react';
2
- import axios from 'axios';
3
2
 
4
3
  export default function C3SIndicatorsGlossaryBlockView(props) {
5
- const [tableHTML, setTableHTML] = React.useState('');
6
-
7
- const getIndicatorsData = () => {
8
- const url =
9
- '/++api++/en/knowledge/european-climate-data-explorer/@c3s_indicators_glossary_table_api';
10
-
11
- axios
12
- .get(url)
13
- .then((response) => {
14
- setTableHTML(response.data.c3s_indicators_glossary_table);
15
- })
16
- .catch((error) => {
17
- // console.error(error);
18
- });
19
- };
20
-
21
- React.useEffect(() => {
22
- getIndicatorsData();
23
- });
4
+ const { metadata, properties, mode = 'view' } = props;
5
+ const content = metadata || properties;
6
+ const { c3s_indicators_glossary_table } = content?.['@components'] || {};
24
7
 
25
8
  return (
26
9
  <div className="block c3sindicators-glossary-block">
27
- <div
28
- className="glossary-table"
29
- dangerouslySetInnerHTML={{
30
- __html: tableHTML,
31
- }}
32
- />
10
+ {mode === 'view' ? (
11
+ <div
12
+ className="glossary-table"
13
+ dangerouslySetInnerHTML={{
14
+ __html: c3s_indicators_glossary_table || 'No content',
15
+ }}
16
+ />
17
+ ) : (
18
+ <div>C3SIndicatorsGlossaryBlockView</div>
19
+ )}
33
20
  </div>
34
21
  );
35
22
  }
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+
3
+ import { SidebarPortal } from '@plone/volto/components';
4
+ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
5
+
6
+ import C3SIndicatorsListingBlockView from './C3SIndicatorsListingBlockView';
7
+ import schema from './schema';
8
+
9
+ export default function C3SIndicatorsOverviewBlockEdit(props) {
10
+ const { block, data, onChangeBlock, selected, id } = props;
11
+
12
+ return (
13
+ <div>
14
+ <C3SIndicatorsListingBlockView data={data} id={id} mode="edit" />
15
+ <SidebarPortal selected={selected}>
16
+ <BlockDataForm
17
+ block={block}
18
+ title={schema.title}
19
+ schema={schema}
20
+ onChangeField={(id, value) => {
21
+ onChangeBlock(block, {
22
+ ...data,
23
+ [id]: value,
24
+ });
25
+ }}
26
+ onChangeBlock={onChangeBlock}
27
+ formData={data}
28
+ />
29
+ </SidebarPortal>
30
+ </div>
31
+ );
32
+ }
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { UniversalLink } from '@plone/volto/components';
3
+
4
+ export default function C3SIndicatorsListingBlockView(props) {
5
+ const { metadata, properties, mode = 'view' } = props;
6
+ const content = metadata || properties;
7
+ const { c3s_indicators_listing } = content?.['@components'] || {};
8
+
9
+ if (!c3s_indicators_listing) {
10
+ if (mode === 'edit') {
11
+ return <div>C3SIndicatorsListingBlockView</div>;
12
+ } else {
13
+ return null;
14
+ }
15
+ }
16
+
17
+ const { description, items } = c3s_indicators_listing;
18
+
19
+ return (
20
+ <div className="block c3sindicators-listing-block">
21
+ <div
22
+ className="description"
23
+ dangerouslySetInnerHTML={{
24
+ __html: description,
25
+ }}
26
+ />
27
+ <ul>
28
+ {items?.map((item, index) => (
29
+ <li key={index}>
30
+ <UniversalLink href={item.url}>{item.title}</UniversalLink>
31
+ </li>
32
+ ))}
33
+ </ul>
34
+ </div>
35
+ );
36
+ }
@@ -0,0 +1,29 @@
1
+ import zoomSVG from '@plone/volto/icons/zoom.svg';
2
+ import C3SIndicatorsListingBlockEdit from './C3SIndicatorsListingBlockEdit';
3
+ import C3SIndicatorsListingBlockView from './C3SIndicatorsListingBlockView';
4
+
5
+ import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
6
+
7
+ export default function installBlock(config) {
8
+ const blocksConfig = config.blocks.blocksConfig;
9
+
10
+ blocksConfig.c3SIndicatorListingBlock = {
11
+ id: 'c3SIndicatorListingBlock',
12
+ title: 'C3S Indicators Listing',
13
+ icon: zoomSVG,
14
+ group: 'site',
15
+ view: C3SIndicatorsListingBlockView,
16
+ edit: C3SIndicatorsListingBlockEdit,
17
+ sidebarTab: 1,
18
+ security: {
19
+ addPermission: [],
20
+ view: [],
21
+ },
22
+ variations: [],
23
+ restricted: ({ properties, block }) => {
24
+ return blockAvailableInMission(properties, block);
25
+ },
26
+ };
27
+
28
+ return config;
29
+ }
@@ -0,0 +1,14 @@
1
+ export default {
2
+ title: 'C3S Indicators Listing',
3
+
4
+ fieldsets: [
5
+ {
6
+ id: 'default',
7
+ title: 'Default',
8
+ fields: [],
9
+ },
10
+ ],
11
+
12
+ properties: {},
13
+ required: [],
14
+ };
@@ -1,55 +1,26 @@
1
1
  import React from 'react';
2
- import axios from 'axios';
3
- import { UniversalLink } from '@plone/volto/components';
4
2
 
5
3
  export default function C3SIndicatorsOverviewBlockView(props) {
6
- const [pageDescription, setPageDescription] = React.useState('');
7
- const [indicators, setIndicators] = React.useState([]);
4
+ const { metadata, properties, mode = 'view' } = props;
5
+ const content = metadata || properties;
6
+ const { c3s_indicators_overview } = content?.['@components'] || {};
8
7
 
9
- const category = props.data.category;
10
-
11
- const getIndicatorsData = () => {
12
- const url =
13
- '/++api++/en/knowledge/european-climate-data-explorer/' +
14
- category +
15
- '/@c3s_indicators_overview_api';
16
-
17
- axios
18
- .get(url)
19
- .then((response) => {
20
- setPageDescription(response.data.c3s_indicators_overview.description);
21
- setIndicators(response.data.c3s_indicators_overview.items);
22
- })
23
- .catch((error) => {
24
- // console.error(error);
25
- });
26
- };
27
-
28
- React.useEffect(() => {
29
- getIndicatorsData();
30
- // eslint-disable-next-line react-hooks/exhaustive-deps
31
- }, [category]);
8
+ if (!c3s_indicators_overview) {
9
+ if (mode === 'edit') {
10
+ return <div>C3SIndicatorsOverviewBlockView</div>;
11
+ } else {
12
+ return null;
13
+ }
14
+ }
32
15
 
33
16
  return (
34
17
  <div className="block c3sindicators-overview-block">
35
18
  <div
36
19
  className="description"
37
20
  dangerouslySetInnerHTML={{
38
- __html: pageDescription,
21
+ __html: c3s_indicators_overview,
39
22
  }}
40
23
  />
41
-
42
- {indicators ? (
43
- <ul>
44
- {indicators.map((item, index) => (
45
- <li key={index}>
46
- <UniversalLink href={item.url}>{item.title}</UniversalLink>
47
- </li>
48
- ))}
49
- </ul>
50
- ) : (
51
- <p>Loading...</p>
52
- )}
53
24
  </div>
54
25
  );
55
26
  }
@@ -1,4 +1,22 @@
1
- const fields = ['category'];
1
+ // const fields = ['category'];
2
+ //
3
+ // category: {
4
+ // title: 'Category',
5
+ // type: 'string',
6
+ // factory: 'Choice',
7
+ // choices: [
8
+ // ['health', 'Health'],
9
+ // ['agriculture', 'Agriculture'],
10
+ // ['forestry', 'Forestry'],
11
+ // ['energy', 'Energy'],
12
+ // ['tourism', 'Tourism'],
13
+ // ['water-and-coastal', 'Water and Coastal'],
14
+ // ],
15
+ // default: 'health',
16
+ // description: 'Choose indicators category to be used as filter.',
17
+ // required: true,
18
+ // noValueOption: false,
19
+ // },
2
20
 
3
21
  export default {
4
22
  title: 'C3S Indicators Overview',
@@ -7,29 +25,11 @@ export default {
7
25
  {
8
26
  id: 'default',
9
27
  title: 'Default',
10
- fields,
28
+ fields: [],
11
29
  },
12
30
  ],
13
31
 
14
- properties: {
15
- category: {
16
- title: 'Category',
17
- type: 'string',
18
- factory: 'Choice',
19
- choices: [
20
- ['health', 'Health'],
21
- ['agriculture', 'Agriculture'],
22
- ['forestry', 'Forestry'],
23
- ['energy', 'Energy'],
24
- ['tourism', 'Tourism'],
25
- ['water-and-coastal', 'Water and Coastal'],
26
- ],
27
- default: 'health',
28
- description: 'Choose indicators category to be used as filter.',
29
- required: true,
30
- noValueOption: false,
31
- },
32
- },
32
+ properties: {},
33
33
 
34
34
  required: [],
35
35
  };
@@ -13,20 +13,46 @@ import './styles.less';
13
13
  const cases_url = '@@case-studies-map.arcgis.json';
14
14
 
15
15
  export default function CaseStudyExplorerView(props) {
16
- const cases = useCases(addAppURL(cases_url));
16
+ const casesData = useCases(addAppURL(cases_url));
17
+ const [cases, setCases] = React.useState([]);
17
18
 
18
19
  const [activeFilters, setActiveFilters] = React.useState({
19
20
  sectors: [],
20
21
  impacts: [],
22
+ measures: [],
21
23
  });
22
24
 
23
25
  const [activeItems, setActiveItems] = React.useState(cases);
24
- const [filters, setFilters] = React.useState([]);
26
+ const [filters, setFilters] = React.useState({
27
+ impacts: [],
28
+ sectors: [],
29
+ measures: {},
30
+ });
31
+
32
+ React.useEffect(() => {
33
+ if (casesData.hasOwnProperty('features')) {
34
+ const _cases = casesData.features;
35
+ let _filters = filters;
36
+ setCases(_cases);
37
+ _filters.measures = casesData.filters.measures;
38
+ setFilters(_filters);
39
+ }
40
+ }, [casesData, filters]);
25
41
 
26
42
  React.useEffect(() => {
27
- const _filters = getFilters(cases);
43
+ const _filters_data = getFilters(cases);
44
+ let _filters = filters;
45
+ _filters.impacts = _filters_data.impacts;
46
+ _filters.sectors = _filters_data.sectors;
28
47
  setFilters(_filters);
29
- }, [cases, activeFilters.impacts, activeFilters.sectors, activeItems.length]);
48
+ }, [
49
+ filters,
50
+ cases,
51
+ activeFilters.impacts,
52
+ activeFilters.sectors,
53
+ activeFilters.measures,
54
+ activeItems.length,
55
+ ]);
30
56
 
31
57
  React.useEffect(() => {
32
58
  const activeItems = filterCases(cases, activeFilters);
@@ -38,7 +64,7 @@ export default function CaseStudyExplorerView(props) {
38
64
  return (
39
65
  <div>
40
66
  <Grid columns="12">
41
- <Grid.Column mobile={9} tablet={9} computer={10} className="col-left">
67
+ <Grid.Column mobile={9} tablet={9} computer={9} className="col-left">
42
68
  {cases.length ? (
43
69
  <CaseStudyMap items={cases} activeItems={activeItems} />
44
70
  ) : null}
@@ -46,7 +72,7 @@ export default function CaseStudyExplorerView(props) {
46
72
  <Grid.Column
47
73
  mobile={3}
48
74
  tablet={3}
49
- computer={2}
75
+ computer={3}
50
76
  className="col-left"
51
77
  id="cse-filter"
52
78
  >
@@ -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
- <h4>
9
- <FormattedMessage
10
- id="Adaptation sectors"
11
- defaultMessage="Adaptation sectors"
12
- />
13
- </h4>
14
- {Object.entries(filters?.sectors || {}).map(([value, label], index) => (
15
- <p key={index}>
16
- <span>{intl.formatMessage({ id: label })}</span>
17
- <input
18
- value={value}
19
- type="checkbox"
20
- onChange={(e) => {
21
- // const value =
22
- const temp = JSON.parse(JSON.stringify(activeFilters));
23
- if (e.target.checked) {
24
- temp.sectors.push(e.target.value);
25
- } else {
26
- temp.sectors = temp.sectors.filter((value) => {
27
- if (value !== e.target.value) return value;
28
- return null;
29
- });
30
- }
31
- setActiveFilters(temp);
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
- </p>
35
- ))}
36
- <h4>
37
- <FormattedMessage
38
- id="Climate impacts"
39
- defaultMessage="Climate impacts"
40
- />
41
- </h4>
42
- {Object.entries(filters?.impacts || {}).map(([value, label], index) => (
43
- <p key={index}>
44
- <span>{intl.formatMessage({ id: label })}</span>
45
- <input
46
- value={value}
47
- type="checkbox"
48
- onChange={(e) => {
49
- // const value =
50
- const temp = JSON.parse(JSON.stringify(activeFilters));
51
- if (e.target.checked) {
52
- temp.impacts.push(e.target.value);
53
- } else {
54
- temp.impacts = temp.impacts.filter((value) => {
55
- if (value !== e.target.value) return value;
56
- return null;
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
- </p>
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
  }