@eeacms/volto-cca-policy 0.2.83 → 0.2.85

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.2.85](https://github.com/eea/volto-cca-policy/compare/0.2.84...0.2.85) - 18 December 2024
8
+
9
+ #### :nail_care: Enhancements
10
+
11
+ - change(view): update Events view - refs #281788 [kreafox - [`f1b8278`](https://github.com/eea/volto-cca-policy/commit/f1b8278b265d50b99f59cbeab9ad9298b0d06d44)]
12
+ - change(view): update News Item view - refs #281788 [kreafox - [`16e1ad7`](https://github.com/eea/volto-cca-policy/commit/16e1ad7763ecea115b611d1538d033b8241fc525)]
13
+
14
+ ### [0.2.84](https://github.com/eea/volto-cca-policy/compare/0.2.83...0.2.84) - 17 December 2024
15
+
16
+ #### :hammer_and_wrench: Others
17
+
18
+ - Fix eslint [Tiberiu Ichim - [`d2ab8e1`](https://github.com/eea/volto-cca-policy/commit/d2ab8e15c70bf790a40105e9ea994d907b8cfbd5)]
19
+ - Remove console.log [Tiberiu Ichim - [`5a78a19`](https://github.com/eea/volto-cca-policy/commit/5a78a1938470e4d4997cbaf9bee2d08e6a40cf49)]
20
+ - Rework language facets for Mission [Tiberiu Ichim - [`85a611a`](https://github.com/eea/volto-cca-policy/commit/85a611ae595f682b1348936d18750ed4bd209137)]
7
21
  ### [0.2.83](https://github.com/eea/volto-cca-policy/compare/0.2.82...0.2.83) - 16 December 2024
8
22
 
9
23
  #### :rocket: Dependency updates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.2.83",
3
+ "version": "0.2.85",
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",
@@ -11,8 +11,8 @@ const BannerTitle = (props) => {
11
11
  } = config;
12
12
  const contentTypes = ['Subsite', 'LRF', 'Plone Site'];
13
13
  const TitleBlockView = blocksConfig?.title?.view;
14
- const hasTitleBlock = hasTypeOfBlock(blocks, '@type', 'title');
15
- const hasCountryFlagBlock = hasTypeOfBlock(blocks, '@type', 'countryFlag');
14
+ const hasTitleBlock = hasTypeOfBlock(blocks, 'title');
15
+ const hasCountryFlagBlock = hasTypeOfBlock(blocks, 'countryFlag');
16
16
  const [hasBodyClass, setHasBodyClass] = React.useState(false);
17
17
  const isHomePage = contentTypes.indexOf(type) > -1 || hasBodyClass;
18
18
 
@@ -48,10 +48,11 @@ function CcaEventView(props) {
48
48
  } = content;
49
49
 
50
50
  const {
51
- blocks: filtered_blocks,
52
- blocks_layout: filtered_blocks_layout,
53
- } = filterBlocks(content, 'tabs_block');
54
- const titleBlock = Object.values(filtered_blocks).find(
51
+ blocks: filteredBlocks,
52
+ blocks_layout: filteredBlocksLayout,
53
+ } = filterBlocks(content, ['tabs_block', 'metadataSection']);
54
+
55
+ const titleBlock = Object.values(filteredBlocks).find(
55
56
  (block) => block['@type'] === 'title',
56
57
  );
57
58
  if (titleBlock && !titleBlock.subtitle && content.subtitle) {
@@ -60,16 +61,6 @@ function CcaEventView(props) {
60
61
 
61
62
  return (
62
63
  <div className="cca-event-view">
63
- <RenderBlocks
64
- {...props}
65
- content={{
66
- ...content,
67
- '@type': 'climate-adapt-event',
68
- blocks: filtered_blocks,
69
- blocks_layout: filtered_blocks_layout,
70
- }}
71
- />
72
-
73
64
  <Container>
74
65
  <PortalMessage content={content} />
75
66
  <Grid columns="12">
@@ -143,6 +134,16 @@ function CcaEventView(props) {
143
134
  <p>{event_language.title}</p>
144
135
  </>
145
136
  )}
137
+
138
+ <RenderBlocks
139
+ {...props}
140
+ content={{
141
+ ...content,
142
+ '@type': 'climate-adapt-event',
143
+ blocks: filteredBlocks,
144
+ blocks_layout: filteredBlocksLayout,
145
+ }}
146
+ />
146
147
  </Grid.Column>
147
148
  <Grid.Column
148
149
  mobile={12}
@@ -11,11 +11,13 @@ import { PortalMessage } from '@eeacms/volto-cca-policy/components';
11
11
 
12
12
  function EventView(props) {
13
13
  const { content } = props;
14
+ // These blocks are used in the Edit View for dexterity layout.
15
+ // We don't want to display them in the View mode.
14
16
  const {
15
- blocks: filtered_blocks,
16
- blocks_layout: filtered_blocks_layout,
17
- hasBlockType,
18
- } = filterBlocks(content, 'tabs_block');
17
+ blocks: filteredBlocks,
18
+ blocks_layout: filteredBlocksLayout,
19
+ hasBlockTypes,
20
+ } = filterBlocks(content, ['tabs_block', 'metadataSection']);
19
21
 
20
22
  return (
21
23
  <div className="cca-event-view">
@@ -25,7 +27,7 @@ function EventView(props) {
25
27
  <Grid columns="12">
26
28
  <Grid.Row>
27
29
  <Grid.Column mobile={12} tablet={12} computer={8}>
28
- {hasBlockType && (
30
+ {hasBlockTypes && (
29
31
  <>
30
32
  <p className="documentDescription">{content.description}</p>
31
33
  <HTMLField value={content.text} className="content-text" />
@@ -36,8 +38,8 @@ function EventView(props) {
36
38
  {...props}
37
39
  content={{
38
40
  ...content,
39
- blocks: filtered_blocks,
40
- blocks_layout: filtered_blocks_layout,
41
+ blocks: filteredBlocks,
42
+ blocks_layout: filteredBlocksLayout,
41
43
  }}
42
44
  />
43
45
 
@@ -4,48 +4,56 @@ import { filterBlocks } from '@eeacms/volto-cca-policy/utils';
4
4
  import { PortalMessage } from '@eeacms/volto-cca-policy/components';
5
5
  import { HTMLField, SubjectTags } from '@eeacms/volto-cca-policy/helpers';
6
6
  import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
7
- import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
8
7
 
9
- const PublicationDate = (props) => {
10
- const date = props.content?.effective;
11
- return date ? (
12
- <div className="news-date-info">
13
- Date:
14
- <When start={date} end={date} whole_day={true} open_end={false} />
15
- </div>
16
- ) : null;
8
+ const DescriptionText = ({ content }) => {
9
+ return (
10
+ <>
11
+ <p className="documentDescription">{content.description}</p>
12
+ <HTMLField value={content.text} className="content-text" />
13
+ </>
14
+ );
17
15
  };
18
16
 
19
17
  function NewsItemView(props) {
20
18
  const { content } = props;
19
+
20
+ // if (content.image_caption) {
21
+ // Object.values(content.blocks).forEach((block) => {
22
+ // if (block['@type'] === 'title' && !block.copyright?.trim()) {
23
+ // block.copyright = content.image_caption;
24
+ // }
25
+ // });
26
+ // }
27
+
28
+ // These blocks are used in the Edit View for dexterity layout.
29
+ // We don't want to display them in the View mode.
21
30
  const {
22
- blocks: filtered_blocks,
23
- blocks_layout: filtered_blocks_layout,
24
- hasBlockType,
25
- } = filterBlocks(content, 'tabs_block');
31
+ blocks: filteredBlocks,
32
+ blocks_layout: filteredBlocksLayout,
33
+ hasBlockTypes,
34
+ } = filterBlocks(content, ['tabs_block', 'metadataSection']);
26
35
 
27
36
  return (
28
37
  <div className="cca-newsitem-view">
29
- <PortalMessage content={content} />
30
-
31
38
  <Container>
32
- {hasBlockType && (
39
+ <PortalMessage content={content} />
40
+ {hasBlockTypes ? (
41
+ <>
42
+ <DescriptionText content={content} />
43
+ <RenderBlocks
44
+ {...props}
45
+ content={{
46
+ ...content,
47
+ blocks: filteredBlocks,
48
+ blocks_layout: filteredBlocksLayout,
49
+ }}
50
+ />
51
+ </>
52
+ ) : (
33
53
  <>
34
- <p className="documentDescription">{content.description}</p>
35
- <HTMLField value={content.text} className="content-text" />
54
+ <RenderBlocks {...props} content={content} />
36
55
  </>
37
56
  )}
38
-
39
- <RenderBlocks
40
- {...props}
41
- content={{
42
- ...content,
43
- blocks: filtered_blocks,
44
- blocks_layout: filtered_blocks_layout,
45
- }}
46
- />
47
-
48
- <PublicationDate {...props} />
49
57
  <SubjectTags {...props} />
50
58
  </Container>
51
59
  </div>
@@ -102,5 +102,7 @@ export default function installMainSearch(config) {
102
102
  process.env.RAZZLE_ES_PROXY_ADDR || getClientProxyAddress();
103
103
  }
104
104
 
105
+ // console.log(config);
106
+
105
107
  return config;
106
108
  }
@@ -2,13 +2,13 @@ import globalSearchBaseConfig from '@eeacms/volto-globalsearch/config/global-sea
2
2
  import { multiTermFacet } from '@eeacms/search';
3
3
  import {
4
4
  // objectProvides,
5
- // language,
5
+ language,
6
6
  geographic_countries,
7
7
  cca_climate_impacts,
8
8
  cca_adaptation_sectors,
9
9
  } from '../common';
10
10
 
11
- const blacklist = ['IncludeArchived', 'issued.date'];
11
+ const blacklist = ['IncludeArchived', 'issued.date', 'language'];
12
12
  let globalFacets = globalSearchBaseConfig.facets.filter(
13
13
  (f) => !blacklist.includes(f.field),
14
14
  );
@@ -23,6 +23,7 @@ globalFacets = globalFacets.concat(
23
23
  cca_climate_impacts,
24
24
  cca_adaptation_sectors,
25
25
  geographic_countries,
26
+ language,
26
27
  multiTermFacet({
27
28
  field: 'cca_adaptation_elements.keyword',
28
29
  isFilterable: false,
@@ -1,7 +1,7 @@
1
1
  import { multiTermFacet } from '@eeacms/search';
2
2
  import globalSearchBaseConfig from '@eeacms/volto-globalsearch/config/global-search-base-config.js';
3
3
  // import spatialWhitelist from '@eeacms/volto-globalsearch/config/json/spatialWhitelist';
4
- import { cca_adaptation_sectors } from './../common';
4
+ import { cca_adaptation_sectors, language } from './../common';
5
5
 
6
6
  const blacklist = ['IncludeArchived', 'issued.date', 'spatial', 'language'];
7
7
 
@@ -21,6 +21,7 @@ const facets = [
21
21
  alwaysVisible: false,
22
22
  }),
23
23
  cca_adaptation_sectors,
24
+ language,
24
25
  // multiTermFacet({
25
26
  // field: 'spatial',
26
27
  // isFilterable: true,
@@ -1,7 +1,11 @@
1
1
  import { multiTermFacet } from '@eeacms/search';
2
2
 
3
3
  import globalSearchBaseConfig from '@eeacms/volto-globalsearch/config/global-search-base-config.js';
4
- import { cca_climate_impacts, cca_adaptation_sectors } from './../common';
4
+ import {
5
+ cca_climate_impacts,
6
+ cca_adaptation_sectors,
7
+ language,
8
+ } from './../common';
5
9
 
6
10
  const facets = [
7
11
  cca_climate_impacts,
@@ -31,6 +35,7 @@ const facets = [
31
35
  iconsFamily: 'Hazard Type',
32
36
  alwaysVisible: false,
33
37
  }),
38
+ language,
34
39
  ];
35
40
 
36
41
  export default facets;
@@ -1,7 +1,11 @@
1
1
  import { multiTermFacet } from '@eeacms/search';
2
2
 
3
- import globalSearchBaseConfig from '@eeacms/volto-globalsearch/config/global-search-base-config.js';
4
- import { cca_climate_impacts, cca_adaptation_sectors } from './../common';
3
+ // import globalSearchBaseConfig from '@eeacms/volto-globalsearch/config/global-search-base-config.js';
4
+ import {
5
+ cca_climate_impacts,
6
+ cca_adaptation_sectors,
7
+ language,
8
+ } from './../common';
5
9
 
6
10
  const facets = [
7
11
  multiTermFacet({
@@ -41,7 +45,8 @@ const facets = [
41
45
  label: 'User requirements',
42
46
  alwaysVisible: false,
43
47
  }),
44
- ...globalSearchBaseConfig.facets,
48
+ language,
49
+ // ...globalSearchBaseConfig.facets,
45
50
  ];
46
51
 
47
52
  export default facets;
package/src/utils.js CHANGED
@@ -32,16 +32,16 @@ export function getBaseUrl(props) {
32
32
  return path;
33
33
  }
34
34
 
35
- export const hasTypeOfBlock = (obj, type, name) => {
35
+ export const hasTypeOfBlock = (obj, name) => {
36
36
  for (const key in obj) {
37
37
  if (obj.hasOwnProperty(key)) {
38
- if (key === type && obj[key] === name) {
38
+ if (key === '@type' && obj[key] === name) {
39
39
  // console.log(`Key "${type}" with value "${name}" found`);
40
40
  return true;
41
41
  }
42
42
 
43
43
  if (typeof obj[key] === 'object' && obj[key] !== null) {
44
- if (hasTypeOfBlock(obj[key], type, name)) {
44
+ if (hasTypeOfBlock(obj[key], name)) {
45
45
  return true;
46
46
  }
47
47
  }
@@ -51,22 +51,29 @@ export const hasTypeOfBlock = (obj, type, name) => {
51
51
  return false;
52
52
  };
53
53
 
54
- export const filterBlocks = (content, block_type) => {
55
- const filteredBlocks = { ...content.blocks };
56
- const filteredBlocksLayout = { ...content.blocks_layout };
54
+ export const filterBlocks = (content, blockTypes = []) => {
55
+ const allBlocks = content.blocks || {};
56
+ const allBlockKeys = Object.keys(allBlocks);
57
57
 
58
- const filteredBlockUID = Object.keys(filteredBlocks)?.filter(
59
- (key) => filteredBlocks[key]['@type'] === block_type,
60
- );
61
- filteredBlockUID.forEach((key) => delete filteredBlocks[key]);
62
- filteredBlocksLayout.items = filteredBlocksLayout?.items?.filter(
63
- (item) => !filteredBlockUID.includes(item),
58
+ const filteredBlocks = { ...allBlocks };
59
+ const filteredLayoutItems = [...(content.blocks_layout?.items || [])];
60
+
61
+ const excludedBlockKeys = allBlockKeys.filter((key) =>
62
+ blockTypes.includes(allBlocks[key]['@type']),
64
63
  );
65
- const hasBlockType = filteredBlockUID.length > 0;
64
+
65
+ excludedBlockKeys.forEach((key) => {
66
+ delete filteredBlocks[key];
67
+ });
66
68
 
67
69
  return {
68
70
  blocks: filteredBlocks,
69
- blocks_layout: filteredBlocksLayout,
70
- hasBlockType,
71
+ blocks_layout: {
72
+ ...content.blocks_layout,
73
+ items: filteredLayoutItems.filter(
74
+ (item) => !excludedBlockKeys.includes(item),
75
+ ),
76
+ },
77
+ hasBlockTypes: excludedBlockKeys.length > 0,
71
78
  };
72
79
  };
@@ -310,15 +310,8 @@ hr {
310
310
 
311
311
  .cca-newsitem-view,
312
312
  .cca-event-view {
313
- .news-date-info {
314
- display: flex;
315
- gap: 3px;
316
- justify-content: flex-end;
317
- }
318
-
319
313
  .content-text p {
320
314
  margin: 0em 0em 1em;
321
- line-height: 1.5;
322
315
  }
323
316
  }
324
317