@eeacms/volto-n2k 1.0.22 → 1.0.24

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +22 -3
  2. package/package.json +3 -2
  3. package/src/components/manage/Blocks/BodyClass/index.js +1 -1
  4. package/src/components/manage/Blocks/CddaShape/View.jsx +2 -2
  5. package/src/components/manage/Blocks/ContactBlock/styles.less +1 -1
  6. package/src/components/manage/Blocks/ExploreHabitats/View.jsx +2 -2
  7. package/src/components/manage/Blocks/ExploreSites/View.jsx +2 -2
  8. package/src/components/manage/Blocks/ExploreSpecies/View.jsx +2 -2
  9. package/src/components/manage/Blocks/HabitatDistribution/View.jsx +2 -2
  10. package/src/components/manage/Blocks/HabitatProtectedSites/View.jsx +2 -2
  11. package/src/components/manage/Blocks/HabitatsBanner/Edit.jsx +49 -0
  12. package/src/components/manage/Blocks/HabitatsBanner/View.jsx +184 -21
  13. package/src/components/manage/Blocks/HabitatsBanner/index.js +18 -11
  14. package/src/components/manage/Blocks/HabitatsBanner/schema.js +64 -5
  15. package/src/components/manage/Blocks/HabitatsBanner/style.less +184 -17
  16. package/src/components/manage/Blocks/Landing/index.js +3 -2
  17. package/src/components/manage/Blocks/Landing/style.less +3 -5
  18. package/src/components/manage/Blocks/NavigationAnchors/View.jsx +1 -1
  19. package/src/components/manage/Blocks/NavigationAnchors/styles.less +2 -0
  20. package/src/components/manage/Blocks/SiteBanner/style.less +8 -0
  21. package/src/components/manage/Blocks/SiteShape/View.jsx +1 -1
  22. package/src/components/manage/Blocks/SiteSpeciesList/style.less +1 -1
  23. package/src/components/manage/Blocks/SpeciesBanner/View.jsx +160 -100
  24. package/src/components/manage/Blocks/SpeciesBanner/style.less +161 -72
  25. package/src/components/manage/Blocks/SpeciesDistribution/View.jsx +2 -2
  26. package/src/components/manage/Blocks/SpeciesProtectedSites/View.jsx +2 -2
  27. package/src/icons/arrow-left.svg +9 -0
  28. package/src/icons/arrow-right.svg +9 -0
package/CHANGELOG.md CHANGED
@@ -4,12 +4,31 @@ 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.22](https://github.com/eea/volto-n2k/compare/1.0.21...1.0.22) - 29 March 2023
7
+ ### [1.0.24](https://github.com/eea/volto-n2k/compare/1.0.23...1.0.24) - 26 April 2023
8
+
9
+ #### :house: Internal changes
10
+
11
+ - style: fix margin-bottom position in habitat-banner-details and species-banner-details [Miu Razvan - [`4e78d69`](https://github.com/eea/volto-n2k/commit/4e78d6927829f18a91f6b409ee670b01d538dba6)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - update [Miu Razvan - [`4347ffc`](https://github.com/eea/volto-n2k/commit/4347ffc93743dbc9d5514fe1f7d6e39b73abd0c8)]
16
+ - update [Miu Razvan - [`4e8317f`](https://github.com/eea/volto-n2k/commit/4e8317ffbe459d5bc15092fa9f43255707a77e37)]
17
+ ### [1.0.23](https://github.com/eea/volto-n2k/compare/1.0.22...1.0.23) - 12 April 2023
18
+
19
+ #### :house: Internal changes
20
+
21
+ - style(HabitatsBanner): reorganize CSS properties and remove unused CSS properties [Miu Razvan - [`682ccc6`](https://github.com/eea/volto-n2k/commit/682ccc630e7f83d8084ec25cd5782315330af4ee)]
8
22
 
9
23
  #### :hammer_and_wrench: Others
10
24
 
11
- - update [Miu Razvan - [`e9a407f`](https://github.com/eea/volto-n2k/commit/e9a407fe51e6f0664f4d2d8aafd32042c9650302)]
12
- - update [Miu Razvan - [`930c7d3`](https://github.com/eea/volto-n2k/commit/930c7d3af8c8541dd83616b4131f0c1639495d70)]
25
+ - update [Miu Razvan - [`3b1f4bb`](https://github.com/eea/volto-n2k/commit/3b1f4bb0ab47baae9bf316c86f4ccaa8494a1a4d)]
26
+ - fix navigation icons svg [tedw87 - [`233255d`](https://github.com/eea/volto-n2k/commit/233255d5dcb655ef12e0ffbfdc64619f186884a5)]
27
+ - update [Miu Razvan - [`9009bc2`](https://github.com/eea/volto-n2k/commit/9009bc2bb08ddaf160bcacd57f9eefec4a487319)]
28
+ - update [Miu Razvan - [`baac43c`](https://github.com/eea/volto-n2k/commit/baac43cabbd61c44ae6513af774bffb0030a0450)]
29
+ - add habitats carousel [tedw87 - [`41861d1`](https://github.com/eea/volto-n2k/commit/41861d172884f04ef0b53ea4035c1051224dcf4e)]
30
+ ### [1.0.22](https://github.com/eea/volto-n2k/compare/1.0.21...1.0.22) - 29 March 2023
31
+
13
32
  ### [1.0.21](https://github.com/eea/volto-n2k/compare/1.0.20...1.0.21) - 22 March 2023
14
33
 
15
34
  ### [1.0.20](https://github.com/eea/volto-n2k/compare/1.0.19...1.0.20) - 22 March 2023
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-n2k",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "volto-n2k: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -33,7 +33,8 @@
33
33
  "react-stickynode": "^4.0.0",
34
34
  "react-use-localstorage": "^3.5.3",
35
35
  "resize-observer-polyfill": "1.5.1",
36
- "slick-carousel": "1.8.1"
36
+ "slick-carousel": "1.8.1",
37
+ "swiper": "9.1.1"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@cypress/code-coverage": "^3.10.0",
@@ -18,7 +18,7 @@ export default (config) => {
18
18
  addPermission: [],
19
19
  view: [],
20
20
  },
21
- blockHasOwnFocusManagement: true,
21
+ blockHasOwnFocusManagement: false,
22
22
  };
23
23
  return config;
24
24
  };
@@ -107,8 +107,8 @@ const View = (props) => {
107
107
  />
108
108
  </Map>
109
109
  </div>
110
- <Container className="map-info-notice">
111
- <Message>
110
+ <Container>
111
+ <Message className="map-info-notice shadow-none">
112
112
  <p>
113
113
  The designations employed and the presentation of material on this
114
114
  map do not imply the expression of any opinion whatsoever on the
@@ -2,7 +2,7 @@
2
2
  margin-left: 1rem;
3
3
 
4
4
  &.no-data:not(.edit) {
5
- margin-top: -1.5rem;
5
+ margin-top: -1em;
6
6
  margin-left: 0;
7
7
  }
8
8
 
@@ -165,8 +165,8 @@ const View = (props) => {
165
165
  />
166
166
  </Map>
167
167
  </div>
168
- <Container className="map-info-notice">
169
- <Message style={{ color: '#005248' }}>
168
+ <Container>
169
+ <Message className="map-info-notice" style={{ color: '#005248' }}>
170
170
  <p>
171
171
  The designations employed and the presentation of material on this
172
172
  map do not imply the expression of any opinion whatsoever on the
@@ -160,8 +160,8 @@ const View = (props) => {
160
160
  />
161
161
  </Map>
162
162
  </div>
163
- <Container className="map-info-notice">
164
- <Message style={{ color: '#005248' }}>
163
+ <Container>
164
+ <Message className="map-info-notice" style={{ color: '#005248' }}>
165
165
  <p>
166
166
  The designations employed and the presentation of material on this
167
167
  map do not imply the expression of any opinion whatsoever on the
@@ -163,8 +163,8 @@ const View = (props) => {
163
163
  />
164
164
  </Map>
165
165
  </div>
166
- <Container className="map-info-notice">
167
- <Message style={{ color: '#005248' }}>
166
+ <Container>
167
+ <Message className="map-info-notice" style={{ color: '#005248' }}>
168
168
  <p>
169
169
  The designations employed and the presentation of material on this
170
170
  map do not imply the expression of any opinion whatsoever on the
@@ -95,8 +95,8 @@ const View = (props) => {
95
95
  <Interactions pointer={false} select={false} />
96
96
  </Map>
97
97
  </div>
98
- <Container className="map-info-notice">
99
- <Message>
98
+ <Container>
99
+ <Message className="map-info-notice">
100
100
  <p>
101
101
  The designations employed and the presentation of material on this
102
102
  map do not imply the expression of any opinion whatsoever on the
@@ -95,8 +95,8 @@ const View = (props) => {
95
95
  <Interactions pointer={false} select={false} />
96
96
  </Map>
97
97
  </div>
98
- <Container className="map-info-notice">
99
- <Message>
98
+ <Container>
99
+ <Message className="map-info-notice">
100
100
  <p>
101
101
  The designations employed and the presentation of material on this
102
102
  map do not imply the expression of any opinion whatsoever on the
@@ -0,0 +1,49 @@
1
+ import React, { useMemo } from 'react';
2
+ import { compose } from 'redux';
3
+ import { SidebarPortal } from '@plone/volto/components';
4
+ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
5
+ import { VisibilitySensor } from '@eeacms/volto-datablocks/components';
6
+ import { connectToProviderData } from '@eeacms/volto-datablocks/hocs';
7
+ import getSchema from './schema';
8
+ import View from './View';
9
+ import './style.less';
10
+
11
+ const Edit = (props) => {
12
+ const schema = useMemo(() => getSchema(props), [props]);
13
+
14
+ return (
15
+ <>
16
+ <View {...props} mode="edit" />
17
+
18
+ <SidebarPortal selected={props.selected}>
19
+ <BlockDataForm
20
+ schema={schema}
21
+ title={schema.title}
22
+ onChangeField={(id, value) => {
23
+ props.onChangeBlock(props.block, {
24
+ ...props.data,
25
+ [id]: value,
26
+ });
27
+ }}
28
+ onChangeBlock={props.onChangeBlock}
29
+ formData={props.data}
30
+ block={props.block}
31
+ />
32
+ </SidebarPortal>
33
+ </>
34
+ );
35
+ };
36
+
37
+ const EditWrapper = compose(
38
+ connectToProviderData((props) => ({
39
+ provider_url: props.data?.provider_url,
40
+ })),
41
+ )(Edit);
42
+
43
+ export default (props) => {
44
+ return (
45
+ <VisibilitySensor>
46
+ <EditWrapper {...props} />
47
+ </VisibilitySensor>
48
+ );
49
+ };
@@ -1,30 +1,56 @@
1
- import React from 'react';
2
- import { Container } from 'semantic-ui-react';
1
+ import React, { useRef, useState } from 'react';
2
+ import { compose } from 'redux';
3
+ import cx from 'classnames';
4
+ import loadable from '@loadable/component';
5
+ import { Icon } from '@plone/volto/components';
6
+ import { VisibilitySensor } from '@eeacms/volto-datablocks/components';
7
+ import { connectToMultipleProviders } from '@eeacms/volto-datablocks/hocs';
8
+ import arrowLeft from '@eeacms/volto-n2k/icons/arrow-left.svg';
9
+ import arrowRight from '@eeacms/volto-n2k/icons/arrow-right.svg';
3
10
  import './style.less';
4
11
 
5
- const View = (props) => {
6
- const provider_data = props.provider_data || {};
12
+ const SwiperLoader = loadable.lib(() => import('swiper'));
13
+ const SwiperReactLoader = loadable.lib(() => import('swiper/react'));
14
+
15
+ const _View = (props) => {
16
+ const swiperEl = useRef();
17
+ const previewEl = useRef();
18
+ const [activeSlide, setActiveSlide] = useState(0);
19
+ const { providers = [] } = props.data;
20
+ const habitat = props.providers_data?.[providers[0]?.provider_url] || {};
21
+ const habitat_pictures =
22
+ props.providers_data?.[providers[1]?.provider_url] || {};
23
+
7
24
  const {
8
- code_2000 = [],
25
+ code_2000,
9
26
  // habitat_description = [],
10
27
  // habitat_type = [],
11
28
  // number_countries = [],
12
29
  // number_sites = [],
13
- scientific_name = [],
14
- } = provider_data;
30
+ scientific_name,
31
+ } = habitat;
32
+
33
+ const pictures = habitat_pictures?.['WebURL'] || [];
34
+ const pictures_length = pictures?.length;
35
+ // const picture_names = habitat_pictures?.['filename'] || [];
36
+ // const copyright = habitat_pictures?.['attribution_copyright'] || [];
37
+
38
+ if (!code_2000 && props.mode === 'edit') {
39
+ return 'Habitat banner block (code_2000 undefined)';
40
+ }
41
+ if (!code_2000) return null;
42
+ if (activeSlide) {
43
+ }
15
44
 
16
- if (!code_2000[0]) return '';
17
45
  return (
18
- <div className="habitat-banner-details full-width">
19
- <Container>
20
- <div className="habitat-details">
21
- <div className="habitat-metadata">
22
- <h2 className="name">{scientific_name[0]}</h2>
23
- <p className="info">
24
- Habitats Directive Annex I code&nbsp;&nbsp;&nbsp;{code_2000[0]}
25
- </p>
26
- <br />
27
- {/* {number_sites[0] && (
46
+ <div className="habitat-banner-details">
47
+ <div className="habitat-details">
48
+ <div className="habitat-metadata">
49
+ <h2 className="name">{scientific_name[0]}</h2>
50
+ <p className="info">
51
+ Habitats Directive Annex I code&nbsp;&nbsp;&nbsp;{code_2000[0]}
52
+ </p>
53
+ {/* {number_sites[0] && (
28
54
  <>
29
55
  <h3 style={{ marginBottom: '0.15rem' }}>{number_sites[0]}</h3>
30
56
  <h4 className="radjhan-normal">
@@ -32,11 +58,148 @@ const View = (props) => {
32
58
  </h4>
33
59
  </>
34
60
  )} */}
35
- </div>
36
61
  </div>
37
- </Container>
62
+ {pictures_length > 0 && (
63
+ <div
64
+ className={cx('carousel', {
65
+ 'one-slide': pictures_length === 1,
66
+ 'two-slides': pictures_length === 2,
67
+ 'three-slides': pictures_length > 2,
68
+ })}
69
+ >
70
+ <div className="arrows">
71
+ <button
72
+ className="swiper-button image-swiper-button-prev"
73
+ onClick={() => {
74
+ swiperEl.current.slidePrev();
75
+ if (previewEl.current?.[0]) {
76
+ previewEl.current[0].slidePrev();
77
+ }
78
+ if (previewEl.current?.[1]) {
79
+ previewEl.current[1].slidePrev();
80
+ }
81
+ setActiveSlide(swiperEl.current.realIndex);
82
+ }}
83
+ >
84
+ <Icon
85
+ className="icon-left"
86
+ color="#000"
87
+ name={arrowLeft}
88
+ size="32px"
89
+ />
90
+ </button>
91
+ <button
92
+ className="swiper-button image-swiper-button-next"
93
+ onClick={() => {
94
+ swiperEl.current.slideNext();
95
+ if (previewEl.current?.[0]) {
96
+ previewEl.current[0].slideNext();
97
+ }
98
+ if (previewEl.current?.[1]) {
99
+ previewEl.current[1].slideNext();
100
+ }
101
+ setActiveSlide(swiperEl.current.realIndex);
102
+ }}
103
+ >
104
+ <Icon
105
+ className="icon-right"
106
+ color="#000"
107
+ name={arrowRight}
108
+ size="32px"
109
+ />
110
+ </button>
111
+ {/* <p title={`${source[activeSlide]} - ${license[activeSlide]}`}>
112
+ {source[activeSlide]} - {license[activeSlide]}
113
+ </p> */}
114
+ </div>
115
+ <SwiperLoader>
116
+ {() => {
117
+ return (
118
+ <SwiperReactLoader>
119
+ {({ Swiper, SwiperSlide }) => {
120
+ return (
121
+ <>
122
+ <Swiper
123
+ loop={true}
124
+ initialSlide={0}
125
+ slidesPerView={1}
126
+ spaceBetween={0}
127
+ onBeforeInit={(swiper) => {
128
+ swiperEl.current = swiper;
129
+ }}
130
+ >
131
+ {pictures.map((source, index) => (
132
+ <SwiperSlide>
133
+ <img src={source} alt={pictures[index]} />
134
+ </SwiperSlide>
135
+ ))}
136
+ </Swiper>
137
+ {pictures_length > 1 && (
138
+ <Swiper
139
+ className="preview preview-one"
140
+ loop={true}
141
+ initialSlide={1}
142
+ slidesPerView={1}
143
+ spaceBetween={0}
144
+ onBeforeInit={(swiper) => {
145
+ if (!previewEl.current) {
146
+ previewEl.current = [];
147
+ }
148
+ previewEl.current[0] = swiper;
149
+ }}
150
+ >
151
+ {pictures.map((source, index) => (
152
+ <SwiperSlide>
153
+ <img src={source} alt={pictures[index]} />
154
+ </SwiperSlide>
155
+ ))}
156
+ </Swiper>
157
+ )}
158
+ {pictures_length > 2 && (
159
+ <Swiper
160
+ className="preview preview-two"
161
+ loop={true}
162
+ initialSlide={2}
163
+ slidesPerView={1}
164
+ spaceBetween={0}
165
+ onBeforeInit={(swiper) => {
166
+ if (!previewEl.current) {
167
+ previewEl.current = [];
168
+ }
169
+ previewEl.current[1] = swiper;
170
+ }}
171
+ >
172
+ {pictures.map((source, index) => (
173
+ <SwiperSlide>
174
+ <img src={source} alt={pictures[index]} />
175
+ </SwiperSlide>
176
+ ))}
177
+ </Swiper>
178
+ )}
179
+ </>
180
+ );
181
+ }}
182
+ </SwiperReactLoader>
183
+ );
184
+ }}
185
+ </SwiperLoader>
186
+ </div>
187
+ )}
188
+ </div>
38
189
  </div>
39
190
  );
40
191
  };
41
192
 
42
- export default View;
193
+ const View = compose(
194
+ connectToMultipleProviders((props) => ({
195
+ providers: props.data?.providers,
196
+ })),
197
+ )(_View);
198
+
199
+ export default (props) => {
200
+ return (
201
+ <VisibilitySensor Placeholder={() => <div>loading....&nbsp;</div>}>
202
+ <View {...props} />
203
+ </VisibilitySensor>
204
+ );
205
+ };
@@ -1,17 +1,24 @@
1
- import HabitatsBannerView from './View';
2
- import getSchema from './schema';
1
+ import worldSVG from '@plone/volto/icons/world.svg';
2
+ import Edit from './Edit';
3
+ import View from './View';
3
4
 
4
5
  export default (config) => {
5
- config.blocks.blocksConfig.custom_connected_block = {
6
- ...config.blocks.blocksConfig.custom_connected_block,
7
- blocks: {
8
- ...config.blocks.blocksConfig.custom_connected_block.blocks,
9
- habitats_banner: {
10
- view: HabitatsBannerView,
11
- getSchema: getSchema,
12
- title: 'Habitat banner',
13
- },
6
+ config.blocks.blocksConfig.habitats_banner = {
7
+ id: 'habitats_banner',
8
+ title: 'Habitats banner',
9
+ icon: worldSVG,
10
+ group: 'natura_2000',
11
+ edit: Edit,
12
+ view: View,
13
+ restricted: false,
14
+ mostUsed: false,
15
+ sidebarTab: 1,
16
+ blocks: {},
17
+ security: {
18
+ addPermission: [],
19
+ view: [],
14
20
  },
21
+ blockHasOwnFocusManagement: false,
15
22
  };
16
23
  return config;
17
24
  };
@@ -1,18 +1,77 @@
1
+ const SourceSchema = {
2
+ title: 'Source',
3
+
4
+ fieldsets: [
5
+ {
6
+ id: 'default',
7
+ title: 'Default',
8
+ fields: ['source', 'source_link'],
9
+ },
10
+ ],
11
+
12
+ properties: {
13
+ source: {
14
+ type: 'string',
15
+ title: 'Source',
16
+ },
17
+ source_link: {
18
+ type: 'string',
19
+ title: 'Link',
20
+ },
21
+ },
22
+
23
+ required: ['source'],
24
+ };
25
+
26
+ const DataProvidersSchema = {
27
+ title: 'Data provider',
28
+ fieldsets: [{ id: 'default', title: 'Default', fields: ['provider_url'] }],
29
+ properties: {
30
+ provider_url: {
31
+ title: 'Provider url',
32
+ widget: 'object_by_path',
33
+ },
34
+ },
35
+ };
36
+
1
37
  const getSchema = (props) => {
2
38
  return {
3
- title: 'Habitats banner',
4
-
39
+ title: 'Habitats Banner',
5
40
  fieldsets: [
6
41
  {
7
42
  id: 'default',
8
43
  title: 'Default',
9
- fields: [],
44
+ fields: ['providers', 'allowedParams'],
45
+ },
46
+ {
47
+ id: 'sources',
48
+ title: 'Sources',
49
+ fields: ['sources'],
10
50
  },
11
51
  ],
12
52
 
13
- properties: {},
53
+ properties: {
54
+ providers: {
55
+ title: 'Data provider',
56
+ schema: DataProvidersSchema,
57
+ widget: 'object_list',
58
+ },
59
+ allowedParams: {
60
+ title: 'Allowed params',
61
+ type: 'array',
62
+ creatable: true,
63
+ items: {
64
+ choices: [],
65
+ },
66
+ },
67
+ sources: {
68
+ title: 'Sources',
69
+ schema: SourceSchema,
70
+ widget: 'object_list',
71
+ },
72
+ },
14
73
 
15
- required: [],
74
+ required: ['url'],
16
75
  };
17
76
  };
18
77