@eeacms/volto-cca-policy 0.2.42 → 0.2.43

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 CHANGED
@@ -4,6 +4,37 @@ 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.43](https://github.com/eea/volto-cca-policy/compare/0.2.42...0.2.43) - 13 June 2024
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat(event): add i18n messages for documents and improve code readability [kreafox - [`f23168a`](https://github.com/eea/volto-cca-policy/commit/f23168ad982317bdf1523cdd42f39ef84b55da0e)]
12
+
13
+ #### :rocket: Dependency updates
14
+
15
+ - Release @eeacms/volto-embed@10.0.2 [EEA Jenkins - [`2e0174c`](https://github.com/eea/volto-cca-policy/commit/2e0174c154250e838535e3f9c8b1c8f83fa8ccde)]
16
+
17
+ #### :bug: Bug Fixes
18
+
19
+ - fix(event): use email link interpolation correctly [kreafox - [`0527737`](https://github.com/eea/volto-cca-policy/commit/0527737a47ae1e70a5719b160736be9247d68634)]
20
+
21
+ #### :nail_care: Enhancements
22
+
23
+ - change(event): simplify component structure and organize imports [kreafox - [`30a7766`](https://github.com/eea/volto-cca-policy/commit/30a7766d33a04d26d17b798d0ef776603c7fe29c)]
24
+ - change(event): use renderBlocks instead of custom BannerTitle component [kreafox - [`0dd267a`](https://github.com/eea/volto-cca-policy/commit/0dd267af20184dbd683671ef1e23dd3d15606667)]
25
+
26
+ #### :hammer_and_wrench: Others
27
+
28
+ - test: fix warning message [kreafox - [`4d31ff2`](https://github.com/eea/volto-cca-policy/commit/4d31ff20dcfce88ad96f608409a5e12b20f13c9e)]
29
+ - test: update snapshot [kreafox - [`c8047ca`](https://github.com/eea/volto-cca-policy/commit/c8047ca5d592fea5db728999f1f7a8f96cad6496)]
30
+ - New version [Tiberiu Ichim - [`8617e34`](https://github.com/eea/volto-cca-policy/commit/8617e343ec075259078b533064bb6de2a3005a48)]
31
+ - https://github.com/elastic/search-ui/issues/1046 [Tiberiu Ichim - [`9eb0d03`](https://github.com/eea/volto-cca-policy/commit/9eb0d03aace62b7692033d9e429c42f10e176354)]
32
+ - Pin @eeacms/volto-embed [kreafox - [`0418854`](https://github.com/eea/volto-cca-policy/commit/04188549444a127e041ef98973900814f86e3859)]
33
+ - Let's try something else [Tiberiu Ichim - [`ab847b7`](https://github.com/eea/volto-cca-policy/commit/ab847b7d35448dadf29892bc10f8024dabf6d664)]
34
+ - Remove dependency for search-ui [Tiberiu Ichim - [`f3bf4a4`](https://github.com/eea/volto-cca-policy/commit/f3bf4a42f1dac44c57b6c1557b583112e328d26d)]
35
+ - Refs #271086 - wip tests [Tripon Eugen - [`e2cfdc7`](https://github.com/eea/volto-cca-policy/commit/e2cfdc78dc82b70d147bc1a7505632b9577719b8)]
36
+ - Refs #271086 - package.json resolutions [Tripon Eugen - [`09cce63`](https://github.com/eea/volto-cca-policy/commit/09cce6376cc489d5466981ce1a8e53bb8a994c1e)]
37
+ - Refs #271086 - add elements filter at cse [Tripon Eugen - [`549030c`](https://github.com/eea/volto-cca-policy/commit/549030cde005331f26a9ccde09394fee3f43f049)]
7
38
  ### [0.2.42](https://github.com/eea/volto-cca-policy/compare/0.2.41...0.2.42) - 4 June 2024
8
39
 
9
40
  ### [0.2.41](https://github.com/eea/volto-cca-policy/compare/0.2.40...0.2.41) - 4 June 2024
@@ -1362,13 +1393,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1362
1393
  - Refs #260715 rast-block wip [Tripon Eugen - [`f19d54e`](https://github.com/eea/volto-cca-policy/commit/f19d54e0b9a6a86bf344eb85b6a1cda7f3de91bf)]
1363
1394
  - Refs #260715 rast-block wip [Tripon Eugen - [`2828537`](https://github.com/eea/volto-cca-policy/commit/2828537b6c084cd1a82162d552fb4ef025b71f9f)]
1364
1395
  - Refs #260715 rast-block updates [Tripon Eugen - [`1e803e5`](https://github.com/eea/volto-cca-policy/commit/1e803e5bd3d3fb7558f261c76c68866be7beb8b5)]
1365
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`0a15e1b`](https://github.com/eea/volto-cca-policy/commit/0a15e1b2ad081233685e80d5b3c60a8663f6b896)]
1366
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`9554e44`](https://github.com/eea/volto-cca-policy/commit/9554e44c92a621a52b2adb5a4830fb084ee5734b)]
1367
1396
  ### [0.1.49](https://github.com/eea/volto-cca-policy/compare/0.1.48...0.1.49) - 15 November 2023
1368
1397
 
1369
1398
  #### :house: Internal changes
1370
1399
 
1371
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`7b820a6`](https://github.com/eea/volto-cca-policy/commit/7b820a6369c2ddd5203b1a4abe352cb4bb43db7a)]
1372
1400
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`f0a8061`](https://github.com/eea/volto-cca-policy/commit/f0a8061c275c236deb00087c23fac9860a073106)]
1373
1401
 
1374
1402
  #### :hammer_and_wrench: Others
@@ -1385,9 +1413,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1385
1413
  - Refs #259267 - jenkins test [Tripon Eugen - [`cacd31e`](https://github.com/eea/volto-cca-policy/commit/cacd31e7b1afe0983674ed5c7632d2e1d7fa752e)]
1386
1414
  - Refs #259267 - jenkins [Tripon Eugen - [`5b3affe`](https://github.com/eea/volto-cca-policy/commit/5b3affee8401239de10097884c1b7f2349d15ec0)]
1387
1415
  - Refs #259267 - add When, lead image and title to files [Tripon Eugen - [`2cedb23`](https://github.com/eea/volto-cca-policy/commit/2cedb237f898af9057e13fba94b615ef71077204)]
1388
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`4d607a5`](https://github.com/eea/volto-cca-policy/commit/4d607a576e9d0a5c34e48c41b409e7df616ee3d6)]
1389
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`b7f74d5`](https://github.com/eea/volto-cca-policy/commit/b7f74d53513a6edbfbca5cb6d19687929bb1e5db)]
1390
- - test: [JENKINS] Improve cypress time [valentinab25 - [`db65617`](https://github.com/eea/volto-cca-policy/commit/db656173391f65157098d95d388c25f6429753d8)]
1391
1416
  - Refs #259267 - cca event blocks attachments and check not mandatoty fields [Tripon Eugen - [`3138e5a`](https://github.com/eea/volto-cca-policy/commit/3138e5afb5bfbdbed14e27ed457b16867b7fa414)]
1392
1417
  - Refs #256681 - Fix error in CCA Event view menu. ([React Intl] An id must be provided to format a message.) [GhitaB - [`517eeb8`](https://github.com/eea/volto-cca-policy/commit/517eeb817264a47bbfd6b9b7d22aaf22d44ed224)]
1393
1418
  - Refs #161485 - Fix ECDE name conflict. [GhitaB - [`8bfd99f`](https://github.com/eea/volto-cca-policy/commit/8bfd99ff68bb82a04d1c0ed625fa514fcf46289e)]
@@ -1604,7 +1629,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1604
1629
 
1605
1630
  #### :house: Internal changes
1606
1631
 
1607
- - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`ad1ced0`](https://github.com/eea/volto-cca-policy/commit/ad1ced0971ba116c13a3b5fcc039172cc915c919)]
1608
1632
 
1609
1633
  #### :hammer_and_wrench: Others
1610
1634
 
@@ -2085,7 +2109,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
2085
2109
  #### :hammer_and_wrench: Others
2086
2110
 
2087
2111
  - Refs #158294 - Update supported languages list. [GhitaB - [`0a4f91f`](https://github.com/eea/volto-cca-policy/commit/0a4f91f39b7edc367bd4c127d6a8f273c7788361)]
2088
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`8f1f9ce`](https://github.com/eea/volto-cca-policy/commit/8f1f9ce6c22805670cc0800d3c779b6d619d0f31)]
2089
2112
  ### [0.1.1](https://github.com/eea/volto-cca-policy/compare/0.1.0...0.1.1) - 13 December 2022
2090
2113
 
2091
2114
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.2.42",
3
+ "version": "0.2.43",
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",
@@ -31,13 +31,13 @@
31
31
  "@eeacms/volto-datablocks": "*",
32
32
  "@eeacms/volto-eea-design-system": "*",
33
33
  "@eeacms/volto-eea-website-theme": "^1.33.2",
34
- "@eeacms/volto-embed": "10.0.1",
34
+ "@eeacms/volto-embed": "^9.1.1",
35
35
  "@eeacms/volto-globalsearch": "^1.1.0",
36
36
  "@eeacms/volto-openlayers-map": "*",
37
- "@eeacms/volto-searchlib": "^0.9.3",
37
+ "@eeacms/volto-searchlib": "2.0.2",
38
+ "@elastic/search-ui": "1.21.2",
38
39
  "@eeacms/volto-slate-label": "^0.6.0",
39
40
  "@eeacms/volto-tabs-block": "^7.5.1",
40
- "@elastic/search-ui": "1.21.2",
41
41
  "d3-array": "^2.12.1",
42
42
  "jotai": "^1.6.0",
43
43
  "query-string": "7.1.0",
@@ -19,12 +19,14 @@ export default function CaseStudyExplorerView(props) {
19
19
  const [activeFilters, setActiveFilters] = React.useState({
20
20
  sectors: [],
21
21
  impacts: [],
22
+ elements: [],
22
23
  measures: [],
23
24
  });
24
25
 
25
26
  const [activeItems, setActiveItems] = React.useState(cases);
26
27
  const [filters, setFilters] = React.useState({
27
28
  impacts: [],
29
+ elements: [],
28
30
  sectors: [],
29
31
  measures: {},
30
32
  });
@@ -44,12 +46,14 @@ export default function CaseStudyExplorerView(props) {
44
46
  let _filters = filters;
45
47
  _filters.impacts = _filters_data.impacts;
46
48
  _filters.sectors = _filters_data.sectors;
49
+ _filters.elements = _filters_data.elements;
47
50
  setFilters(_filters);
48
51
  }, [
49
52
  filters,
50
53
  cases,
51
54
  activeFilters.impacts,
52
55
  activeFilters.sectors,
56
+ activeFilters.elements,
53
57
  activeFilters.measures,
54
58
  activeItems.length,
55
59
  ]);
@@ -84,6 +84,31 @@ export default function CaseStudyFilters(props) {
84
84
  ),
85
85
  )}
86
86
  </Accordion.Content>
87
+ <Accordion.Title
88
+ active={activeIndex.includes(3)}
89
+ index={3}
90
+ onClick={handleClick}
91
+ >
92
+ <AccordionIcon active={activeIndex.includes(3)} />
93
+ <FormattedMessage
94
+ id="Adaptation elements"
95
+ defaultMessage="Adaptation elements"
96
+ />
97
+ </Accordion.Title>
98
+ <Accordion.Content active={activeIndex.includes(3)}>
99
+ {Object.entries(filters?.elements || {}).map(
100
+ ([value, label], index) => (
101
+ <Checkbox
102
+ label={intl.formatMessage({ id: label })}
103
+ value={value}
104
+ checked={activeFilters.elements.includes(value)}
105
+ name="elements"
106
+ onChange={checkboxChangeHandler}
107
+ key={'element' + index}
108
+ />
109
+ ),
110
+ )}
111
+ </Accordion.Content>
87
112
  <Accordion.Title
88
113
  active={activeIndex.includes(1)}
89
114
  index={1}
@@ -16,6 +16,7 @@ describe('CaseStudyFilters', () => {
16
16
  // impacts: [{ DROUGHT: 'Drought' }],
17
17
  sectors: [],
18
18
  impacts: [],
19
+ elements: [],
19
20
  measures: {
20
21
  // Measure1: [
21
22
  // { key: 'M11', value: 'm11' },
@@ -26,6 +27,7 @@ describe('CaseStudyFilters', () => {
26
27
  activeFilters: {
27
28
  sectors: [],
28
29
  impacts: [],
30
+ elements: [],
29
31
  measures: [],
30
32
  },
31
33
  };
@@ -43,7 +43,6 @@ export default function FeatureDisplay({ feature }) {
43
43
  <span
44
44
  dangerouslySetInnerHTML={{
45
45
  __html: feature.adaptation_options_links.replaceAll('<>', '; '),
46
- // __html: feature.adaptation_options_links,
47
46
  }}
48
47
  ></span>
49
48
  </p>
@@ -35,6 +35,7 @@ export function filterCases(cases, activeFilters) {
35
35
  if (
36
36
  activeFilters.sectors.length === 0 &&
37
37
  activeFilters.measures.length === 0 &&
38
+ activeFilters.elements.length === 0 &&
38
39
  activeFilters.impacts.length === 0
39
40
  )
40
41
  return _case;
@@ -45,6 +46,10 @@ export function filterCases(cases, activeFilters) {
45
46
  if (_case.properties.sectors.includes(',' + filter + ',')) flag = true;
46
47
  });
47
48
 
49
+ activeFilters.elements.forEach((filter) => {
50
+ if (_case.properties.elements.includes(',' + filter + ',')) flag = true;
51
+ });
52
+
48
53
  activeFilters.impacts.forEach((filter) => {
49
54
  if (_case.properties.impacts.includes(',' + filter + ',')) flag = true;
50
55
  });
@@ -60,7 +65,7 @@ export function filterCases(cases, activeFilters) {
60
65
  }
61
66
 
62
67
  export function getFilters(cases) {
63
- let _filters = { sectors: {}, impacts: {}, measures: {} };
68
+ let _filters = { sectors: {}, impacts: {}, elements: {}, measures: {} };
64
69
 
65
70
  for (let key of Object.keys(cases)) {
66
71
  const _case = cases[key];
@@ -81,6 +86,17 @@ export function getFilters(cases) {
81
86
  }
82
87
  }
83
88
 
89
+ let elementKeys = _case.properties?.elements?.split(',');
90
+ let elementNames = _case.properties?.elements_str?.split(',') || [];
91
+ for (let i = 0; i < elementNames.length; i++) {
92
+ if (
93
+ !_filters.elements.hasOwnProperty(elementKeys[i + 1]) &&
94
+ elementKeys[i + 1].length
95
+ ) {
96
+ _filters.elements[elementKeys[i + 1]] = elementNames[i];
97
+ }
98
+ }
99
+
84
100
  // let ktmKeys = _case.properties.ktms.split(',');
85
101
  // let ktmNames = _case.properties.impacts_str.split(',');
86
102
  // for (let i = 0; i < ktmKeys.length; i++) {
@@ -12,17 +12,18 @@ const messages = defineMessages({
12
12
  });
13
13
 
14
14
  const getDropdownOptions = (items) => {
15
- const options = items?.map((item) => {
16
- const source = item?.source?.[0];
17
- return {
18
- key: source?.id,
19
- value: source?.id,
20
- text: item.item_title,
21
- as: Link,
22
- to: flattenToAppURL(source?.['@id']),
23
- };
24
- });
25
- return options;
15
+ return (
16
+ items?.map((item, index) => {
17
+ const source = item?.source?.[0];
18
+ return {
19
+ key: source?.id || index,
20
+ value: source?.id,
21
+ text: item.item_title,
22
+ as: Link,
23
+ to: flattenToAppURL(source?.['@id']),
24
+ };
25
+ }) || []
26
+ );
26
27
  };
27
28
 
28
29
  const DropdownListView = (props) => {
@@ -1,58 +1,73 @@
1
1
  import React from 'react';
2
+ import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
2
3
  import { Grid, Container, Segment } from 'semantic-ui-react';
3
4
  import {
4
- DocumentsList,
5
5
  HTMLField,
6
- BannerTitle,
7
6
  EventDetails,
7
+ DocumentsList,
8
8
  } from '@eeacms/volto-cca-policy/helpers';
9
9
  import { PortalMessage } from '@eeacms/volto-cca-policy/components';
10
- import { FormattedMessage } from 'react-intl';
10
+ import { filterBlocks } from '@eeacms/volto-cca-policy/utils';
11
+ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
12
+
13
+ const messages = defineMessages({
14
+ download_agenda: {
15
+ id: 'Download the detailed agenda',
16
+ defaultMessage: 'Download the detailed agenda',
17
+ },
18
+ download_documents: {
19
+ id: 'A background document for the event is available',
20
+ defaultMessage: 'A background document for the event is available',
21
+ },
22
+ });
23
+
24
+ const DocumentSection = ({ title, file }) => (
25
+ <DocumentsList
26
+ content={{
27
+ show_counter: false,
28
+ section_title: title,
29
+ cca_files: [
30
+ {
31
+ url: file?.download,
32
+ title: file?.filename,
33
+ },
34
+ ],
35
+ }}
36
+ />
37
+ );
11
38
 
12
39
  function CcaEventView(props) {
40
+ const intl = useIntl();
13
41
  const { content } = props;
14
- const { event_language } = content;
15
- // cca_files: [content.agenda_file]}
16
- if (content.agenda_file) {
17
- content.agenda_file['url'] = content.agenda_file['download'];
18
- content.agenda_file['title'] = content.agenda_file['filename'];
19
- }
20
- if (content.background_documents) {
21
- content.background_documents['url'] =
22
- content.background_documents['download'];
23
- content.background_documents['title'] =
24
- content.background_documents['filename'];
25
- }
26
- const agenda_files = {
27
- section_title: 'Download the detailed agenda',
28
- cca_files: [content.agenda_file],
29
- show_counter: false,
30
- };
31
- const background_documents = {
32
- section_title: 'A background document for the event is available ',
33
- cca_files: [content.background_documents],
34
- show_counter: false,
35
- };
42
+ const {
43
+ event_language,
44
+ agenda_file,
45
+ background_documents,
46
+ participation,
47
+ contact_email,
48
+ } = content;
49
+
50
+ const {
51
+ blocks: filtered_blocks,
52
+ blocks_layout: filtered_blocks_layout,
53
+ } = filterBlocks(content, 'tabs_block');
36
54
 
37
55
  return (
38
56
  <div className="cca-event-view">
39
- <BannerTitle
40
- content={{ ...content, '@type': 'Climate adapt event' }}
41
- data={{
42
- info: [{ description: '' }],
43
- hideContentType: false,
44
- hideCreationDate: false,
45
- hideModificationDate: false,
46
- hidePublishingDate: false,
47
- hideDownloadButton: false,
48
- hideShareButton: false,
57
+ <RenderBlocks
58
+ {...props}
59
+ content={{
60
+ ...content,
61
+ '@type': 'climate-adapt-event',
62
+ blocks: filtered_blocks,
63
+ blocks_layout: filtered_blocks_layout,
49
64
  }}
50
65
  />
51
66
 
52
67
  <Container>
53
68
  <PortalMessage content={content} />
54
69
  <Grid columns="12">
55
- <div className="row">
70
+ <Grid.Row>
56
71
  <Grid.Column
57
72
  mobile={12}
58
73
  tablet={12}
@@ -69,9 +84,18 @@ function CcaEventView(props) {
69
84
  </h2>
70
85
  <HTMLField value={content.agenda} />
71
86
 
72
- {content?.agenda_file && <DocumentsList content={agenda_files} />}
73
- {content?.background_documents && (
74
- <DocumentsList content={background_documents} />
87
+ {agenda_file && (
88
+ <DocumentSection
89
+ title={intl.formatMessage(messages.download_agenda)}
90
+ file={agenda_file}
91
+ />
92
+ )}
93
+
94
+ {background_documents && (
95
+ <DocumentSection
96
+ title={intl.formatMessage(messages.download_documents)}
97
+ file={background_documents}
98
+ />
75
99
  )}
76
100
 
77
101
  <h2>
@@ -86,20 +110,21 @@ function CcaEventView(props) {
86
110
  defaultMessage="Participation"
87
111
  />
88
112
  </h3>
89
- <HTMLField value={content.participation} />
113
+ <HTMLField value={participation} />
90
114
 
91
115
  <h2>
92
116
  <FormattedMessage id="Contact" defaultMessage="Contact" />
93
117
  </h2>
94
- <p>
95
- <FormattedMessage
96
- id="If you have any further questions you can contact"
97
- defaultMessage="If you have any further questions you can contact"
98
- />{' '}
99
- <a href="mailto:{content.contact_email}">
100
- {content.contact_email}
101
- </a>
102
- </p>
118
+
119
+ {contact_email && (
120
+ <p>
121
+ <FormattedMessage
122
+ id="If you have any further questions you can contact"
123
+ defaultMessage="If you have any further questions you can contact"
124
+ />{' '}
125
+ <a href={`mailto:${contact_email}`}>{contact_email}</a>
126
+ </p>
127
+ )}
103
128
 
104
129
  {event_language && (
105
130
  <>
@@ -123,7 +148,7 @@ function CcaEventView(props) {
123
148
  <EventDetails {...props} />
124
149
  </Segment>
125
150
  </Grid.Column>
126
- </div>
151
+ </Grid.Row>
127
152
  </Grid>
128
153
  </Container>
129
154
  </div>