@eeacms/volto-cca-policy 0.1.43 → 0.1.44

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,20 @@ 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.1.44](https://github.com/eea/volto-cca-policy/compare/0.1.43...0.1.44) - 22 September 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Allow subsite behavior in folders that are not subsites [Tiberiu Ichim - [`28faeb4`](https://github.com/eea/volto-cca-policy/commit/28faeb41c43833352da3ed4002c82cc0429e4a47)]
12
+ - Support subsite logo uploaded as svg [Tiberiu Ichim - [`c1c0874`](https://github.com/eea/volto-cca-policy/commit/c1c08740c838da4f3f5fe2a8b74c4fa87364edce)]
13
+ - Refs #161483 - Fix description html - C3S Indicators Overview block. [GhitaB - [`0853fc4`](https://github.com/eea/volto-cca-policy/commit/0853fc449b64620d173582cadfe6763d73ce8551)]
14
+ - Refs #161483 - Use universal link - C3S Indicators Overview block. [GhitaB - [`054fa8d`](https://github.com/eea/volto-cca-policy/commit/054fa8d62bfd9824ceddf52cc3ebc51b456c935b)]
15
+ - Refs #161483 - Select category - C3S Indicators Overview block. [GhitaB - [`eb75b38`](https://github.com/eea/volto-cca-policy/commit/eb75b3858d6e83fbe87f123381df65f9de4b84ca)]
16
+ - Refs #161483 - Add C3S Indicators Overview block. [GhitaB - [`cf86213`](https://github.com/eea/volto-cca-policy/commit/cf862135713780355a38a1eb683abd1166041cb9)]
17
+ - Cleanup in read more block [kreafox - [`20ac717`](https://github.com/eea/volto-cca-policy/commit/20ac7171575a1966a8aabb50d5ae9e2808429423)]
18
+ - Refs #161485 - Fix error in GeocharsWidget. [GhitaB - [`6fda82d`](https://github.com/eea/volto-cca-policy/commit/6fda82ded95cba32b7519c8bcfa49358887bac6b)]
19
+ - Add read more block [kreafox - [`7fafeaa`](https://github.com/eea/volto-cca-policy/commit/7fafeaabf7bb091db76f9fc083cf61fce2bf6c06)]
20
+ - Refs #161485 - Fix field for Observatory partner. Add facet in search landing page. [GhitaB - [`c21d23e`](https://github.com/eea/volto-cca-policy/commit/c21d23e38ce07733775a3513544c2d3bb5f99edb)]
7
21
  ### [0.1.43](https://github.com/eea/volto-cca-policy/compare/0.1.42...0.1.43) - 15 September 2023
8
22
 
9
23
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
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",
@@ -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 C3SIndicatorsOverviewBlockView from './C3SIndicatorsOverviewBlockView';
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
+ <C3SIndicatorsOverviewBlockView 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,54 @@
1
+ import React from 'react';
2
+ import axios from 'axios';
3
+ import { UniversalLink } from '@plone/volto/components';
4
+
5
+ export default function C3SIndicatorsOverviewBlockView(props) {
6
+ const [pageDescription, setPageDescription] = React.useState('');
7
+ const [indicators, setIndicators] = React.useState([]);
8
+
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';
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
+ });
31
+
32
+ return (
33
+ <div className="block c3sindicators-overview-block">
34
+ <div
35
+ className="description"
36
+ dangerouslySetInnerHTML={{
37
+ __html: pageDescription,
38
+ }}
39
+ />
40
+
41
+ {indicators ? (
42
+ <ul>
43
+ {indicators.map((item, index) => (
44
+ <li key={index}>
45
+ <UniversalLink href={item.url}>{item.title}</UniversalLink>
46
+ </li>
47
+ ))}
48
+ </ul>
49
+ ) : (
50
+ <p>Loading...</p>
51
+ )}
52
+ </div>
53
+ );
54
+ }
@@ -0,0 +1,28 @@
1
+ import zoomSVG from '@plone/volto/icons/zoom.svg';
2
+ import C3SIndicatorsOverviewBlockEdit from './C3SIndicatorsOverviewBlockEdit';
3
+ import C3SIndicatorsOverviewBlockView from './C3SIndicatorsOverviewBlockView';
4
+ import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
5
+
6
+ export default function installBlock(config) {
7
+ const blocksConfig = config.blocks.blocksConfig;
8
+
9
+ blocksConfig.c3SIndicatorsOverviewBlock = {
10
+ id: 'c3SIndicatorsOverviewBlock',
11
+ title: 'C3S Indicators Overview',
12
+ icon: zoomSVG,
13
+ group: 'site',
14
+ view: C3SIndicatorsOverviewBlockView,
15
+ edit: C3SIndicatorsOverviewBlockEdit,
16
+ sidebarTab: 1,
17
+ security: {
18
+ addPermission: [],
19
+ view: [],
20
+ },
21
+ variations: [],
22
+ restricted: ({ properties, block }) => {
23
+ return blockAvailableInMission(properties, block);
24
+ },
25
+ };
26
+
27
+ return config;
28
+ }
@@ -0,0 +1,35 @@
1
+ const fields = ['category'];
2
+
3
+ export default {
4
+ title: 'C3S Indicators Overview',
5
+
6
+ fieldsets: [
7
+ {
8
+ id: 'default',
9
+ title: 'Default',
10
+ fields,
11
+ },
12
+ ],
13
+
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
+ },
33
+
34
+ required: [],
35
+ };
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { SidebarPortal } from '@plone/volto/components';
3
+ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
4
+ import ReadMoreView from './ReadMoreView';
5
+ import schema from './schema';
6
+
7
+ const ReadMoreEdit = (props) => {
8
+ const { block, data, onChangeBlock, selected, id } = props;
9
+
10
+ return (
11
+ <>
12
+ <ReadMoreView data={data} id={id} mode="edit" />
13
+
14
+ <SidebarPortal selected={selected}>
15
+ <BlockDataForm
16
+ block={block}
17
+ title={schema.title}
18
+ schema={schema}
19
+ onChangeField={(id, value) => {
20
+ onChangeBlock(block, {
21
+ ...data,
22
+ [id]: value,
23
+ });
24
+ }}
25
+ onChangeBlock={onChangeBlock}
26
+ formData={data}
27
+ />
28
+ </SidebarPortal>
29
+ </>
30
+ );
31
+ };
32
+ export default ReadMoreEdit;
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import { Button, Icon } from 'semantic-ui-react';
3
+ import { BodyClass } from '@plone/volto/helpers';
4
+ import cx from 'classnames';
5
+
6
+ import './style.less';
7
+
8
+ const ReadMoreView = (props) => {
9
+ const { data, mode } = props;
10
+ const isEditMode = mode === 'edit';
11
+ const { label_opened, label_closed, label_position, height } = data;
12
+
13
+ const [isReadMore, setIsReadMore] = React.useState(true);
14
+ const [wrapperHeight, setWrapperHeight] = React.useState(height);
15
+ const [mounted, setMounted] = React.useState(false);
16
+ const readMoreRef = React.createRef();
17
+
18
+ React.useEffect(() => {
19
+ setMounted(true);
20
+ }, []);
21
+
22
+ React.useEffect(() => {
23
+ if (isEditMode || !mounted) return;
24
+
25
+ const button = readMoreRef.current;
26
+ const wrapper = document.createElement('div');
27
+ wrapper.className = 'panel-wrapper';
28
+
29
+ const nodes = [];
30
+ let prev_elem = button.previousSibling;
31
+ while (prev_elem) {
32
+ nodes.push(prev_elem);
33
+ prev_elem = prev_elem.previousSibling;
34
+ }
35
+ const section = document.getElementsByClassName('panel-wrapper');
36
+ if (section.length > 0) return;
37
+
38
+ Array.from(nodes).forEach((e) => {
39
+ wrapper.appendChild(e);
40
+ });
41
+
42
+ button.parentNode.insertBefore(wrapper, button);
43
+ wrapper.append(...Array.from(wrapper.childNodes).reverse());
44
+ }, [mounted, readMoreRef, isEditMode]);
45
+
46
+ React.useEffect(() => {
47
+ if (isEditMode || !mounted) return;
48
+
49
+ const wrapper = document.getElementsByClassName('panel-wrapper')[0];
50
+
51
+ if (wrapper) {
52
+ wrapper.style.height = wrapperHeight;
53
+ }
54
+ }, [mounted, wrapperHeight, isEditMode]);
55
+
56
+ React.useEffect(() => {
57
+ isReadMore ? setWrapperHeight(height) : setWrapperHeight('auto');
58
+ }, [height, isReadMore]);
59
+
60
+ return (
61
+ <div
62
+ ref={readMoreRef}
63
+ id="read-more-button"
64
+ className={cx('styled-readMoreBlock', {
65
+ left: label_position === 'left',
66
+ right: label_position === 'right',
67
+ })}
68
+ >
69
+ <BodyClass className={`${isReadMore ? 'closed' : 'opened'}`} />
70
+ <Button basic icon primary onClick={() => setIsReadMore(!isReadMore)}>
71
+ {isReadMore ? (
72
+ <>
73
+ <strong>{label_closed || 'Read more'}</strong>
74
+ <Icon className="ri-arrow-down-s-line" />
75
+ </>
76
+ ) : (
77
+ <>
78
+ <strong>{label_opened || 'Read less'}</strong>
79
+ <Icon className="ri-arrow-up-s-line" />
80
+ </>
81
+ )}
82
+ </Button>
83
+ </div>
84
+ );
85
+ };
86
+ export default ReadMoreView;
@@ -0,0 +1,22 @@
1
+ import ReadMoreEdit from './ReadMoreEdit';
2
+ import ReadMoreView from './ReadMoreView';
3
+ import iconSVG from '@plone/volto/icons/divide-horizontal.svg';
4
+
5
+ export default function installBlock(config) {
6
+ config.blocks.blocksConfig.readMoreBlock = {
7
+ id: 'readMoreBlock',
8
+ title: 'Read more',
9
+ icon: iconSVG,
10
+ group: 'site',
11
+ edit: ReadMoreEdit,
12
+ view: ReadMoreView,
13
+ mostUsed: false,
14
+ sidebarTab: 1,
15
+ security: {
16
+ addPermission: [],
17
+ view: [],
18
+ },
19
+ };
20
+
21
+ return config;
22
+ }
@@ -0,0 +1,42 @@
1
+ export default {
2
+ title: 'Read more',
3
+ fieldsets: [
4
+ {
5
+ id: 'default',
6
+ title: 'Default',
7
+ fields: ['label_closed', 'label_opened', 'label_position', 'height'],
8
+ },
9
+ ],
10
+ properties: {
11
+ label_closed: {
12
+ title: 'Closed button',
13
+ default: 'Read more',
14
+ },
15
+ label_opened: {
16
+ title: 'Opened button',
17
+ default: 'Read less',
18
+ },
19
+ label_position: {
20
+ title: 'Button position',
21
+ choices: [
22
+ ['left', 'Left'],
23
+ ['right', 'Right'],
24
+ ],
25
+ default: 'right',
26
+ },
27
+ height: {
28
+ title: (
29
+ <a
30
+ rel="noreferrer"
31
+ target="_blank"
32
+ href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
33
+ >
34
+ CSS height
35
+ </a>
36
+ ),
37
+ default: '50vh',
38
+ description: 'Visible section height',
39
+ },
40
+ },
41
+ required: [],
42
+ };
@@ -0,0 +1,25 @@
1
+ .styled-readMoreBlock {
2
+ display: flex;
3
+ margin: 1.5em 0;
4
+
5
+ &.right {
6
+ flex-direction: row-reverse;
7
+ }
8
+
9
+ button {
10
+ display: flex !important;
11
+ align-items: center !important;
12
+ font-size: 18px !important;
13
+ }
14
+
15
+ i.icon {
16
+ font-size: 26px !important;
17
+ }
18
+ }
19
+
20
+ body.closed {
21
+ .panel-wrapper {
22
+ overflow: hidden;
23
+ -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent);
24
+ }
25
+ }
@@ -11,6 +11,8 @@ import installCountryMapHeatIndex from './CountryMapHeatIndex';
11
11
  import installCountryMapProfile from './CountryMapProfile';
12
12
  import installListing from './Listing';
13
13
  import installRAST from './RASTBlock';
14
+ import installC3SIndicatorsOverviewBlock from './C3SIndicatorsOverviewBlock';
15
+ import installReadMore from './ReadMore';
14
16
 
15
17
  export default function installBlocks(config) {
16
18
  config.blocks.blocksConfig.title.restricted = false;
@@ -18,6 +20,8 @@ export default function installBlocks(config) {
18
20
 
19
21
  return compose(
20
22
  installRAST,
23
+ installReadMore,
24
+ installC3SIndicatorsOverviewBlock,
21
25
  installMKHMap,
22
26
  installECDEIndicatorsBlock,
23
27
  installCaseStudyExplorerBlock,
@@ -20,6 +20,7 @@ import { usePrevious } from '@eeacms/volto-eea-design-system/helpers';
20
20
  import { find } from 'lodash';
21
21
  import globeIcon from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/global-line.svg';
22
22
  import eeaFlag from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/eea.png';
23
+ import { toPublicURL } from '@plone/volto/helpers';
23
24
 
24
25
  import config from '@plone/volto/registry';
25
26
  import { compose } from 'recompose';
@@ -72,7 +73,7 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
72
73
  return removeTrailingSlash(state.router?.location?.pathname) || '';
73
74
  });
74
75
 
75
- const isSubsite = subsite?.['@type'] === 'Subsite';
76
+ const isSubsite = ['Folder', 'Subsite'].indexOf(subsite?.['@type']) > -1;
76
77
 
77
78
  const isHomePageInverse = useSelector((state) => {
78
79
  const layout = state.content?.data?.layout;
@@ -115,6 +116,11 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
115
116
  }
116
117
  }, [token, dispatch, pathname, previousToken]);
117
118
 
119
+ const subsiteLogo = subsite?.subsite_logo
120
+ ? subsite.subsite_logo.scales?.preview?.download ||
121
+ toPublicURL(`${subsite['@id']}/@@images/subsite_logo`)
122
+ : null;
123
+
118
124
  return (
119
125
  <Header menuItems={items}>
120
126
  {isHomePageInverse && <BodyClass className="homepage" />}
@@ -238,7 +244,7 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
238
244
  <>
239
245
  {subsite.subsite_logo ? (
240
246
  <Logo
241
- src={subsite.subsite_logo?.scales.preview.download}
247
+ src={subsiteLogo}
242
248
  title={subsite.title}
243
249
  alt={subsite.title}
244
250
  url={flattenToAppURL(subsite['@id'])}
@@ -110,7 +110,7 @@ const SelectCountries = (props) => {
110
110
  key={country.code}
111
111
  value={country.code}
112
112
  label={country.name}
113
- checked={countries.includes(country.code)}
113
+ checked={countries?.includes(country.code) || false}
114
114
  onChange={handleSelect}
115
115
  />
116
116
  ))}
@@ -69,7 +69,6 @@ const DefaultView = (props) => {
69
69
  let currentNavigation = config.settings.contextNavigationLocations.find(
70
70
  (element) => location.pathname.indexOf(element.rootPath) > -1,
71
71
  );
72
- // console.log('CurrentNavigation', currentNavigation);
73
72
 
74
73
  const gridColumns =
75
74
  currentNavigation && currentNavigation?.columns
@@ -106,6 +106,12 @@ export default function installMainSearch(config) {
106
106
  'Heat',
107
107
  ],
108
108
  },
109
+ {
110
+ id: 'observatoryPartner',
111
+ title: 'Observatory partner',
112
+ facetField: 'cca_partner_contributors.keyword',
113
+ sortOn: 'alpha',
114
+ },
109
115
  ];
110
116
 
111
117
  if (typeof window !== 'undefined') {
@@ -173,7 +173,7 @@ const facets = [
173
173
  sortOnCustomLabel: 'Alphabetical',
174
174
  },
175
175
  {
176
- field: 'cca_origin_websites.keyword',
176
+ field: 'cca_partner_contributors.keyword',
177
177
  factory: 'MultiTermFacet',
178
178
  label: 'Observatory partner',
179
179
  showInFacetsList: true,