@eeacms/volto-cca-policy 0.1.81 → 0.1.82

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,11 +4,28 @@ 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.81](https://github.com/eea/volto-cca-policy/compare/0.1.80...0.1.81) - 21 February 2024
7
+ ### [0.1.82](https://github.com/eea/volto-cca-policy/compare/0.1.81...0.1.82) - 24 February 2024
8
+
9
+ #### :house: Internal changes
10
+
11
+ - style: Automated code fix [eea-jenkins - [`3107391`](https://github.com/eea/volto-cca-policy/commit/31073918d51bcd0adbe929cfea001671b892e04f)]
8
12
 
9
13
  #### :hammer_and_wrench: Others
10
14
 
11
- - Don't hide the section header [Tiberiu Ichim - [`f7d9ded`](https://github.com/eea/volto-cca-policy/commit/f7d9ded5932b8636d3f485e5184639f8d88f3d33)]
15
+ - Code cleanup [Tiberiu Ichim - [`47a937c`](https://github.com/eea/volto-cca-policy/commit/47a937c76eeb4d31cf69bdfc84986b4a7b5a53fb)]
16
+ - Use a json file [Tiberiu Ichim - [`cd5307e`](https://github.com/eea/volto-cca-policy/commit/cd5307e14b72e27582e323fa5bd7355e246c886e)]
17
+ - Eslint [Tiberiu Ichim - [`9a79b88`](https://github.com/eea/volto-cca-policy/commit/9a79b882251c83c523c5ac3cfc4d74bed10f2727)]
18
+ - Eslint [Tiberiu Ichim - [`367d0b6`](https://github.com/eea/volto-cca-policy/commit/367d0b632f09e2d7d47289e777019d3257982c0d)]
19
+ - Show tags in news item [Tiberiu Ichim - [`4660adc`](https://github.com/eea/volto-cca-policy/commit/4660adc38a9cc7d0f34db021918e6148f1aef367)]
20
+ - Add newsitem view [Tiberiu Ichim - [`ce83fec`](https://github.com/eea/volto-cca-policy/commit/ce83feca8dc01df52cb410c0a1da748663f75271)]
21
+ - Show blocks in CCAEventView [Tiberiu Ichim - [`89e0e78`](https://github.com/eea/volto-cca-policy/commit/89e0e7864a9a490812bc2599ac0a5c8bca3668b4)]
22
+ - Add event view view [Tiberiu Ichim - [`a4dfcd7`](https://github.com/eea/volto-cca-policy/commit/a4dfcd7b4d560db839eb7d6b116584e82d2bb706)]
23
+ - Fix hit enter in layout settings block [Tiberiu Ichim - [`5774d3e`](https://github.com/eea/volto-cca-policy/commit/5774d3e1d6332b8661aa1a78a9b300820b2d4f1c)]
24
+ - test: increase coverage [kreafox - [`334a6a3`](https://github.com/eea/volto-cca-policy/commit/334a6a374d6af8e4856c1be5bcee073a619c88af)]
25
+ - test: fix ES lint warnings [kreafox - [`e884310`](https://github.com/eea/volto-cca-policy/commit/e88431084ddaa6298541ac2a9edefcc45b26ea0e)]
26
+ - Add details [Tiberiu Ichim - [`ad521be`](https://github.com/eea/volto-cca-policy/commit/ad521bed6f11d4fdf8590eac5dc9f5352d05dd27)]
27
+ ### [0.1.81](https://github.com/eea/volto-cca-policy/compare/0.1.80...0.1.81) - 21 February 2024
28
+
12
29
  ### [0.1.80](https://github.com/eea/volto-cca-policy/compare/0.1.79...0.1.80) - 21 February 2024
13
30
 
14
31
  #### :bug: Bug Fixes
@@ -381,13 +398,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
381
398
  - Refs #260715 rast-block wip [Tripon Eugen - [`f19d54e`](https://github.com/eea/volto-cca-policy/commit/f19d54e0b9a6a86bf344eb85b6a1cda7f3de91bf)]
382
399
  - Refs #260715 rast-block wip [Tripon Eugen - [`2828537`](https://github.com/eea/volto-cca-policy/commit/2828537b6c084cd1a82162d552fb4ef025b71f9f)]
383
400
  - Refs #260715 rast-block updates [Tripon Eugen - [`1e803e5`](https://github.com/eea/volto-cca-policy/commit/1e803e5bd3d3fb7558f261c76c68866be7beb8b5)]
384
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`0a15e1b`](https://github.com/eea/volto-cca-policy/commit/0a15e1b2ad081233685e80d5b3c60a8663f6b896)]
385
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`9554e44`](https://github.com/eea/volto-cca-policy/commit/9554e44c92a621a52b2adb5a4830fb084ee5734b)]
386
401
  ### [0.1.49](https://github.com/eea/volto-cca-policy/compare/0.1.48...0.1.49) - 15 November 2023
387
402
 
388
403
  #### :house: Internal changes
389
404
 
390
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`7b820a6`](https://github.com/eea/volto-cca-policy/commit/7b820a6369c2ddd5203b1a4abe352cb4bb43db7a)]
391
405
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`f0a8061`](https://github.com/eea/volto-cca-policy/commit/f0a8061c275c236deb00087c23fac9860a073106)]
392
406
 
393
407
  #### :hammer_and_wrench: Others
@@ -404,9 +418,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
404
418
  - Refs #259267 - jenkins test [Tripon Eugen - [`cacd31e`](https://github.com/eea/volto-cca-policy/commit/cacd31e7b1afe0983674ed5c7632d2e1d7fa752e)]
405
419
  - Refs #259267 - jenkins [Tripon Eugen - [`5b3affe`](https://github.com/eea/volto-cca-policy/commit/5b3affee8401239de10097884c1b7f2349d15ec0)]
406
420
  - Refs #259267 - add When, lead image and title to files [Tripon Eugen - [`2cedb23`](https://github.com/eea/volto-cca-policy/commit/2cedb237f898af9057e13fba94b615ef71077204)]
407
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`4d607a5`](https://github.com/eea/volto-cca-policy/commit/4d607a576e9d0a5c34e48c41b409e7df616ee3d6)]
408
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`b7f74d5`](https://github.com/eea/volto-cca-policy/commit/b7f74d53513a6edbfbca5cb6d19687929bb1e5db)]
409
- - test: [JENKINS] Improve cypress time [valentinab25 - [`db65617`](https://github.com/eea/volto-cca-policy/commit/db656173391f65157098d95d388c25f6429753d8)]
410
421
  - Refs #259267 - cca event blocks attachments and check not mandatoty fields [Tripon Eugen - [`3138e5a`](https://github.com/eea/volto-cca-policy/commit/3138e5afb5bfbdbed14e27ed457b16867b7fa414)]
411
422
  - 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)]
412
423
  - Refs #161485 - Fix ECDE name conflict. [GhitaB - [`8bfd99f`](https://github.com/eea/volto-cca-policy/commit/8bfd99ff68bb82a04d1c0ed625fa514fcf46289e)]
@@ -623,7 +634,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
623
634
 
624
635
  #### :house: Internal changes
625
636
 
626
- - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`ad1ced0`](https://github.com/eea/volto-cca-policy/commit/ad1ced0971ba116c13a3b5fcc039172cc915c919)]
627
637
 
628
638
  #### :hammer_and_wrench: Others
629
639
 
@@ -1104,7 +1114,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1104
1114
  #### :hammer_and_wrench: Others
1105
1115
 
1106
1116
  - Refs #158294 - Update supported languages list. [GhitaB - [`0a4f91f`](https://github.com/eea/volto-cca-policy/commit/0a4f91f39b7edc367bd4c127d6a8f273c7788361)]
1107
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`8f1f9ce`](https://github.com/eea/volto-cca-policy/commit/8f1f9ce6c22805670cc0800d3c779b6d619d0f31)]
1108
1117
  ### [0.1.1](https://github.com/eea/volto-cca-policy/compare/0.1.0...0.1.1) - 13 December 2022
1109
1118
 
1110
1119
  #### :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.81",
3
+ "version": "0.1.82",
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",
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
- import { compose } from 'redux';
3
2
  import { Link } from 'react-router-dom';
4
3
  import { Dropdown } from 'semantic-ui-react';
5
- import { connect, useDispatch, useSelector } from 'react-redux';
4
+ import { useDispatch, useSelector } from 'react-redux';
6
5
  import { getQueryStringResults } from '@plone/volto/actions';
7
- import { regionCountries } from './countries';
6
+ import regionCountries from './countries.json';
8
7
 
9
8
  const getSiblings = (items) => {
10
9
  const regionsDropdown = (items || []).map((item) => {
@@ -24,8 +23,9 @@ const getSiblings = (items) => {
24
23
  return regionsDropdown;
25
24
  };
26
25
 
27
- const TransRegionSelectView = (props) => {
28
- const { id, data, content } = props;
26
+ export default function TransRegionSelectView(props) {
27
+ const { id, data } = props;
28
+ const content = useSelector((state) => state.content.data);
29
29
  const { title } = content;
30
30
  const dispatch = useDispatch();
31
31
  const querystringResults = useSelector(
@@ -86,7 +86,7 @@ const TransRegionSelectView = (props) => {
86
86
  title === 'Other regions' ? null : (
87
87
  <h5>Region's countries:</h5>
88
88
  )}
89
- {regionCountries
89
+ {regionCountries.countries
90
90
  .filter((item) => item.region === title)
91
91
  .map((item, i) => (
92
92
  <div className="countries-listing" key={i}>
@@ -115,10 +115,4 @@ const TransRegionSelectView = (props) => {
115
115
  </div>
116
116
  </div>
117
117
  );
118
- };
119
-
120
- export default compose(
121
- connect((state, props) => ({
122
- content: state.content.data,
123
- })),
124
- )(TransRegionSelectView);
118
+ }
@@ -0,0 +1,150 @@
1
+ {
2
+ "countries": [
3
+ {
4
+ "region": "Adriatic-Ionian Area",
5
+ "countries": [
6
+ ["Croatia", "/countries/croatia"],
7
+ ["Greece", "/countries/greece"],
8
+ ["Italy", "/countries/italy"],
9
+ ["Slovenia", "/countries/slovenia"],
10
+ ["Albania", ""],
11
+ ["Bosnia and Herzegovina", ""],
12
+ ["Montenegro", ""],
13
+ ["Republic of North Macedonia", ""],
14
+ ["Serbia", ""]
15
+ ]
16
+ },
17
+ {
18
+ "region": "Alpine Space",
19
+ "countries": [
20
+ ["Austria", "/countries/austria"],
21
+ ["France", "/countries/france"],
22
+ ["Germany", "/countries/germany"],
23
+ ["Italy", "/countries/italy"],
24
+ ["Slovenia", "/countries/slovenia"],
25
+ ["Liechtenstein", ""],
26
+ ["Switzerland", "/countries/switzerland"]
27
+ ]
28
+ },
29
+ {
30
+ "region": "Northern Periphery and Arctic",
31
+ "countries": [
32
+ ["Finland", "/countries/finland"],
33
+ ["Ireland", "/countries/ireland"],
34
+ ["Sweden", "/countries/sweden"],
35
+ ["Iceland", "/countries/iceland"],
36
+ ["Norway", "/countries/norway"],
37
+ ["Greenland", ""],
38
+ ["Faroe Islands", ""]
39
+ ]
40
+ },
41
+ {
42
+ "region": "Atlantic Area",
43
+ "countries": [
44
+ ["France", "/countries/france"],
45
+ ["Ireland", "/countries/ireland"],
46
+ ["Portugal", "/countries/portugal"],
47
+ ["Spain", "/countries/spain"]
48
+ ]
49
+ },
50
+ {
51
+ "region": "Baltic Sea",
52
+ "countries": [
53
+ ["Denmark", "/countries/denmark"],
54
+ ["Estonia", "/countries/estonia"],
55
+ ["Finland", "/countries/finland"],
56
+ ["Germany", "/countries/germany"],
57
+ ["Latvia", "/countries/latvia"],
58
+ ["Lithuania", "/countries/lithuania"],
59
+ ["Poland", "/countries/poland"],
60
+ ["Sweden", "/countries/sweden"],
61
+ ["Norway", "/countries/norway"]
62
+ ]
63
+ },
64
+ {
65
+ "region": "Central Europe",
66
+ "countries": [
67
+ ["Austria", "/countries/austria"],
68
+ ["Croatia", "/countries/croatia"],
69
+ ["Czechia", "/countries/czech-republic"],
70
+ ["Germany", "/countries/germany"],
71
+ ["Hungary", "/countries/hungary"],
72
+ ["Italy", "/countries/italy"],
73
+ ["Poland", "/countries/poland"],
74
+ ["Slovakia", "/countries/slovakia"],
75
+ ["Slovenia", "/countries/slovenia"]
76
+ ]
77
+ },
78
+ {
79
+ "region": "Danube Area",
80
+ "countries": [
81
+ ["Austria", "/countries/austria"],
82
+ ["Bulgaria", "/countries/bulgaria"],
83
+ ["Croatia", "/countries/croatia"],
84
+ ["Czechia", "/countries/czech-republic"],
85
+ ["Germany", "/countries/germany"],
86
+ ["Hungary", "/countries/hungary"],
87
+ ["Romania", "/countries/romania"],
88
+ ["Slovakia", "/countries/slovakia"],
89
+ ["Slovenia", "/countries/slovenia"],
90
+ ["Bosnia and Herzegovina, ", ""],
91
+ ["Montenegro", ""],
92
+ ["Serbia", ""],
93
+ ["Ukraine", ""],
94
+ ["Republic of Moldova", ""]
95
+ ]
96
+ },
97
+ {
98
+ "region": "Mediterranean Area",
99
+ "countries": [
100
+ ["Albania", ""],
101
+ ["Bosnia and Herzegovina", ""],
102
+ ["Bulgaria", "/countries/bulgaria"],
103
+ ["Croatia", "/countries/croatia"],
104
+ ["Cyprus", "/countries/cyprus"],
105
+ ["France", "/countries/france"],
106
+ ["Greece", "/countries/greece"],
107
+ ["Italy", "/countries/italy"],
108
+ ["Malta", "/countries/malta"],
109
+ ["Montenegro", ""],
110
+ ["Portugal", "/countries/portugal"],
111
+ ["Republic of North Macedonia", ""],
112
+ ["Slovenia", "/countries/slovenia"],
113
+ ["Spain", "/countries/spain"]
114
+ ]
115
+ },
116
+ {
117
+ "region": "North Sea Region",
118
+ "countries": [
119
+ ["Belgium", "/countries/belgium"],
120
+ ["Denmark", "/countries/denmark"],
121
+ ["Germany", "/countries/germany"],
122
+ ["France", "/countries/france"],
123
+ ["Netherlands", "/countries/netherlands"],
124
+ ["Sweden", "/countries/sweden"],
125
+ ["Norway", "/countries/norway"]
126
+ ]
127
+ },
128
+ {
129
+ "region": "North-West Europe",
130
+ "countries": [
131
+ ["Belgium", "/countries/belgium"],
132
+ ["France", "/countries/france"],
133
+ ["Germany", "/countries/germany"],
134
+ ["Ireland", "/countries/ireland"],
135
+ ["Luxembourg", "/countries/luxembourg"],
136
+ ["Netherlands", "/countries/netherlands"],
137
+ ["Switzerland", "/countries/switzerland"]
138
+ ]
139
+ },
140
+ {
141
+ "region": "South-West Europe",
142
+ "countries": [
143
+ ["France", "/countries/france"],
144
+ ["Portugal", "/countries/portugal"],
145
+ ["Spain", "/countries/spain"],
146
+ ["Andorra", ""]
147
+ ]
148
+ }
149
+ ]
150
+ }
@@ -0,0 +1,316 @@
1
+ /**
2
+ * CreatableSelectWidget component.
3
+ * @module components/manage/Widgets/SelectWidget
4
+ *
5
+ * A copy of the SelectWidget component. The only difference is that is uses the Creatable component as a base
6
+ */
7
+
8
+ import React, { Component } from 'react';
9
+ import PropTypes from 'prop-types';
10
+ import { connect } from 'react-redux';
11
+ import { compose } from 'redux';
12
+ import { map } from 'lodash';
13
+ import { defineMessages, injectIntl } from 'react-intl';
14
+ import {
15
+ getVocabFromHint,
16
+ getVocabFromField,
17
+ getVocabFromItems,
18
+ } from '@plone/volto/helpers';
19
+ import { FormFieldWrapper } from '@plone/volto/components';
20
+ import { getVocabulary, getVocabularyTokenTitle } from '@plone/volto/actions';
21
+ import { normalizeValue } from '@plone/volto/components/manage/Widgets/SelectUtils';
22
+
23
+ import {
24
+ customSelectStyles,
25
+ DropdownIndicator,
26
+ ClearIndicator,
27
+ Option,
28
+ selectTheme,
29
+ MenuList,
30
+ MultiValueContainer,
31
+ } from '@plone/volto/components/manage/Widgets/SelectStyling';
32
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
33
+
34
+ import loadable from '@loadable/component';
35
+
36
+ export const Creatable = loadable(() => import('react-select/creatable'));
37
+
38
+ const messages = defineMessages({
39
+ default: {
40
+ id: 'Default',
41
+ defaultMessage: 'Default',
42
+ },
43
+ idTitle: {
44
+ id: 'Short Name',
45
+ defaultMessage: 'Short Name',
46
+ },
47
+ idDescription: {
48
+ id: 'Used for programmatic access to the fieldset.',
49
+ defaultMessage: 'Used for programmatic access to the fieldset.',
50
+ },
51
+ title: {
52
+ id: 'Title',
53
+ defaultMessage: 'Title',
54
+ },
55
+ description: {
56
+ id: 'Description',
57
+ defaultMessage: 'Description',
58
+ },
59
+ close: {
60
+ id: 'Close',
61
+ defaultMessage: 'Close',
62
+ },
63
+ choices: {
64
+ id: 'Choices',
65
+ defaultMessage: 'Choices',
66
+ },
67
+ required: {
68
+ id: 'Required',
69
+ defaultMessage: 'Required',
70
+ },
71
+ select: {
72
+ id: 'Select…',
73
+ defaultMessage: 'Select…',
74
+ },
75
+ no_value: {
76
+ id: 'No value',
77
+ defaultMessage: 'No value',
78
+ },
79
+ no_options: {
80
+ id: 'No options',
81
+ defaultMessage: 'No options',
82
+ },
83
+ });
84
+
85
+ /**
86
+ * SelectWidget component class.
87
+ * @function SelectWidget
88
+ * @returns {string} Markup of the component.
89
+ */
90
+ class SelectWidget extends Component {
91
+ /**
92
+ * Property types.
93
+ * @property {Object} propTypes Property types.
94
+ * @static
95
+ */
96
+ static propTypes = {
97
+ id: PropTypes.string.isRequired,
98
+ title: PropTypes.string.isRequired,
99
+ description: PropTypes.string,
100
+ required: PropTypes.bool,
101
+ error: PropTypes.arrayOf(PropTypes.string),
102
+ getVocabulary: PropTypes.func.isRequired,
103
+ getVocabularyTokenTitle: PropTypes.func.isRequired,
104
+ choices: PropTypes.arrayOf(
105
+ PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
106
+ ),
107
+ items: PropTypes.shape({
108
+ vocabulary: PropTypes.object,
109
+ }),
110
+ widgetOptions: PropTypes.shape({
111
+ vocabulary: PropTypes.object,
112
+ }),
113
+ value: PropTypes.oneOfType([
114
+ PropTypes.object,
115
+ PropTypes.string,
116
+ PropTypes.bool,
117
+ PropTypes.func,
118
+ PropTypes.array,
119
+ ]),
120
+ onChange: PropTypes.func.isRequired,
121
+ onBlur: PropTypes.func,
122
+ onClick: PropTypes.func,
123
+ onEdit: PropTypes.func,
124
+ onDelete: PropTypes.func,
125
+ wrapped: PropTypes.bool,
126
+ noValueOption: PropTypes.bool,
127
+ customOptionStyling: PropTypes.any,
128
+ isMulti: PropTypes.bool,
129
+ placeholder: PropTypes.string,
130
+ };
131
+
132
+ /**
133
+ * Default properties
134
+ * @property {Object} defaultProps Default properties.
135
+ * @static
136
+ */
137
+ static defaultProps = {
138
+ description: null,
139
+ required: false,
140
+ items: {
141
+ vocabulary: null,
142
+ },
143
+ widgetOptions: {
144
+ vocabulary: null,
145
+ },
146
+ error: [],
147
+ choices: [],
148
+ value: null,
149
+ onChange: () => {},
150
+ onBlur: () => {},
151
+ onClick: () => {},
152
+ onEdit: null,
153
+ onDelete: null,
154
+ noValueOption: true,
155
+ customOptionStyling: null,
156
+ };
157
+
158
+ /**
159
+ * Component did mount
160
+ * @method componentDidMount
161
+ * @returns {undefined}
162
+ */
163
+ componentDidMount() {
164
+ if (
165
+ (!this.props.choices || this.props.choices?.length === 0) &&
166
+ this.props.vocabBaseUrl
167
+ ) {
168
+ this.props.getVocabulary({
169
+ vocabNameOrURL: this.props.vocabBaseUrl,
170
+ size: -1,
171
+ subrequest: this.props.lang,
172
+ });
173
+ }
174
+ }
175
+
176
+ componentDidUpdate(prevProps) {
177
+ if (
178
+ this.props.vocabBaseUrl !== prevProps.vocabBaseUrl &&
179
+ (!this.props.choices || this.props.choices?.length === 0)
180
+ ) {
181
+ this.props.getVocabulary({
182
+ vocabNameOrURL: this.props.vocabBaseUrl,
183
+ size: -1,
184
+ subrequest: this.props.lang,
185
+ });
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Render method.
191
+ * @method render
192
+ * @returns {string} Markup for the component.
193
+ */
194
+ render() {
195
+ const { id, choices, value, intl, onChange } = this.props;
196
+ const normalizedValue = normalizeValue(choices, value, intl);
197
+ // Make sure that both disabled and isDisabled (from the DX layout feat work)
198
+ const disabled = this.props.disabled || this.props.isDisabled;
199
+
200
+ let options = this.props.vocabBaseUrl
201
+ ? this.props.choices
202
+ : [
203
+ ...map(choices, (option) => ({
204
+ value: option[0],
205
+ label:
206
+ // Fix "None" on the serializer, to remove when fixed in p.restapi
207
+ option[1] !== 'None' && option[1] ? option[1] : option[0],
208
+ })),
209
+ // Only set "no-value" option if there's no default in the field
210
+ // TODO: also if this.props.defaultValue?
211
+ ...(this.props.noValueOption &&
212
+ (this.props.default === undefined || this.props.default === null)
213
+ ? [
214
+ {
215
+ label: this.props.intl.formatMessage(messages.no_value),
216
+ value: 'no-value',
217
+ },
218
+ ]
219
+ : []),
220
+ ];
221
+
222
+ const isMulti = this.props.isMulti
223
+ ? this.props.isMulti
224
+ : id === 'roles' || id === 'groups' || this.props.type === 'array';
225
+
226
+ return (
227
+ <FormFieldWrapper {...this.props}>
228
+ <Creatable
229
+ id={`field-${id}`}
230
+ key={choices}
231
+ name={id}
232
+ menuShouldScrollIntoView={false}
233
+ isDisabled={disabled}
234
+ isSearchable={true}
235
+ className="react-select-container"
236
+ classNamePrefix="react-select"
237
+ isMulti={isMulti}
238
+ options={options}
239
+ styles={customSelectStyles}
240
+ theme={selectTheme}
241
+ components={{
242
+ ...(options?.length > 25 && {
243
+ MenuList,
244
+ }),
245
+ MultiValueContainer,
246
+ DropdownIndicator,
247
+ ClearIndicator,
248
+ Option: this.props.customOptionStyling || Option,
249
+ }}
250
+ value={normalizedValue}
251
+ placeholder={
252
+ this.props.placeholder ??
253
+ this.props.intl.formatMessage(messages.select)
254
+ }
255
+ onChange={(selectedOption) => {
256
+ if (isMulti) {
257
+ return onChange(
258
+ id,
259
+ selectedOption.map((el) => el.value),
260
+ );
261
+ }
262
+ return onChange(
263
+ id,
264
+ selectedOption && selectedOption.value !== 'no-value'
265
+ ? selectedOption.value
266
+ : undefined,
267
+ );
268
+ }}
269
+ isClearable
270
+ />
271
+ </FormFieldWrapper>
272
+ );
273
+ }
274
+ }
275
+
276
+ export const SelectWidgetComponent = injectIntl(SelectWidget);
277
+
278
+ export default compose(
279
+ injectLazyLibs(['reactSelect']),
280
+ connect(
281
+ (state, props) => {
282
+ const vocabBaseUrl = !props.choices
283
+ ? getVocabFromHint(props) ||
284
+ getVocabFromField(props) ||
285
+ getVocabFromItems(props)
286
+ : '';
287
+
288
+ const vocabState =
289
+ state.vocabularies?.[vocabBaseUrl]?.subrequests?.[state.intl.locale];
290
+
291
+ // If the schema already has the choices in it, then do not try to get the vocab,
292
+ // even if there is one
293
+ if (props.choices) {
294
+ return {
295
+ choices: props.choices,
296
+ lang: state.intl.locale,
297
+ };
298
+ } else if (vocabState) {
299
+ return {
300
+ vocabBaseUrl,
301
+ choices: vocabState?.items ?? [],
302
+ lang: state.intl.locale,
303
+ };
304
+ // There is a moment that vocabState is not there yet, so we need to pass the
305
+ // vocabBaseUrl to the component.
306
+ } else if (vocabBaseUrl) {
307
+ return {
308
+ vocabBaseUrl,
309
+ lang: state.intl.locale,
310
+ };
311
+ }
312
+ return { lang: state.intl.locale };
313
+ },
314
+ { getVocabulary, getVocabularyTokenTitle },
315
+ ),
316
+ )(SelectWidgetComponent);
@@ -0,0 +1,89 @@
1
+ import React from 'react';
2
+ import configureStore from 'redux-mock-store';
3
+ import { Provider } from 'react-intl-redux';
4
+ import { waitFor, render, screen, fireEvent } from '@testing-library/react';
5
+
6
+ import CreatableSelectWidget from './CreatableSelectWidget';
7
+
8
+ const mockStore = configureStore();
9
+
10
+ jest.mock('@plone/volto/helpers/Loadable/Loadable');
11
+ beforeAll(
12
+ async () =>
13
+ await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
14
+ );
15
+
16
+ test('renders a select widget component', async () => {
17
+ const store = mockStore({
18
+ intl: {
19
+ locale: 'en',
20
+ messages: {},
21
+ },
22
+ vocabularies: {
23
+ 'plone.app.vocabularies.Keywords': {
24
+ items: [{ title: 'My item', value: 'myitem' }],
25
+ itemsTotal: 1,
26
+ },
27
+ },
28
+ });
29
+
30
+ const { container } = render(
31
+ <Provider store={store}>
32
+ <CreatableSelectWidget
33
+ id="my-field"
34
+ title="My field"
35
+ fieldSet="default"
36
+ onChange={() => {}}
37
+ onBlur={() => {}}
38
+ onClick={() => {}}
39
+ />
40
+ </Provider>,
41
+ );
42
+
43
+ await waitFor(() => screen.getByText('My field'));
44
+ expect(container).toMatchSnapshot();
45
+ });
46
+
47
+ test("No 'No value' option when default value is 0", async () => {
48
+ const store = mockStore({
49
+ intl: {
50
+ locale: 'en',
51
+ messages: {},
52
+ },
53
+ });
54
+
55
+ const choices = [
56
+ ['0', 'None'],
57
+ ['1', 'One'],
58
+ ];
59
+
60
+ const value = {
61
+ value: '0',
62
+ label: 'None',
63
+ };
64
+
65
+ const _default = 0;
66
+
67
+ const { container } = render(
68
+ <Provider store={store}>
69
+ <CreatableSelectWidget
70
+ id="my-field"
71
+ title="My field"
72
+ fieldSet="default"
73
+ choices={choices}
74
+ default={_default}
75
+ value={value}
76
+ onChange={() => {}}
77
+ onBlur={() => {}}
78
+ onClick={() => {}}
79
+ />
80
+ </Provider>,
81
+ );
82
+
83
+ await waitFor(() => screen.getByText('None'));
84
+ fireEvent.mouseDown(
85
+ container.querySelector('.react-select__dropdown-indicator'),
86
+ { button: 0 },
87
+ );
88
+ expect(container).toMatchSnapshot();
89
+ });
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { DocumentsList, HTMLField } from '@eeacms/volto-cca-policy/helpers';
3
3
  import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
4
4
  import { Grid } from 'semantic-ui-react';
5
+ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
5
6
  import config from '@plone/volto/registry';
6
7
 
7
8
  function CcaEventView(props) {
@@ -57,6 +58,8 @@ function CcaEventView(props) {
57
58
  </>
58
59
  )}
59
60
  <HTMLField value={content.text} className="long_description" />
61
+ <RenderBlocks {...props} />
62
+
60
63
  <h2>Agenda and supporting documents</h2>
61
64
  <HTMLField value={content.agenda} className="long_description" />
62
65
  {content?.agenda_file && <DocumentsList content={agenda_files} />}
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { HTMLField } from '@eeacms/volto-cca-policy/helpers';
3
+ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
4
+ import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
5
+ import { Grid } from 'semantic-ui-react';
6
+ import config from '@plone/volto/registry';
7
+
8
+ function CcaEventView(props) {
9
+ const {
10
+ blocks: { blocksConfig },
11
+ } = config;
12
+ const TitleBlockView = blocksConfig?.title?.view;
13
+ const { content } = props;
14
+ // cca_files: [content.agenda_file]}
15
+
16
+ return (
17
+ <div className="cca-event-view">
18
+ {content?.image !== null && (
19
+ <TitleBlockView
20
+ {...props}
21
+ data={{ info: [{ description: '' }] }}
22
+ metadata={content}
23
+ />
24
+ )}
25
+ <div className="ui container">
26
+ <Grid columns="12">
27
+ <div className="row">
28
+ <Grid.Column
29
+ mobile={12}
30
+ tablet={12}
31
+ computer={9}
32
+ className="col-left"
33
+ >
34
+ {content?.image === null && (
35
+ <>
36
+ <div className="ui label">Climate adapt event</div>
37
+ <h1>{content.title}</h1>
38
+ </>
39
+ )}
40
+ <p>{content.description}</p>
41
+ <HTMLField value={content.text} className="long_description" />
42
+ <RenderBlocks {...props} />
43
+ </Grid.Column>
44
+ <Grid.Column
45
+ mobile={12}
46
+ tablet={12}
47
+ computer={3}
48
+ className="col-right"
49
+ >
50
+ <h3>When</h3>
51
+ <When
52
+ start={content.start}
53
+ end={content.end}
54
+ whole_day={content.whole_day}
55
+ open_end={content.open_end}
56
+ />
57
+ {content?.location !== null && (
58
+ <>
59
+ <h3>Where</h3>
60
+ <p>{content.location}</p>
61
+ </>
62
+ )}
63
+ {!!content.contact_email && (
64
+ <>
65
+ <h3>Info</h3>
66
+ <p>{content.contact_email}</p>
67
+ </>
68
+ )}
69
+ </Grid.Column>
70
+ </div>
71
+ </Grid>
72
+ </div>
73
+ </div>
74
+ );
75
+ }
76
+
77
+ export default CcaEventView;
@@ -0,0 +1,54 @@
1
+ // import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
2
+ import React from 'react';
3
+ import { HTMLField } from '@eeacms/volto-cca-policy/helpers';
4
+ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
5
+ import config from '@plone/volto/registry';
6
+ import { Label } from 'semantic-ui-react';
7
+
8
+ // const Date = (props) => {
9
+ // const date = props.content?.effective;
10
+ // return date ? (
11
+ // <>
12
+ // <When start={date} end={date} whole_day={true} open_end={false} />
13
+ // </>
14
+ // ) : null;
15
+ // };
16
+
17
+ const SubjectTags = (props) => {
18
+ const tags = props.content?.subjects;
19
+ return tags?.length > 0 ? (
20
+ <>
21
+ Filed under:{' '}
22
+ {tags.map((tag) => (
23
+ <Label key={tag}>{tag}</Label>
24
+ ))}
25
+ </>
26
+ ) : null;
27
+ };
28
+
29
+ function CcaEventView(props) {
30
+ const {
31
+ blocks: { blocksConfig },
32
+ } = config;
33
+ const TitleBlockView = blocksConfig?.title?.view;
34
+ const { content } = props;
35
+
36
+ return (
37
+ <div className="cca-newsitem-view">
38
+ <TitleBlockView
39
+ {...props}
40
+ data={{ info: [{ description: '' }] }}
41
+ metadata={content}
42
+ />
43
+ <div className="ui container">
44
+ <p>{content.description}</p>
45
+ <HTMLField value={content.text} className="long_description" />
46
+ <RenderBlocks {...props} />
47
+ {/* <Date {...props} /> */}
48
+ <SubjectTags {...props} />
49
+ </div>
50
+ </div>
51
+ );
52
+ }
53
+
54
+ export default CcaEventView;
package/src/index.js CHANGED
@@ -5,6 +5,8 @@ import { Sitemap } from '@plone/volto/components';
5
5
  import AdaptationOptionView from './components/theme/Views/AdaptationOptionView';
6
6
  import CaseStudyView from './components/theme/Views/CaseStudyView';
7
7
  import CcaEventView from './components/theme/Views/CcaEventView';
8
+ import NewsItemView from './components/theme/Views/NewsItemView';
9
+ import EventView from './components/theme/Views/EventView';
8
10
  import GuidanceView from './components/theme/Views/GuidanceView';
9
11
  import IndicatorView from './components/theme/Views/IndicatorView';
10
12
  import InformationPortalView from './components/theme/Views/InformationPortalView';
@@ -30,6 +32,7 @@ import GeolocationWidget from './components/theme/Widgets/GeolocationWidget';
30
32
  import MigrationButtons from './components/MigrationButtons';
31
33
 
32
34
  import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
35
+ import CreatableSelectWidget from './components/manage/Widgets/CreatableSelectWidget';
33
36
 
34
37
  const getEnv = () => (typeof window !== 'undefined' ? window.env : process.env);
35
38
 
@@ -190,6 +193,10 @@ const applyConfig = (config) => {
190
193
  config.blocks.blocksConfig.maps.restricted = false;
191
194
  }
192
195
 
196
+ if (config.blocks.blocksConfig.layoutSettings) {
197
+ config.blocks.blocksConfig.layoutSettings.blockHasOwnFocusManagement = false;
198
+ }
199
+
193
200
  // Enable video
194
201
  if (config.blocks.blocksConfig.video) {
195
202
  config.blocks.blocksConfig.video.restricted = false;
@@ -241,6 +248,7 @@ const applyConfig = (config) => {
241
248
  'eea.climateadapt.adaptationoption': AdaptationOptionView,
242
249
  'eea.climateadapt.casestudy': CaseStudyView,
243
250
  'cca-event': CcaEventView,
251
+ Event: EventView,
244
252
  'eea.climateadapt.guidancedocument': GuidanceView,
245
253
  'eea.climateadapt.indicator': IndicatorView,
246
254
  'eea.climateadapt.informationportal': InformationPortalView,
@@ -250,6 +258,7 @@ const applyConfig = (config) => {
250
258
  'eea.climateadapt.tool': ToolView,
251
259
  'eea.climateadapt.video': VideoView,
252
260
  'eea.climateadapt.c3sindicator': C3SIndicatorView,
261
+ 'News Item': NewsItemView,
253
262
  };
254
263
 
255
264
  config.views.layoutViewsNamesMapping.view_cca_event = 'CCA Event View';
@@ -437,6 +446,12 @@ const applyConfig = (config) => {
437
446
  // Custom widgets
438
447
  config.widgets.id.geochars = GeocharsWidget;
439
448
  config.widgets.id.geolocation = GeolocationWidget;
449
+ config.widgets.widget.creatableselect = CreatableSelectWidget;
450
+
451
+ config.blocks.blocksConfig.layoutSettings.schemaEnhancer = ({ schema }) => {
452
+ schema.properties.body_class.widget = 'creatableselect';
453
+ return schema;
454
+ };
440
455
 
441
456
  // we won't need the listing for Folders
442
457
  delete config.views.layoutViews.listing_view;
@@ -1,148 +0,0 @@
1
- export const regionCountries = [
2
- {
3
- region: 'Adriatic-Ionian Area',
4
- countries: [
5
- ['Croatia', '/countries/croatia'],
6
- ['Greece', '/countries/greece'],
7
- ['Italy', '/countries/italy'],
8
- ['Slovenia', '/countries/slovenia'],
9
- ['Albania', ''],
10
- ['Bosnia and Herzegovina', ''],
11
- ['Montenegro', ''],
12
- ['Republic of North Macedonia', ''],
13
- ['Serbia', ''],
14
- ],
15
- },
16
- {
17
- region: 'Alpine Space',
18
- countries: [
19
- ['Austria', '/countries/austria'],
20
- ['France', '/countries/france'],
21
- ['Germany', '/countries/germany'],
22
- ['Italy', '/countries/italy'],
23
- ['Slovenia', '/countries/slovenia'],
24
- ['Liechtenstein', ''],
25
- ['Switzerland', '/countries/switzerland'],
26
- ],
27
- },
28
- {
29
- region: 'Northern Periphery and Arctic',
30
- countries: [
31
- ['Finland', '/countries/finland'],
32
- ['Ireland', '/countries/ireland'],
33
- ['Sweden', '/countries/sweden'],
34
- ['Iceland', '/countries/iceland'],
35
- ['Norway', '/countries/norway'],
36
- ['Greenland', ''],
37
- ['Faroe Islands', ''],
38
- ],
39
- },
40
- {
41
- region: 'Atlantic Area',
42
- countries: [
43
- ['France', '/countries/france'],
44
- ['Ireland', '/countries/ireland'],
45
- ['Portugal', '/countries/portugal'],
46
- ['Spain', '/countries/spain'],
47
- ],
48
- },
49
- {
50
- region: 'Baltic Sea',
51
- countries: [
52
- ['Denmark', '/countries/denmark'],
53
- ['Estonia', '/countries/estonia'],
54
- ['Finland', '/countries/finland'],
55
- ['Germany', '/countries/germany'],
56
- ['Latvia', '/countries/latvia'],
57
- ['Lithuania', '/countries/lithuania'],
58
- ['Poland', '/countries/poland'],
59
- ['Sweden', '/countries/sweden'],
60
- ['Norway', '/countries/norway'],
61
- ],
62
- },
63
- {
64
- region: 'Central Europe',
65
- countries: [
66
- ['Austria', '/countries/austria'],
67
- ['Croatia', '/countries/croatia'],
68
- ['Czechia', '/countries/czech-republic'],
69
- ['Germany', '/countries/germany'],
70
- ['Hungary', '/countries/hungary'],
71
- ['Italy', '/countries/italy'],
72
- ['Poland', '/countries/poland'],
73
- ['Slovakia', '/countries/slovakia'],
74
- ['Slovenia', '/countries/slovenia'],
75
- ],
76
- },
77
- {
78
- region: 'Danube Area',
79
- countries: [
80
- ['Austria', '/countries/austria'],
81
- ['Bulgaria', '/countries/bulgaria'],
82
- ['Croatia', '/countries/croatia'],
83
- ['Czechia', '/countries/czech-republic'],
84
- ['Germany', '/countries/germany'],
85
- ['Hungary', '/countries/hungary'],
86
- ['Romania', '/countries/romania'],
87
- ['Slovakia', '/countries/slovakia'],
88
- ['Slovenia', '/countries/slovenia'],
89
- ['Bosnia and Herzegovina, ', ''],
90
- ['Montenegro', ''],
91
- ['Serbia', ''],
92
- ['Ukraine', ''],
93
- ['Republic of Moldova', ''],
94
- ],
95
- },
96
- {
97
- region: 'Mediterranean Area',
98
- countries: [
99
- ['Albania', ''],
100
- ['Bosnia and Herzegovina', ''],
101
- ['Bulgaria', '/countries/bulgaria'],
102
- ['Croatia', '/countries/croatia'],
103
- ['Cyprus', '/countries/cyprus'],
104
- ['France', '/countries/france'],
105
- ['Greece', '/countries/greece'],
106
- ['Italy', '/countries/italy'],
107
- ['Malta', '/countries/malta'],
108
- ['Montenegro', ''],
109
- ['Portugal', '/countries/portugal'],
110
- ['Republic of North Macedonia', ''],
111
- ['Slovenia', '/countries/slovenia'],
112
- ['Spain', '/countries/spain'],
113
- ],
114
- },
115
- {
116
- region: 'North Sea Region',
117
- countries: [
118
- ['Belgium', '/countries/belgium'],
119
- ['Denmark', '/countries/denmark'],
120
- ['Germany', '/countries/germany'],
121
- ['France', '/countries/france'],
122
- ['Netherlands', '/countries/netherlands'],
123
- ['Sweden', '/countries/sweden'],
124
- ['Norway', '/countries/norway'],
125
- ],
126
- },
127
- {
128
- region: 'North-West Europe',
129
- countries: [
130
- ['Belgium', '/countries/belgium'],
131
- ['France', '/countries/france'],
132
- ['Germany', '/countries/germany'],
133
- ['Ireland', '/countries/ireland'],
134
- ['Luxembourg', '/countries/luxembourg'],
135
- ['Netherlands', '/countries/netherlands'],
136
- ['Switzerland', '/countries/switzerland'],
137
- ],
138
- },
139
- {
140
- region: 'South-West Europe',
141
- countries: [
142
- ['France', '/countries/france'],
143
- ['Portugal', '/countries/portugal'],
144
- ['Spain', '/countries/spain'],
145
- ['Andorra', ''],
146
- ],
147
- },
148
- ];