@eeacms/volto-cca-policy 0.1.17 → 0.1.18

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,7 +4,27 @@ 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.17](https://github.com/eea/volto-cca-policy/compare/0.1.16...0.1.17) - 28 April 2023
7
+ ### [0.1.18](https://github.com/eea/volto-cca-policy/compare/0.1.17...0.1.18) - 16 May 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Small Improvement on region select [kreafox - [`1221718`](https://github.com/eea/volto-cca-policy/commit/1221718978f8b20e6cf58bb984f9c9d85b691e83)]
12
+ - Fix region name [kreafox - [`aa8b266`](https://github.com/eea/volto-cca-policy/commit/aa8b26631cf104fabe1a0040a4c0b52f5d5650ca)]
13
+ - Fix case on other regions [kreafox - [`fac6535`](https://github.com/eea/volto-cca-policy/commit/fac653548863808958b422ce669878d1e50d9797)]
14
+ - Fix regions name [kreafox - [`5107f8b`](https://github.com/eea/volto-cca-policy/commit/5107f8b25add8b647debcaa032b9224b147fe6e6)]
15
+ - Refs #252182 - Get rid of listing custom organisation cards. [GhitaB - [`467faaf`](https://github.com/eea/volto-cca-policy/commit/467faafafe3692da58a85a7af95bd508114f7689)]
16
+ - Fix mobile menu background color [kreafox - [`ae00bd8`](https://github.com/eea/volto-cca-policy/commit/ae00bd877f6d2c62fcc6fad13e3151850003aa3e)]
17
+ - Refs #252182 - WIP Custom listing variation for organisation cards. [GhitaB - [`2ebca9a`](https://github.com/eea/volto-cca-policy/commit/2ebca9a3a45ba4f20ebc29b27d9f1a626611760c)]
18
+ - Refs #252182 - WIP Custom listing variation for organisation cards. [GhitaB - [`c638573`](https://github.com/eea/volto-cca-policy/commit/c63857327c582a9dace952e8cabf902096f8ff09)]
19
+ - Fix region name [kreafox - [`6baa26a`](https://github.com/eea/volto-cca-policy/commit/6baa26a32ebdb0c7ec5d91007abcb0e7d206c3f2)]
20
+ - Add trans region select block [kreafox - [`b95f6b3`](https://github.com/eea/volto-cca-policy/commit/b95f6b3cca8075a7a1e6a23ee14010a2d5a07d5b)]
21
+ - Fix macro regions [kreafox - [`388b443`](https://github.com/eea/volto-cca-policy/commit/388b4438b812a42e0f7be1e3d8b023befc21b5ab)]
22
+ - Set default nr of items [kreafox - [`286e83b`](https://github.com/eea/volto-cca-policy/commit/286e83b1cd17d31e749b58583fbe4efcaee47fe2)]
23
+ - Filter block styling [kreafox - [`b718171`](https://github.com/eea/volto-cca-policy/commit/b718171d429e011d372008a8a38de456066915d1)]
24
+ - Code cleanup [kreafox - [`be09233`](https://github.com/eea/volto-cca-policy/commit/be092333735f9c50c1fdcbdcbfdc28f8a3056350)]
25
+ - Make itemModel work [Tiberiu Ichim - [`8fed2bc`](https://github.com/eea/volto-cca-policy/commit/8fed2bce3f777b705ebca06abd58826f744530c3)]
26
+ - WIP filter ace content block [kreafox - [`3f8b97e`](https://github.com/eea/volto-cca-policy/commit/3f8b97e62bb8bb5c93e4b26b61c982efdb5a47c7)]
27
+ ### [0.1.17](https://github.com/eea/volto-cca-policy/compare/0.1.16...0.1.17) - 2 May 2023
8
28
 
9
29
  #### :hammer_and_wrench: Others
10
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
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,17 +1,50 @@
1
1
  import React from 'react';
2
-
2
+ import { useSelector, useDispatch } from 'react-redux';
3
+ import { getVocabulary } from '@plone/volto/actions';
3
4
  import { SidebarPortal } from '@plone/volto/components';
4
5
  import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
5
-
6
- import schema from './schema';
6
+ import { BIOREGIONS, OTHER_REGIONS } from '@eeacms/volto-cca-policy/helpers';
7
+ import FilterSchema from './schema';
7
8
  import FilterAceContentView from './FilterAceContentView';
8
9
 
10
+ const REGIONS = 'eea.climateadapt.regions';
11
+
12
+ const getMacroRegions = (regions, bioregions) => {
13
+ const macro_regions = [[OTHER_REGIONS, OTHER_REGIONS]];
14
+ regions.forEach((region) => {
15
+ Object.entries(bioregions).forEach(([k, v]) => {
16
+ if (region.label === v) {
17
+ macro_regions.push([k, region.label]);
18
+ }
19
+ });
20
+ });
21
+
22
+ return macro_regions;
23
+ };
24
+
9
25
  export default function RelevantAceContentEdit(props) {
10
- const { block, data, onChangeBlock, selected, id } = props;
26
+ const { block, data, onChangeBlock, selected, id, pathname } = props;
27
+ const dispatch = useDispatch();
28
+
29
+ const regionsVocabItems = useSelector((state) =>
30
+ state.vocabularies[REGIONS]?.loaded
31
+ ? state.vocabularies[REGIONS].items
32
+ : [],
33
+ );
34
+
35
+ React.useEffect(() => {
36
+ const action = getVocabulary({
37
+ vocabNameOrURL: REGIONS,
38
+ });
39
+ dispatch(action);
40
+ }, [dispatch]);
41
+
42
+ const macro_regions = getMacroRegions(regionsVocabItems, BIOREGIONS);
43
+ const schema = FilterSchema(data, macro_regions);
11
44
 
12
45
  return (
13
46
  <div>
14
- <FilterAceContentView data={data} id={id} mode="edit" />
47
+ <FilterAceContentView data={data} id={id} mode="edit" path={pathname} />
15
48
  <SidebarPortal selected={selected}>
16
49
  <BlockDataForm
17
50
  block={block}
@@ -1,38 +1,209 @@
1
1
  import React from 'react';
2
- // import { List } from 'semantic-ui-react';
3
- // import { Link } from 'react-router-dom';
4
- // import { flattenToAppURL } from '@plone/volto/helpers';
2
+ import loadable from '@loadable/component';
5
3
  import ListingBody from '@plone/volto/components/manage/Blocks/Listing/ListingBody';
4
+ import { useSelector, useDispatch } from 'react-redux';
5
+ import { getVocabulary } from '@plone/volto/actions';
6
+ import { OTHER_REGIONS } from '@eeacms/volto-cca-policy/helpers';
7
+ import {
8
+ Option,
9
+ DropdownIndicator,
10
+ selectTheme,
11
+ customSelectStyles,
12
+ } from '@plone/volto/components/manage/Widgets/SelectStyling';
6
13
 
7
- const FilterAceContentView = (props) => {
8
- const { data, id, mode = 'view' } = props;
9
- // const { title } = data;
10
- // const results = _v_results || [];
11
- const queryData = {
14
+ import './style.less';
15
+
16
+ const Select = loadable(() => import('react-select'));
17
+
18
+ const IMPACTS = 'eea.climateadapt.aceitems_climateimpacts';
19
+ const SECTORS = 'eea.climateadapt.aceitems_sectors';
20
+
21
+ const FIELDS = [
22
+ 'bio_regions',
23
+ 'countries',
24
+ 'element_type',
25
+ 'funding_programme',
26
+ 'macro_regions',
27
+ 'origin_website',
28
+ 'search_text',
29
+ 'search_type',
30
+ 'sector',
31
+ 'special_tags',
32
+ ];
33
+
34
+ const fieldmap = {
35
+ origin_website: 'origin_website',
36
+ search_type: 'search_type',
37
+ element_type: 'elements',
38
+ search_text: 'SearchableText',
39
+ special_tags: 'special_tags',
40
+ sector: 'sectors',
41
+ countries: 'countries',
42
+ macro_regions: 'macro_regions',
43
+ bio_regions: 'bio_regions',
44
+ funding_programme: 'funding_programme',
45
+ };
46
+
47
+ const otherMacroRegions = [
48
+ 'TRANS_BIO_MACARO',
49
+ 'TRANS_MACRO_CAR_AREA',
50
+ 'TRANS_MACRO_AMAZONIA',
51
+ 'TRANS_BIO_ANATOLIAN',
52
+ 'TRANS_MACRO_IND_OCEAN_AREA',
53
+ ];
54
+
55
+ const impacts_no_value = [
56
+ {
57
+ label: 'All climate impacts',
58
+ value: '',
59
+ },
60
+ ];
61
+
62
+ const sectors_no_value = [
63
+ {
64
+ label: 'All adaptation sectors',
65
+ value: '',
66
+ },
67
+ ];
68
+
69
+ const applyQuery = (id, data, currentLang, impacts, sectors) => {
70
+ const defaultQuery = Object.entries(data)
71
+ .filter(
72
+ ([field, value]) => FIELDS.includes(field) && value && value.length > 0,
73
+ )
74
+ .map(([field, value]) => {
75
+ let values = [];
76
+ if (value.includes(OTHER_REGIONS)) {
77
+ values = [...value, ...otherMacroRegions];
78
+ values.splice(values.indexOf(OTHER_REGIONS), 1);
79
+ } else {
80
+ values = value;
81
+ }
82
+
83
+ return {
84
+ i: fieldmap[field],
85
+ o: 'plone.app.querystring.operation.selection.any',
86
+ v: values,
87
+ };
88
+ });
89
+
90
+ defaultQuery.push({
91
+ i: 'Language',
92
+ o: 'plone.app.querystring.operation.selection.any',
93
+ v: currentLang,
94
+ });
95
+
96
+ if (impacts) defaultQuery.push(impacts);
97
+ if (sectors) defaultQuery.push(sectors);
98
+
99
+ return {
12
100
  block: id,
13
- querystring: {
14
- query: [
15
- {
16
- i: 'portal_type',
17
- o: 'plone.app.querystring.operation.selection.any',
18
- v: ['Document'],
19
- },
20
- ],
21
- },
22
- sort_order: 'ascending',
101
+ limit: data.nr_items,
102
+ query: defaultQuery,
103
+ sort_on: data.sortBy,
104
+ sort_order: 'descending',
105
+ template: 'summary',
106
+ itemModel: { '@type': 'simpleItem' },
23
107
  };
108
+ };
109
+
110
+ const FilterAceContentView = (props) => {
111
+ const { data, id, mode = 'view' } = props;
112
+ const dispatch = useDispatch();
113
+ const currentLang = useSelector((state) => state.intl.locale);
114
+ const impactsVocabItems = useSelector((state) =>
115
+ state.vocabularies[IMPACTS]?.loaded
116
+ ? state.vocabularies[IMPACTS].items
117
+ : [],
118
+ );
119
+ const sectorsVocabItems = useSelector((state) =>
120
+ state.vocabularies[SECTORS]?.loaded
121
+ ? state.vocabularies[SECTORS].items
122
+ : [],
123
+ );
124
+
125
+ const [impactsQuery, setImpactsQueryQuery] = React.useState();
126
+ const [sectorsQuery, setSectorsQuery] = React.useState();
127
+
128
+ React.useEffect(() => {
129
+ const action = getVocabulary({
130
+ vocabNameOrURL: IMPACTS,
131
+ });
132
+ dispatch(action);
133
+ }, [dispatch]);
134
+
135
+ React.useEffect(() => {
136
+ const action = getVocabulary({
137
+ vocabNameOrURL: SECTORS,
138
+ });
139
+ dispatch(action);
140
+ }, [dispatch]);
141
+
142
+ const listingBodyData = applyQuery(
143
+ id,
144
+ data,
145
+ currentLang,
146
+ impactsQuery,
147
+ sectorsQuery,
148
+ );
24
149
 
25
150
  return (
26
151
  <div className="block filter-acecontent-block">
27
- Filter ace content view
28
152
  {data.title && <h4>{data.title}</h4>}
29
- <ListingBody
30
- id={id}
31
- data={queryData}
32
- path={props.path}
33
- isEditMode={mode === 'edit'}
34
- variation={null}
153
+ <Select
154
+ id="field-impacts"
155
+ name="impacts"
156
+ disabled={false}
157
+ className="react-select-container"
158
+ classNamePrefix="react-select"
159
+ options={[impacts_no_value[0], ...(impactsVocabItems || [])]}
160
+ styles={customSelectStyles}
161
+ theme={selectTheme}
162
+ components={{ DropdownIndicator, Option }}
163
+ defaultValue={impacts_no_value}
164
+ onChange={({ value }) => {
165
+ if (value) {
166
+ setImpactsQueryQuery({
167
+ i: 'climate_impacts',
168
+ o: 'plone.app.querystring.operation.selection.any',
169
+ v: value,
170
+ });
171
+ } else {
172
+ setImpactsQueryQuery(null);
173
+ }
174
+ }}
175
+ />
176
+ <Select
177
+ id="field-sectors"
178
+ name="sectors"
179
+ disabled={false}
180
+ className="react-select-container"
181
+ classNamePrefix="react-select"
182
+ options={[sectors_no_value[0], ...(sectorsVocabItems || [])]}
183
+ styles={customSelectStyles}
184
+ theme={selectTheme}
185
+ components={{ DropdownIndicator, Option }}
186
+ defaultValue={sectors_no_value}
187
+ onChange={({ value }) => {
188
+ if (value) {
189
+ setSectorsQuery({
190
+ i: 'sectors',
191
+ o: 'plone.app.querystring.operation.selection.any',
192
+ v: value,
193
+ });
194
+ } else {
195
+ setSectorsQuery(null);
196
+ }
197
+ }}
35
198
  />
199
+ <div className="listing-wrapper">
200
+ <ListingBody
201
+ id={id}
202
+ data={listingBodyData}
203
+ path={props.path}
204
+ isEditMode={mode === 'edit'}
205
+ />
206
+ </div>
36
207
  </div>
37
208
  );
38
209
  };
@@ -5,7 +5,7 @@ import FilterAceContentView from './FilterAceContentView';
5
5
  export default function installBlock(config) {
6
6
  config.blocks.blocksConfig.filterAceContent = {
7
7
  id: 'filterAceContent',
8
- title: 'Filter Ace Content',
8
+ title: 'Filter AceContent',
9
9
  icon: zoomSVG,
10
10
  group: 'site',
11
11
  view: FilterAceContentView,
@@ -1,112 +1,117 @@
1
- export default {
2
- title: 'Filter Ace Content',
3
- fieldsets: [
4
- {
5
- id: 'default',
6
- title: 'Default',
7
- fields: [
8
- 'title',
9
- 'search_text',
10
- 'origin_website',
11
- 'search_type',
12
- 'element_type',
13
- 'sector',
14
- 'special_tags',
15
- 'countries',
16
- 'macro_regions',
17
- 'bio_regions',
18
- 'funding_programme',
19
- 'nr_items',
20
- ],
21
- },
22
- ],
23
- properties: {
24
- title: {
25
- title: 'Block title',
26
- },
27
- search_text: {
28
- title: 'Search text',
29
- },
30
- origin_website: {
31
- title: 'Origin website',
32
- widget: 'array',
33
- vocabulary: {
34
- '@id': 'eea.climateadapt.funding_programme',
1
+ const FilterSchema = (data, macro_regions) => {
2
+ return {
3
+ title: 'Filter Ace Content',
4
+ fieldsets: [
5
+ {
6
+ id: 'default',
7
+ title: 'Default',
8
+ fields: [
9
+ 'title',
10
+ 'search_text',
11
+ 'origin_website',
12
+ 'search_type',
13
+ 'element_type',
14
+ 'sector',
15
+ 'special_tags',
16
+ 'countries',
17
+ 'macro_regions',
18
+ 'bio_regions',
19
+ 'funding_programme',
20
+ 'nr_items',
21
+ ],
35
22
  },
36
- },
37
- search_type: {
38
- title: 'Aceitem type',
39
- widget: 'array',
40
- vocabulary: {
41
- '@id': 'eea.climateadapt.search_types_vocabulary',
23
+ ],
24
+ properties: {
25
+ title: {
26
+ title: 'Block title',
42
27
  },
43
- },
44
- element_type: {
45
- title: 'Element type',
46
- widget: 'array',
47
- vocabulary: {
48
- '@id': 'eea.climateadapt.element_types_vocabulary',
28
+ search_text: {
29
+ title: 'Search text',
49
30
  },
50
- },
51
- sector: {
52
- title: 'Sector',
53
- widget: 'array',
54
- vocabulary: {
55
- '@id': 'eea.climateadapt.aceitems_sectors',
31
+ origin_website: {
32
+ title: 'Origin website',
33
+ widget: 'array',
34
+ vocabulary: {
35
+ '@id': 'eea.climateadapt.origin_website',
36
+ },
56
37
  },
57
- },
58
- special_tags: {
59
- title: 'Special tags',
60
- widget: 'array',
61
- vocabulary: {
62
- '@id': 'eea.climateadapt.special_tags',
38
+ search_type: {
39
+ title: 'Aceitem type',
40
+ widget: 'array',
41
+ vocabulary: {
42
+ '@id': 'eea.climateadapt.search_types_vocabulary',
43
+ },
63
44
  },
64
- },
65
- countries: {
66
- title: 'Countries',
67
- widget: 'array',
68
- vocabulary: {
69
- '@id': 'eea.climateadapt.ace_countries',
45
+ element_type: {
46
+ title: 'Element type',
47
+ widget: 'array',
48
+ vocabulary: {
49
+ '@id': 'eea.climateadapt.element_types_vocabulary',
50
+ },
70
51
  },
71
- },
72
- macro_regions: {
73
- title: 'Macro-Transnational Regions',
74
- widget: 'array',
75
- vocabulary: {
76
- '@id': 'eea.climateadapt.regions',
52
+ sector: {
53
+ title: 'Sector',
54
+ widget: 'array',
55
+ vocabulary: {
56
+ '@id': 'eea.climateadapt.aceitems_sectors',
57
+ },
77
58
  },
78
- },
79
- bio_regions: {
80
- title: 'Biogeographical Regions',
81
- widget: 'array',
82
- vocabulary: {
83
- '@id': 'eea.climateadapt.bioregions',
59
+ special_tags: {
60
+ title: 'Special tags',
61
+ widget: 'array',
62
+ vocabulary: {
63
+ '@id': 'eea.climateadapt.special_tags',
64
+ },
84
65
  },
85
- },
86
- funding_programme: {
87
- title: 'Funding programmes',
88
- type: 'choice',
89
- vocabulary: {
90
- '@id': 'eea.climateadapt.funding_programme',
66
+ countries: {
67
+ title: 'Countries',
68
+ widget: 'array',
69
+ vocabulary: {
70
+ '@id': 'eea.climateadapt.ace_countries',
71
+ },
72
+ },
73
+ macro_regions: {
74
+ title: 'Macro-Transnational Regions',
75
+ widget: 'array',
76
+ vocabulary: {
77
+ '@id': 'eea.climateadapt.regions',
78
+ },
79
+ choices: macro_regions, // override to set correct values
80
+ },
81
+ bio_regions: {
82
+ title: 'Biogeographical Regions',
83
+ widget: 'array',
84
+ vocabulary: {
85
+ '@id': 'eea.climateadapt.bioregions',
86
+ },
87
+ },
88
+ funding_programme: {
89
+ title: 'Funding programmes',
90
+ type: 'choice',
91
+ vocabulary: {
92
+ '@id': 'eea.climateadapt.funding_programme',
93
+ },
94
+ },
95
+ nr_items: {
96
+ title: 'Nr of items to show',
97
+ type: 'number',
98
+ default: '5',
99
+ },
100
+ sortBy: {
101
+ title: 'Sort by',
102
+ description: 'Sort order for results and assigned items',
103
+ choices: [
104
+ ['modified', 'Last Modified'],
105
+ ['effective', 'Last Published'],
106
+ ['getId', 'Alphabetical sorting'],
107
+ ],
108
+ // vocabulary: {
109
+ // '@id': 'sortby_vocabulary',
110
+ // },
91
111
  },
92
112
  },
93
- nr_items: {
94
- title: 'Nr of items to show',
95
- type: 'number',
96
- default: '0',
97
- },
98
- sortBy: {
99
- title: 'Sort by',
100
- description: 'Sort order for results and assigned items',
101
- choices: [
102
- ['MODIFIED', 'Last Modified'],
103
- ['EFFECTIVE', 'Last Published'],
104
- ['NAME', 'Alphabetical sorting'],
105
- ],
106
- // vocabulary: {
107
- // '@id': 'sortby_vocabulary',
108
- // },
109
- },
110
- },
111
- required: [],
113
+ required: [],
114
+ };
112
115
  };
116
+
117
+ export default FilterSchema;
@@ -0,0 +1,3 @@
1
+ .listing-wrapper {
2
+ margin-top: 1.5em;
3
+ }
@@ -5,15 +5,12 @@ import { flattenToAppURL } from '@plone/volto/helpers';
5
5
 
6
6
  const RelevantAceContentView = (props) => {
7
7
  const { data } = props;
8
- const { title, _v_results, items, combine_results } = data;
8
+ const { title, _v_results, items = [], combine_results } = data;
9
9
  const results = _v_results || [];
10
10
 
11
- // console.log(data);
12
-
13
11
  return (
14
12
  <div className="block relevant-acecontent-block">
15
13
  {title && <h4>{title}</h4>}
16
-
17
14
  {combine_results ? (
18
15
  <>
19
16
  {(items || []).map((item, index) => (
@@ -49,6 +46,7 @@ const RelevantAceContentView = (props) => {
49
46
  )}
50
47
  </>
51
48
  )}
49
+ {results.length === 0 && items.length === 0 && <div>No items</div>}
52
50
  </div>
53
51
  );
54
52
  };
@@ -5,7 +5,7 @@ import RelevantAceContentView from './RelevantAceContentView';
5
5
  export default function installBlock(config) {
6
6
  config.blocks.blocksConfig.relevantAceContent = {
7
7
  id: 'relevantAceContent',
8
- title: 'Relevant acecontent',
8
+ title: 'Relevant AceContent',
9
9
  icon: zoomSVG,
10
10
  group: 'site',
11
11
  view: RelevantAceContentView,
@@ -128,7 +128,7 @@ export default {
128
128
  nr_items: {
129
129
  title: 'Nr of items to show',
130
130
  type: 'number',
131
- default: '0',
131
+ default: '5',
132
132
  },
133
133
  show_share_btn: {
134
134
  title: 'Show the share button',
@@ -6,8 +6,6 @@ export default function SearchAceContentView(props) {
6
6
  const { data } = props;
7
7
  const results = data._v_results || [];
8
8
 
9
- // console.log(data);
10
-
11
9
  return results && results.length > 0 ? (
12
10
  <div className="block search-acecontent-block">
13
11
  {data.title && <h4>{data.title}</h4>}
@@ -93,7 +93,7 @@ export default {
93
93
  nr_items: {
94
94
  title: 'Nr of items to show',
95
95
  type: 'number',
96
- default: '0',
96
+ default: '5',
97
97
  },
98
98
  },
99
99
  required: [],
@@ -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 schema from './schema';
7
+ import TransRegionSelectView from './TransRegionSelectView';
8
+
9
+ export default function TransRegionSelectEdit(props) {
10
+ const { block, data, onChangeBlock, selected, id } = props;
11
+
12
+ return (
13
+ <div>
14
+ <TransRegionSelectView 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,124 @@
1
+ import React from 'react';
2
+ import { compose } from 'redux';
3
+ import { Link } from 'react-router-dom';
4
+ import { Dropdown } from 'semantic-ui-react';
5
+ import { connect, useDispatch, useSelector } from 'react-redux';
6
+ import { getQueryStringResults } from '@plone/volto/actions';
7
+ import { regionCountries } from './countries';
8
+
9
+ const getSiblings = (items) => {
10
+ const regionsDropdown = (items || []).map((item) => {
11
+ return {
12
+ key: item.title,
13
+ value: item.title,
14
+ text: item.title,
15
+ as: Link,
16
+ to: item['@id'],
17
+ };
18
+ });
19
+
20
+ regionsDropdown.sort((a, b) =>
21
+ a.text < b.text ? -1 : a.text > b.text ? 1 : 0,
22
+ );
23
+
24
+ return regionsDropdown;
25
+ };
26
+
27
+ const TransRegionSelectView = (props) => {
28
+ const { id, data, content } = props;
29
+ const { title } = content;
30
+ const dispatch = useDispatch();
31
+ const querystringResults = useSelector(
32
+ (state) => state.querystringsearch.subrequests,
33
+ );
34
+ const currentLang = useSelector((state) => state.intl.locale);
35
+ const regions = getSiblings(querystringResults[id]?.items);
36
+ const otherRegionsCoverTitle =
37
+ 'EU outermost regions and the overseas countries and territories';
38
+
39
+ React.useEffect(() => {
40
+ dispatch(
41
+ getQueryStringResults(
42
+ '/',
43
+ {
44
+ b_start: 0,
45
+ b_size: 10000,
46
+ limit: 10000,
47
+ query: [
48
+ {
49
+ i: 'path',
50
+ o: 'plone.app.querystring.operation.string.relativePath',
51
+ v: '/en/countries-regions/transnational-regions/::1',
52
+ },
53
+ {
54
+ i: 'object_provides',
55
+ o: 'plone.app.querystring.operation.selection.any',
56
+ v: 'eea.climateadapt.interfaces.ITransnationalRegionMarker',
57
+ },
58
+ {
59
+ i: 'review_state',
60
+ o: 'plone.app.querystring.operation.selection.any',
61
+ v: 'published',
62
+ },
63
+ ],
64
+ },
65
+ id,
66
+ ),
67
+ );
68
+ }, [dispatch, id]);
69
+
70
+ const defaultValue =
71
+ title === otherRegionsCoverTitle ? 'Other regions' : title;
72
+
73
+ return (
74
+ <div className="block">
75
+ {data.title && <h5>{data.title}</h5>}
76
+ <Dropdown
77
+ selection
78
+ text="Choose a region"
79
+ options={regions}
80
+ defaultValue={defaultValue}
81
+ icon="angle down"
82
+ />
83
+ <p></p>
84
+ <div className="countries">
85
+ {title === otherRegionsCoverTitle ||
86
+ title === 'Other regions' ? null : (
87
+ <h5>Region's countries:</h5>
88
+ )}
89
+ {regionCountries
90
+ .filter((item) => item.region === title)
91
+ .map((item, i) => (
92
+ <div className="countries-listing" key={i}>
93
+ {item.countries.map((country, i) => {
94
+ const url = `/${currentLang}${country[1]}`;
95
+ return (
96
+ <React.Fragment key={i}>
97
+ {country[1].length > 0 ? (
98
+ <Link to={url}>
99
+ <span>
100
+ {country[0]}
101
+ {i < item.countries.length - 1 ? ', ' : ''}
102
+ </span>
103
+ </Link>
104
+ ) : (
105
+ <span>
106
+ {country[0]}
107
+ {i < item.countries.length - 1 ? ', ' : ''}
108
+ </span>
109
+ )}
110
+ </React.Fragment>
111
+ );
112
+ })}
113
+ </div>
114
+ ))}
115
+ </div>
116
+ </div>
117
+ );
118
+ };
119
+
120
+ export default compose(
121
+ connect((state, props) => ({
122
+ content: state.content.data,
123
+ })),
124
+ )(TransRegionSelectView);
@@ -0,0 +1,170 @@
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
+ // ['United Kingdom', '/countries/united-kingdom'],
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
+ // ['United Kingdom', '/countries/united-kingdom'],
49
+ ],
50
+ },
51
+ // {
52
+ // region: 'Balkan-Mediterranean',
53
+ // countries: [
54
+ // ['Bulgaria', '/countries/bulgaria'],
55
+ // ['Cyprus', '/countries/cyprus'],
56
+ // ['Greece', '/countries/greece'],
57
+ // ['Albania', ''],
58
+ // ['Republic of North Macedonia', ''],
59
+ // ],
60
+ // },
61
+ {
62
+ region: 'Baltic Sea',
63
+ countries: [
64
+ ['Denmark', '/countries/denmark'],
65
+ ['Estonia', '/countries/estonia'],
66
+ ['Finland', '/countries/finland'],
67
+ ['Germany', '/countries/germany'],
68
+ ['Latvia', '/countries/latvia'],
69
+ ['Lithuania', '/countries/lithuania'],
70
+ ['Poland', '/countries/poland'],
71
+ ['Sweden', '/countries/sweden'],
72
+ ['Norway', '/countries/norway'],
73
+ // ['Russia', ''],
74
+ // ['Belarus', ''],
75
+ ],
76
+ },
77
+ {
78
+ region: 'Central Europe',
79
+ countries: [
80
+ ['Austria', '/countries/austria'],
81
+ ['Croatia', '/countries/croatia'],
82
+ ['Czechia', '/countries/czech-republic'],
83
+ ['Germany', '/countries/germany'],
84
+ ['Hungary', '/countries/hungary'],
85
+ ['Italy', '/countries/italy'],
86
+ ['Poland', '/countries/poland'],
87
+ ['Slovakia', '/countries/slovakia'],
88
+ ['Slovenia', '/countries/slovenia'],
89
+ ],
90
+ },
91
+ {
92
+ region: 'Danube Area',
93
+ countries: [
94
+ ['Austria', '/countries/austria'],
95
+ ['Bulgaria', '/countries/bulgaria'],
96
+ ['Croatia', '/countries/croatia'],
97
+ ['Czechia', '/countries/czech-republic'],
98
+ ['Germany', '/countries/germany'],
99
+ ['Hungary', '/countries/hungary'],
100
+ ['Romania', '/countries/romania'],
101
+ ['Slovakia', '/countries/slovakia'],
102
+ ['Slovenia', '/countries/slovenia'],
103
+ ['Bosnia and Herzegovina, ', ''],
104
+ ['Montenegro', ''],
105
+ ['Serbia', ''],
106
+ ['Ukraine', ''],
107
+ ['Republic of Moldova', ''],
108
+ ],
109
+ },
110
+ {
111
+ region: 'Mediterranean Area',
112
+ countries: [
113
+ ['Albania', ''],
114
+ ['Bosnia and Herzegovina', ''],
115
+ ['Bulgaria', '/countries/bulgaria'],
116
+ ['Croatia', '/countries/croatia'],
117
+ ['Cyprus', '/countries/cyprus'],
118
+ ['France', '/countries/france'],
119
+ ['Greece', '/countries/greece'],
120
+ ['Italy', '/countries/italy'],
121
+ ['Malta', '/countries/malta'],
122
+ ['Montenegro', ''],
123
+ ['Portugal', '/countries/portugal'],
124
+ ['Republic of North Macedonia', ''],
125
+ ['Slovenia', '/countries/slovenia'],
126
+ ['Spain', '/countries/spain'],
127
+ // ['United Kingdom', '/countries/united-kingdom'],
128
+ ],
129
+ },
130
+ {
131
+ region: 'North Sea Region',
132
+ countries: [
133
+ ['Belgium', '/countries/belgium'],
134
+ ['Denmark', '/countries/denmark'],
135
+ ['Germany', '/countries/germany'],
136
+ ['France', '/countries/france'],
137
+ ['Netherlands', '/countries/netherlands'],
138
+ ['Sweden', '/countries/sweden'],
139
+ // ['United Kingdom', '/countries/united-kingdom'],
140
+ ['Norway', '/countries/norway'],
141
+ ],
142
+ },
143
+ {
144
+ region: 'North-West Europe',
145
+ countries: [
146
+ ['Belgium', '/countries/belgium'],
147
+ ['France', '/countries/france'],
148
+ ['Germany', '/countries/germany'],
149
+ ['Ireland', '/countries/ireland'],
150
+ ['Luxembourg', '/countries/luxembourg'],
151
+ ['Netherlands', '/countries/netherlands'],
152
+ ['Switzerland', '/countries/switzerland'],
153
+ // ['United Kingdom', '/countries/united-kingdom'],
154
+ ],
155
+ },
156
+ {
157
+ region: 'South-West Europe',
158
+ countries: [
159
+ ['France', '/countries/france'],
160
+ ['Portugal', '/countries/portugal'],
161
+ ['Spain', '/countries/spain'],
162
+ // ['United Kingdom', '/countries/united-kingdom'],
163
+ ['Andorra', ''],
164
+ ],
165
+ },
166
+ // {
167
+ // region: 'Other regions',
168
+ // countries: [],
169
+ // },
170
+ ];
@@ -0,0 +1,22 @@
1
+ import zoomSVG from '@plone/volto/icons/zoom.svg';
2
+ import TransRegionSelectEdit from './TransRegionSelectEdit';
3
+ import TransRegionSelectView from './TransRegionSelectView';
4
+
5
+ export default function installBlock(config) {
6
+ config.blocks.blocksConfig.transRegionSelect = {
7
+ id: 'transRegionSelect',
8
+ title: 'Trans Region Select',
9
+ icon: zoomSVG,
10
+ group: 'site',
11
+ view: TransRegionSelectView,
12
+ edit: TransRegionSelectEdit,
13
+ sidebarTab: 1,
14
+ security: {
15
+ addPermission: [],
16
+ view: [],
17
+ },
18
+ variations: [],
19
+ };
20
+
21
+ return config;
22
+ }
@@ -0,0 +1,16 @@
1
+ export default {
2
+ title: 'Trans Region Select',
3
+ fieldsets: [
4
+ {
5
+ id: 'default',
6
+ title: 'Default',
7
+ fields: ['title'],
8
+ },
9
+ ],
10
+ properties: {
11
+ title: {
12
+ title: 'Block title',
13
+ },
14
+ },
15
+ required: [],
16
+ };
@@ -5,6 +5,7 @@ import installCaseStudyExplorerBlock from './CaseStudyExplorer';
5
5
  import installSearchAceContent from './SearchAceContent';
6
6
  import installRelevantAceContent from './RelevantAceContent';
7
7
  import installFilterAceContent from './FilterAceContent';
8
+ import installTransRegionSelect from './TransRegionSelect';
8
9
 
9
10
  export default function installBlocks(config) {
10
11
  config.blocks.blocksConfig.title.restricted = false;
@@ -15,5 +16,6 @@ export default function installBlocks(config) {
15
16
  installSearchAceContent,
16
17
  installRelevantAceContent,
17
18
  installFilterAceContent,
19
+ installTransRegionSelect,
18
20
  )(config);
19
21
  }
@@ -96,6 +96,8 @@ export const BIOREGIONS = {
96
96
  TRANS_BIO_STEPPIC: 'Steppic',
97
97
  };
98
98
 
99
+ export const OTHER_REGIONS = 'Other Regions';
100
+
99
101
  export const SUBNATIONAL_REGIONS = {
100
102
  SUBN_Région_de_Bruxelles_Capit:
101
103
  'Région de Bruxelles-Capitale/Brussels Hoofdstedelijk Gewest (BE)',
@@ -15,6 +15,7 @@ export ShareInfo from './ShareInfo';
15
15
  export {
16
16
  ACE_COUNTRIES,
17
17
  BIOREGIONS,
18
+ OTHER_REGIONS,
18
19
  SUBNATIONAL_REGIONS,
19
20
  EU_COUNTRIES,
20
21
  WIDGET_COUNTRIES,
@@ -183,9 +183,18 @@ body.subsite-mkh {
183
183
  background: @green-1;
184
184
  }
185
185
 
186
+ #mega-menu {
187
+ .ui.accordion .title i,
188
+ .ui.accordion button.title i {
189
+ color: @white;
190
+ }
191
+ }
192
+
186
193
  footer,
194
+ .burger-action,
195
+ #search-box,
187
196
  #mega-menu,
188
- #search-box {
197
+ #mega-menu .ui.accordion .content {
189
198
  background: @subsiteBackgroundGradient;
190
199
  }
191
200
  }