@eeacms/volto-clms-theme 1.0.75 → 1.0.78

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,8 +4,34 @@ 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
+ #### [1.0.78](https://github.com/eea/volto-clms-theme/compare/1.0.77...1.0.78)
8
+
9
+ - refactor card link [`e3ab510`](https://github.com/eea/volto-clms-theme/commit/e3ab51012c21a1bc62e2600431aac225dbd76003)
10
+ - add link to the entire card [`aee0981`](https://github.com/eea/volto-clms-theme/commit/aee09811585c925a050347259bb10369c0ec4845)
11
+
12
+ #### [1.0.77](https://github.com/eea/volto-clms-theme/compare/1.0.76...1.0.77)
13
+
14
+ > 3 March 2022
15
+
16
+ - Develop [`#222`](https://github.com/eea/volto-clms-theme/pull/222)
17
+ - cardContainerBlock refactoring, remove cardBlock and make ImageEditor… [`#221`](https://github.com/eea/volto-clms-theme/pull/221)
18
+ - fix image uploading workflow [`86c10e6`](https://github.com/eea/volto-clms-theme/commit/86c10e6b9bf2d0e82aa1415539d291d04b6f86e9)
19
+ - cardContainerBlock refactoring, remove cardBlock and make ImageEditor reusable [`2292c6b`](https://github.com/eea/volto-clms-theme/commit/2292c6bdb11eeac3f99df080b096b2d923ed2926)
20
+
21
+ #### [1.0.76](https://github.com/eea/volto-clms-theme/compare/1.0.75...1.0.76)
22
+
23
+ > 2 March 2022
24
+
25
+ - Develop [`#220`](https://github.com/eea/volto-clms-theme/pull/220)
26
+ - add modal when download requests are both standard downloads or prepackaged files [`#219`](https://github.com/eea/volto-clms-theme/pull/219)
27
+ - upgrade volto-accordion-block [`cf8a7a6`](https://github.com/eea/volto-clms-theme/commit/cf8a7a6909b1d38f855ef01f0642add7e882e804)
28
+ - add modal when downloading files are prepackaged and mapviewer [`c974d37`](https://github.com/eea/volto-clms-theme/commit/c974d37f42fd13d0de53416c36ed4b8f8a8ba2c0)
29
+
7
30
  #### [1.0.75](https://github.com/eea/volto-clms-theme/compare/1.0.74...1.0.75)
8
31
 
32
+ > 1 March 2022
33
+
34
+ - New release [`#218`](https://github.com/eea/volto-clms-theme/pull/218)
9
35
  - add elvis operator [`#217`](https://github.com/eea/volto-clms-theme/pull/217)
10
36
  - no need to tinker with dates, we configure the listing in Volto [`#215`](https://github.com/eea/volto-clms-theme/pull/215)
11
37
  - use new placeholder image [`#216`](https://github.com/eea/volto-clms-theme/pull/216)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.75",
3
+ "version": "1.0.78",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -30,7 +30,7 @@
30
30
  "@eeacms/volto-taxonomy"
31
31
  ],
32
32
  "dependencies": {
33
- "@eeacms/volto-accordion-block": "3.4.7",
33
+ "@eeacms/volto-accordion-block": "3.4.13",
34
34
  "@eeacms/volto-arcgis-block": "*",
35
35
  "@eeacms/volto-clms-utils": "0.1.6",
36
36
  "@eeacms/volto-columns-block": "4.4.3",
@@ -1,10 +1,10 @@
1
- export const CardContainerSchema = (types, extras) => ({
1
+ export const CardContainerSchema = () => ({
2
2
  title: 'Card container',
3
3
  fieldsets: [
4
4
  {
5
5
  id: 'default',
6
6
  title: 'Default',
7
- fields: ['title', 'cardStyle', 'cardOrigin', ...extras],
7
+ fields: ['title', 'variation', 'customCards'],
8
8
  },
9
9
  ],
10
10
  properties: {
@@ -13,43 +13,13 @@ export const CardContainerSchema = (types, extras) => ({
13
13
  description: 'Card container block friendly name',
14
14
  type: 'string',
15
15
  },
16
- cardStyle: {
17
- title: 'Card style',
18
- choices: [
19
- ['line', 'Line Image card'],
20
- ['line-color', 'Colored Line card'],
21
- ['doc', 'Line card'],
22
- ['block', 'Block card'],
23
- ['event', 'Event card'],
24
- ],
25
- default: 'line',
26
- },
27
- contentTypes: {
28
- title: 'Content Types',
29
- choices: types,
30
- isMulti: true,
31
- },
32
- cardOrigin: {
33
- title: 'Cards origin',
34
- choices: [
35
- ['current', 'Current folder children'],
36
- ['selection', 'Selected folder children'],
37
- ['custom', 'Customized cards'],
38
- ],
39
- default: 'current',
40
- },
41
- containerSelection: {
42
- title: 'Card container selector',
43
- widget: 'object_browser',
44
- mode: 'link',
45
- },
46
16
  customCards: {
47
17
  title: 'Custom cards',
48
18
  type: 'panels',
49
19
  schema: CardBlockSchema,
50
20
  },
51
21
  },
52
- required: ['cardStyle', 'cardOrigin'],
22
+ required: ['variation', 'cardOrigin'],
53
23
  });
54
24
 
55
25
  export const CardBlockSchema = () => ({
@@ -58,7 +28,7 @@ export const CardBlockSchema = () => ({
58
28
  {
59
29
  id: 'default',
60
30
  title: 'Default',
61
- fields: ['title', 'image', 'description', 'url'],
31
+ fields: ['title', 'description', 'url'],
62
32
  },
63
33
  ],
64
34
  properties: {
@@ -77,7 +47,9 @@ export const CardBlockSchema = () => ({
77
47
  },
78
48
  url: {
79
49
  title: 'url',
80
- type: 'string',
50
+ widget: 'object_browser',
51
+ mode: 'link',
52
+ allowExternals: true,
81
53
  },
82
54
  },
83
55
  required: [],
@@ -1,67 +1,37 @@
1
- import './styles.less';
2
-
3
1
  import { CardBlockSchema, CardContainerSchema } from './CardContainerSchema';
4
2
  import React, { useState } from 'react';
5
3
  import { emptyCard, getPanels } from '../utils';
6
4
 
7
5
  import CclCard from '@eeacms/volto-clms-theme/components/CclCard/CclCard';
8
- import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
9
- import { SidebarPortal } from '@plone/volto/components'; // BlocksForm, Icon,
6
+ import { SidebarPortal, BlockDataForm } from '@plone/volto/components'; // BlocksForm, Icon,
7
+ import { addExtensionFieldToSchema } from '@plone/volto/helpers/Extensions/withBlockSchemaEnhancer';
10
8
  import { compose } from 'redux';
11
9
  import { injectIntl } from 'react-intl';
12
10
  import { isEmpty } from 'lodash';
13
- import { useSelector } from 'react-redux';
14
11
  import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser';
12
+ import CclImageEditor from '@eeacms/volto-clms-theme/components/CclImageEditor/CclImageEditor';
13
+ import { defineMessages } from 'react-intl';
14
+ import config from '@plone/volto/registry';
15
+ import getListingBodyVariation from './utils.js';
15
16
 
16
- const CclCardContainerBlockEdit = (props) => {
17
- const { block, data, onChangeBlock, selected } = props;
18
-
19
- const regex = /[a-zA-Z]+(?!.*[a-zA-Z]+)/;
20
- const types = useSelector((state) => state.types.types);
21
- const type_options = types.map((type) => [
22
- type['@id'].match(regex)[0],
23
- type.title,
24
- ]);
17
+ const messages = defineMessages({
18
+ template: {
19
+ id: 'Variation',
20
+ defaultMessage: 'Variation',
21
+ },
22
+ });
25
23
 
26
- const card = {
27
- '@id': '/en/product-portfolio/how-our-products-are-created',
28
- title: 'Dataset preview title',
29
- description:
30
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis luctus mauris ante, a iaculis leo placerat quis. Nullam vitae vulputate leo, et ultricies dolor.',
31
- image: {
32
- scales: {
33
- icon: {
34
- download:
35
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
36
- },
37
- large: {
38
- download:
39
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
40
- },
41
- listing: {
42
- download:
43
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
44
- },
45
- mini: {
46
- download:
47
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
48
- },
49
- preview: {
50
- download:
51
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
52
- },
53
- thumb: {
54
- download:
55
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
56
- },
57
- tile: {
58
- download:
59
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
60
- },
61
- },
62
- },
63
- url: '/en/product-portfolio/how-our-products-are-created',
64
- };
24
+ const CclCardContainerBlockEdit = ({
25
+ block,
26
+ data,
27
+ onChangeBlock,
28
+ selected,
29
+ editable,
30
+ setSidebarTab,
31
+ openObjectBrowser,
32
+ pathname,
33
+ intl,
34
+ }) => {
65
35
  const properties = isEmpty(data?.customCards?.blocks)
66
36
  ? emptyCard(2)
67
37
  : data.customCards;
@@ -80,21 +50,24 @@ const CclCardContainerBlockEdit = (props) => {
80
50
  /* eslint-disable-next-line */
81
51
  }, []);
82
52
 
83
- const [selectedBlock, setSelectedBlock] = useState(-1);
84
- React.useEffect(() => {
85
- if (!selected) {
86
- setSelectedBlock(-1);
87
- }
88
- }, [selected]);
53
+ const [selectedCardBlock, setSelectedCardBlock] = useState(-1);
54
+
55
+ let schema = CardContainerSchema();
56
+
57
+ schema = addExtensionFieldToSchema({
58
+ schema,
59
+ name: 'variation',
60
+ items: config.blocks.blocksConfig.listing.variations,
61
+ intl,
62
+ title: { id: intl.formatMessage(messages.template) },
63
+ });
89
64
 
90
- let extras = [];
91
- if (data.cardOrigin === 'selection') {
92
- extras.push('containerSelection');
93
- extras.push('contentTypes');
94
- } else if (data.cardOrigin === 'current') {
95
- extras.push('contentTypes');
96
- } else if (data.cardOrigin === 'custom') {
97
- extras.push('customCards');
65
+ const variation = getListingBodyVariation(data);
66
+ let containerClass = '';
67
+ if (['news', 'event'].includes(variation.templateID)) {
68
+ containerClass = 'ccl-container';
69
+ } else if (!['line', 'doc', 'globalSearch'].includes(variation.templateID)) {
70
+ containerClass = 'card-container';
98
71
  }
99
72
 
100
73
  return (
@@ -102,46 +75,44 @@ const CclCardContainerBlockEdit = (props) => {
102
75
  <div
103
76
  className="cardContainer-header"
104
77
  onClick={() => {
105
- props.setSidebarTab(1);
106
- setSelectedBlock(-1);
78
+ setSidebarTab(1);
79
+ setSelectedCardBlock(-1);
107
80
  }}
108
81
  aria-hidden="true"
109
82
  >
110
83
  {data.title || 'Card container'}
111
84
  </div>
112
- <div>
113
- {data.cardOrigin === 'custom' ? (
114
- <>
115
- {panels.map(([uid, panel], index) => (
116
- <div
117
- key={index}
118
- className={uid === selectedBlock && 'block selected'}
119
- onClick={() => {
120
- setSelectedBlock(uid);
121
- }}
122
- onKeyDown={() => {
123
- setSelectedBlock(uid);
124
- }}
125
- role="button"
126
- tabIndex="0"
127
- >
128
- <CclCard
129
- type={data.cardStyle || 'line'}
130
- card={data.customCards.blocks[uid]}
131
- />
132
- </div>
133
- ))}
134
- </>
135
- ) : (
136
- <div className="card-container">
137
- <CclCard type={data.cardStyle} card={card} />
138
- <CclCard type={data.cardStyle} card={card} />
139
- </div>
140
- )}
85
+ <div className={containerClass}>
86
+ {panels.map(([uid, panel], index) => (
87
+ <CclCard
88
+ key={index}
89
+ type={variation?.templateID || 'doc'}
90
+ card={panel}
91
+ onClickImage={() => {
92
+ setSelectedCardBlock(uid);
93
+ }}
94
+ isCustomCard={true}
95
+ CclImageEditor={
96
+ <CclImageEditor
97
+ block={block}
98
+ data={data}
99
+ editable={editable}
100
+ imageUrl={panel?.image?.url}
101
+ onChangeBlock={onChangeBlock}
102
+ openObjectBrowser={openObjectBrowser}
103
+ pathname={pathname}
104
+ selected={selected}
105
+ selectedCardBlock={selectedCardBlock}
106
+ setSelectedCardBlock={setSelectedCardBlock}
107
+ uid={uid}
108
+ />
109
+ }
110
+ />
111
+ ))}
141
112
  </div>
142
- <SidebarPortal selected={selected && selectedBlock === -1}>
143
- <InlineForm
144
- schema={CardContainerSchema(type_options, extras)}
113
+ <SidebarPortal selected={selected && selectedCardBlock === -1}>
114
+ <BlockDataForm
115
+ schema={schema}
145
116
  title="Card container block"
146
117
  onChangeField={(id, value) => {
147
118
  onChangeBlock(block, {
@@ -153,9 +124,11 @@ const CclCardContainerBlockEdit = (props) => {
153
124
  />
154
125
  </SidebarPortal>
155
126
  <SidebarPortal
156
- selected={selected && selectedBlock !== -1 && data.customCards?.blocks}
127
+ selected={
128
+ selected && selectedCardBlock !== -1 && data.customCards?.blocks
129
+ }
157
130
  >
158
- <InlineForm
131
+ <BlockDataForm
159
132
  schema={CardBlockSchema()}
160
133
  title="Card block"
161
134
  onChangeField={(id, value) => {
@@ -165,15 +138,15 @@ const CclCardContainerBlockEdit = (props) => {
165
138
  ...data.customCards,
166
139
  blocks: {
167
140
  ...data.customCards.blocks,
168
- [selectedBlock]: {
169
- ...data.customCards.blocks[selectedBlock],
141
+ [selectedCardBlock]: {
142
+ ...data.customCards.blocks[selectedCardBlock],
170
143
  [id]: value,
171
144
  },
172
145
  },
173
146
  },
174
147
  });
175
148
  }}
176
- formData={data.customCards?.blocks[selectedBlock]}
149
+ formData={data.customCards?.blocks[selectedCardBlock]}
177
150
  />
178
151
  </SidebarPortal>
179
152
  </>
@@ -1,54 +1,31 @@
1
- import { useDispatch, useSelector } from 'react-redux';
2
-
3
1
  import CclCard from '@eeacms/volto-clms-theme/components/CclCard/CclCard';
4
2
  import React from 'react';
5
- import { searchContent } from '@plone/volto/actions';
3
+ import getListingBodyVariation from './utils.js';
6
4
 
7
5
  const CclCardContainerBlockView = (props) => {
8
- const { data, metadata, properties, id } = props;
6
+ const { data } = props;
7
+ let cards = data?.customCards?.blocks_layout?.items.map(
8
+ (uid) => data.customCards.blocks[uid],
9
+ );
9
10
 
10
- const searchSubrequests = useSelector((state) => state.search.subrequests);
11
- const dispatch = useDispatch();
12
- let cards = searchSubrequests?.[props.id]?.items;
11
+ const variation = getListingBodyVariation(data);
13
12
 
14
- let path = '';
15
- if (data.cardOrigin === 'current') {
16
- path = metadata ? metadata['@id'] : properties['@id'];
17
- } else if (data.cardOrigin === 'selection') {
18
- path = data.containerSelection ? data.containerSelection[0]['@id'] : '';
19
- } else if (data.cardOrigin === 'custom') {
20
- cards = data?.customCards?.blocks_layout?.items.map(
21
- (uid) => data.customCards.blocks[uid],
22
- );
13
+ let containerClass = '';
14
+ if (['news', 'event'].includes(variation.templateID)) {
15
+ containerClass = 'ccl-container';
16
+ } else if (!['line', 'doc', 'globalSearch'].includes(variation.templateID)) {
17
+ containerClass = 'card-container';
23
18
  }
24
-
25
- React.useEffect(() => {
26
- let portal_type =
27
- data.contentTypes?.length > 0 ? { portal_type: data.contentTypes } : {};
28
- dispatch(
29
- searchContent(
30
- path,
31
- {
32
- sort_on: 'effective',
33
- sort_order: 'reverse',
34
- fullobjects: 1,
35
- ...portal_type,
36
- },
37
- id,
38
- ),
39
- );
40
- }, [path, data, id, dispatch]);
41
-
42
- var cardStyle = data.cardStyle || 'line';
43
19
  return (
44
- <div
45
- className={
46
- cardStyle === 'line' || cardStyle === 'doc' ? '' : 'card-container'
47
- }
48
- >
20
+ <div className={containerClass}>
49
21
  {cards &&
50
22
  cards.map((card, index) => (
51
- <CclCard key={index} type={cardStyle} card={card} />
23
+ <CclCard
24
+ key={index}
25
+ type={variation.templateID}
26
+ card={card}
27
+ isCustomCard={true}
28
+ />
52
29
  ))}
53
30
  </div>
54
31
  );
@@ -0,0 +1,13 @@
1
+ import config from '@plone/volto/registry';
2
+ const getListingBodyVariation = (data) => {
3
+ const { variations } = config.blocks.blocksConfig.listing;
4
+ const variation = data.variation
5
+ ? variations.find(
6
+ ({ id, templateID }) => id === data.variation && templateID,
7
+ )
8
+ : variations.find(({ isDefault, templateID }) => isDefault && templateID);
9
+
10
+ return variation;
11
+ };
12
+
13
+ export default getListingBodyVariation;