@eeacms/volto-cca-policy 0.2.84 → 0.2.86
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 +13 -0
- package/package.json +2 -2
- package/src/components/theme/BannerTitle/BannerTitle.jsx +2 -2
- package/src/components/theme/Views/CcaEventView.jsx +15 -14
- package/src/components/theme/Views/EventView.jsx +9 -7
- package/src/components/theme/Views/NewsItemView.jsx +37 -29
- package/src/helpers/Constants.jsx +1 -0
- package/src/utils.js +22 -15
- package/theme/globals/views.less +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ 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.86](https://github.com/eea/volto-cca-policy/compare/0.2.85...0.2.86) - 18 December 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: Dependency updates
|
|
10
|
+
|
|
11
|
+
- Release @eeacms/volto-searchlib@2.0.6 [EEA Jenkins - [`05e0fe3`](https://github.com/eea/volto-cca-policy/commit/05e0fe3792bc2406b89c4e0a8c17941a661276ba)]
|
|
12
|
+
|
|
13
|
+
### [0.2.85](https://github.com/eea/volto-cca-policy/compare/0.2.84...0.2.85) - 18 December 2024
|
|
14
|
+
|
|
15
|
+
#### :nail_care: Enhancements
|
|
16
|
+
|
|
17
|
+
- change(view): update Events view - refs #281788 [kreafox - [`f1b8278`](https://github.com/eea/volto-cca-policy/commit/f1b8278b265d50b99f59cbeab9ad9298b0d06d44)]
|
|
18
|
+
- change(view): update News Item view - refs #281788 [kreafox - [`16e1ad7`](https://github.com/eea/volto-cca-policy/commit/16e1ad7763ecea115b611d1538d033b8241fc525)]
|
|
19
|
+
|
|
7
20
|
### [0.2.84](https://github.com/eea/volto-cca-policy/compare/0.2.83...0.2.84) - 17 December 2024
|
|
8
21
|
|
|
9
22
|
#### :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.
|
|
3
|
+
"version": "0.2.86",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@eeacms/volto-globalsearch": "^1.1.0",
|
|
36
36
|
"@eeacms/volto-hero-block": "^7.1.0",
|
|
37
37
|
"@eeacms/volto-openlayers-map": "*",
|
|
38
|
-
"@eeacms/volto-searchlib": "2.0.
|
|
38
|
+
"@eeacms/volto-searchlib": "2.0.6",
|
|
39
39
|
"@eeacms/volto-slate-label": "^0.6.0",
|
|
40
40
|
"@eeacms/volto-tabs-block": "^7.5.1",
|
|
41
41
|
"@elastic/search-ui": "1.21.2",
|
|
@@ -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, '
|
|
15
|
-
const hasCountryFlagBlock = hasTypeOfBlock(blocks, '
|
|
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:
|
|
52
|
-
blocks_layout:
|
|
53
|
-
} = filterBlocks(content, 'tabs_block');
|
|
54
|
-
|
|
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:
|
|
16
|
-
blocks_layout:
|
|
17
|
-
|
|
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
|
-
{
|
|
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:
|
|
40
|
-
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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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:
|
|
23
|
-
blocks_layout:
|
|
24
|
-
|
|
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
|
-
{
|
|
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
|
-
<
|
|
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>
|
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,
|
|
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],
|
|
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,
|
|
55
|
-
const
|
|
56
|
-
const
|
|
54
|
+
export const filterBlocks = (content, blockTypes = []) => {
|
|
55
|
+
const allBlocks = content.blocks || {};
|
|
56
|
+
const allBlockKeys = Object.keys(allBlocks);
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
64
|
+
|
|
65
|
+
excludedBlockKeys.forEach((key) => {
|
|
66
|
+
delete filteredBlocks[key];
|
|
67
|
+
});
|
|
66
68
|
|
|
67
69
|
return {
|
|
68
70
|
blocks: filteredBlocks,
|
|
69
|
-
blocks_layout:
|
|
70
|
-
|
|
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
|
};
|
package/theme/globals/views.less
CHANGED
|
@@ -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
|
|