@eeacms/volto-n2k 0.1.1

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 (233) hide show
  1. package/.coverage.babel.config.js +9 -0
  2. package/.release-it.json +17 -0
  3. package/CHANGELOG.md +155 -0
  4. package/DEVELOP.md +53 -0
  5. package/Jenkinsfile +209 -0
  6. package/LICENSE.md +9 -0
  7. package/README.md +62 -0
  8. package/bootstrap +41 -0
  9. package/cypress/fixtures/example.json +5 -0
  10. package/cypress/integration/block-basics.js +32 -0
  11. package/cypress/plugins/index.js +26 -0
  12. package/cypress/support/commands.js +315 -0
  13. package/cypress/support/index.js +53 -0
  14. package/cypress.json +12 -0
  15. package/jest-addon.config.js +36 -0
  16. package/package.json +57 -0
  17. package/src/actions.js +20 -0
  18. package/src/components/index.js +3 -0
  19. package/src/components/manage/Blocks/BodyClass/Edit.jsx +29 -0
  20. package/src/components/manage/Blocks/BodyClass/View.jsx +13 -0
  21. package/src/components/manage/Blocks/BodyClass/index.js +24 -0
  22. package/src/components/manage/Blocks/BodyClass/schema.js +19 -0
  23. package/src/components/manage/Blocks/BubbleChart/BubbleChart.jsx +101 -0
  24. package/src/components/manage/Blocks/BubbleChart/Chart.jsx +67 -0
  25. package/src/components/manage/Blocks/BubbleChart/ChartContext.jsx +3 -0
  26. package/src/components/manage/Blocks/BubbleChart/View.jsx +63 -0
  27. package/src/components/manage/Blocks/BubbleChart/index.js +17 -0
  28. package/src/components/manage/Blocks/BubbleChart/schema.js +124 -0
  29. package/src/components/manage/Blocks/BubbleChart/style.less +12 -0
  30. package/src/components/manage/Blocks/CarouselHorizontal/HorizontalView.jsx +221 -0
  31. package/src/components/manage/Blocks/CarouselHorizontal/index.js +19 -0
  32. package/src/components/manage/Blocks/CarouselHorizontal/schema.js +32 -0
  33. package/src/components/manage/Blocks/CddaShape/View.jsx +109 -0
  34. package/src/components/manage/Blocks/CddaShape/index.js +23 -0
  35. package/src/components/manage/Blocks/CddaShape/schema.js +19 -0
  36. package/src/components/manage/Blocks/CddaShape/style.less +14 -0
  37. package/src/components/manage/Blocks/ContactBlock/View.jsx +56 -0
  38. package/src/components/manage/Blocks/ContactBlock/icons/domain.svg +1 -0
  39. package/src/components/manage/Blocks/ContactBlock/icons/email.svg +1 -0
  40. package/src/components/manage/Blocks/ContactBlock/icons/location.svg +1 -0
  41. package/src/components/manage/Blocks/ContactBlock/index.js +17 -0
  42. package/src/components/manage/Blocks/ContactBlock/schema.js +57 -0
  43. package/src/components/manage/Blocks/ContactBlock/styles.less +31 -0
  44. package/src/components/manage/Blocks/ExplodedPiesChart/Pie.jsx +125 -0
  45. package/src/components/manage/Blocks/ExplodedPiesChart/View.jsx +80 -0
  46. package/src/components/manage/Blocks/ExplodedPiesChart/index.js +17 -0
  47. package/src/components/manage/Blocks/ExplodedPiesChart/schema.js +75 -0
  48. package/src/components/manage/Blocks/ExplodedPiesChart/style.less +80 -0
  49. package/src/components/manage/Blocks/ExploreHabitats/Edit.jsx +29 -0
  50. package/src/components/manage/Blocks/ExploreHabitats/View.jsx +177 -0
  51. package/src/components/manage/Blocks/ExploreHabitats/index.js +24 -0
  52. package/src/components/manage/Blocks/ExploreHabitats/schema.js +15 -0
  53. package/src/components/manage/Blocks/ExploreHabitats/style.less +15 -0
  54. package/src/components/manage/Blocks/ExploreSites/Edit.jsx +29 -0
  55. package/src/components/manage/Blocks/ExploreSites/View.jsx +175 -0
  56. package/src/components/manage/Blocks/ExploreSites/index.js +24 -0
  57. package/src/components/manage/Blocks/ExploreSites/schema.js +15 -0
  58. package/src/components/manage/Blocks/ExploreSites/style.less +15 -0
  59. package/src/components/manage/Blocks/ExploreSpecies/Edit.jsx +29 -0
  60. package/src/components/manage/Blocks/ExploreSpecies/View.jsx +177 -0
  61. package/src/components/manage/Blocks/ExploreSpecies/index.js +24 -0
  62. package/src/components/manage/Blocks/ExploreSpecies/schema.js +15 -0
  63. package/src/components/manage/Blocks/ExploreSpecies/style.less +15 -0
  64. package/src/components/manage/Blocks/HabitatClassification/View.jsx +30 -0
  65. package/src/components/manage/Blocks/HabitatClassification/index.js +17 -0
  66. package/src/components/manage/Blocks/HabitatClassification/schema.js +19 -0
  67. package/src/components/manage/Blocks/HabitatClassification/style.less +3 -0
  68. package/src/components/manage/Blocks/HabitatDistribution/View.jsx +97 -0
  69. package/src/components/manage/Blocks/HabitatDistribution/index.js +23 -0
  70. package/src/components/manage/Blocks/HabitatDistribution/schema.js +19 -0
  71. package/src/components/manage/Blocks/HabitatDistribution/style.less +5 -0
  72. package/src/components/manage/Blocks/HabitatProtectedSites/View.jsx +97 -0
  73. package/src/components/manage/Blocks/HabitatProtectedSites/index.js +23 -0
  74. package/src/components/manage/Blocks/HabitatProtectedSites/schema.js +19 -0
  75. package/src/components/manage/Blocks/HabitatProtectedSites/style.less +5 -0
  76. package/src/components/manage/Blocks/HabitatsBanner/View.jsx +39 -0
  77. package/src/components/manage/Blocks/HabitatsBanner/index.js +17 -0
  78. package/src/components/manage/Blocks/HabitatsBanner/schema.js +19 -0
  79. package/src/components/manage/Blocks/HabitatsBanner/style.less +49 -0
  80. package/src/components/manage/Blocks/ImageText/Edit.jsx +98 -0
  81. package/src/components/manage/Blocks/ImageText/View.jsx +66 -0
  82. package/src/components/manage/Blocks/ImageText/index.js +24 -0
  83. package/src/components/manage/Blocks/ImageText/schema.js +69 -0
  84. package/src/components/manage/Blocks/ImageText/styles.less +87 -0
  85. package/src/components/manage/Blocks/Landing/DefalutView.jsx +83 -0
  86. package/src/components/manage/Blocks/Landing/Edit.jsx +219 -0
  87. package/src/components/manage/Blocks/Landing/EditBlockWrapper.jsx +161 -0
  88. package/src/components/manage/Blocks/Landing/View.jsx +65 -0
  89. package/src/components/manage/Blocks/Landing/images/background.webp +0 -0
  90. package/src/components/manage/Blocks/Landing/images/coasts_and_seas.webp +0 -0
  91. package/src/components/manage/Blocks/Landing/images/forests.webp +0 -0
  92. package/src/components/manage/Blocks/Landing/images/grasslands.webp +0 -0
  93. package/src/components/manage/Blocks/Landing/images/hiker.webp +0 -0
  94. package/src/components/manage/Blocks/Landing/images/islands.webp +0 -0
  95. package/src/components/manage/Blocks/Landing/images/mountains.webp +0 -0
  96. package/src/components/manage/Blocks/Landing/images/natura2000.webp +0 -0
  97. package/src/components/manage/Blocks/Landing/images/natura2000_square.webp +0 -0
  98. package/src/components/manage/Blocks/Landing/images/peatlands.webp +0 -0
  99. package/src/components/manage/Blocks/Landing/images/people_and_nature.webp +0 -0
  100. package/src/components/manage/Blocks/Landing/images/rivers.webp +0 -0
  101. package/src/components/manage/Blocks/Landing/index.js +104 -0
  102. package/src/components/manage/Blocks/Landing/schema.js +62 -0
  103. package/src/components/manage/Blocks/Landing/style.less +174 -0
  104. package/src/components/manage/Blocks/List/View.jsx +37 -0
  105. package/src/components/manage/Blocks/List/index.js +17 -0
  106. package/src/components/manage/Blocks/List/schema.js +49 -0
  107. package/src/components/manage/Blocks/List/style.less +12 -0
  108. package/src/components/manage/Blocks/NavigationAnchors/Edit.jsx +33 -0
  109. package/src/components/manage/Blocks/NavigationAnchors/View.jsx +132 -0
  110. package/src/components/manage/Blocks/NavigationAnchors/assets/external.png +0 -0
  111. package/src/components/manage/Blocks/NavigationAnchors/index.js +23 -0
  112. package/src/components/manage/Blocks/NavigationAnchors/schema.js +76 -0
  113. package/src/components/manage/Blocks/NavigationAnchors/styles.less +104 -0
  114. package/src/components/manage/Blocks/SimpleDataTable/index.js +16 -0
  115. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/View.jsx +178 -0
  116. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/index.js +4 -0
  117. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/schema.js +56 -0
  118. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/style.less +54 -0
  119. package/src/components/manage/Blocks/SiteBanner/View.jsx +148 -0
  120. package/src/components/manage/Blocks/SiteBanner/index.js +17 -0
  121. package/src/components/manage/Blocks/SiteBanner/schema.js +19 -0
  122. package/src/components/manage/Blocks/SiteBanner/style.less +106 -0
  123. package/src/components/manage/Blocks/SiteHabitatsList/View.jsx +89 -0
  124. package/src/components/manage/Blocks/SiteHabitatsList/index.js +17 -0
  125. package/src/components/manage/Blocks/SiteHabitatsList/schema.js +19 -0
  126. package/src/components/manage/Blocks/SiteHabitatsList/style.less +70 -0
  127. package/src/components/manage/Blocks/SiteProtectedHabitats/View.jsx +47 -0
  128. package/src/components/manage/Blocks/SiteProtectedHabitats/images/background.webp +0 -0
  129. package/src/components/manage/Blocks/SiteProtectedHabitats/index.js +17 -0
  130. package/src/components/manage/Blocks/SiteProtectedHabitats/schema.js +19 -0
  131. package/src/components/manage/Blocks/SiteProtectedHabitats/style.less +90 -0
  132. package/src/components/manage/Blocks/SiteProtectedSpecies/View.jsx +55 -0
  133. package/src/components/manage/Blocks/SiteProtectedSpecies/images/background.webp +0 -0
  134. package/src/components/manage/Blocks/SiteProtectedSpecies/index.js +17 -0
  135. package/src/components/manage/Blocks/SiteProtectedSpecies/schema.js +19 -0
  136. package/src/components/manage/Blocks/SiteProtectedSpecies/style.less +90 -0
  137. package/src/components/manage/Blocks/SiteShape/View.jsx +107 -0
  138. package/src/components/manage/Blocks/SiteShape/index.js +23 -0
  139. package/src/components/manage/Blocks/SiteShape/schema.js +19 -0
  140. package/src/components/manage/Blocks/SiteShape/style.less +15 -0
  141. package/src/components/manage/Blocks/SiteSpeciesList/Filters/SortBy.jsx +52 -0
  142. package/src/components/manage/Blocks/SiteSpeciesList/Filters/SpeciesGroups.jsx +43 -0
  143. package/src/components/manage/Blocks/SiteSpeciesList/Filters/View.jsx +200 -0
  144. package/src/components/manage/Blocks/SiteSpeciesList/Filters/index.js +4 -0
  145. package/src/components/manage/Blocks/SiteSpeciesList/View.jsx +253 -0
  146. package/src/components/manage/Blocks/SiteSpeciesList/index.js +17 -0
  147. package/src/components/manage/Blocks/SiteSpeciesList/schema.js +19 -0
  148. package/src/components/manage/Blocks/SiteSpeciesList/style.less +264 -0
  149. package/src/components/manage/Blocks/SiteSpeciesList/utils.js +33 -0
  150. package/src/components/manage/Blocks/SlateLink/render.jsx +77 -0
  151. package/src/components/manage/Blocks/SlateLink/styles.less +22 -0
  152. package/src/components/manage/Blocks/SlateSVG/constants.js +1 -0
  153. package/src/components/manage/Blocks/SlateSVG/extensions.js +11 -0
  154. package/src/components/manage/Blocks/SlateSVG/index.js +47 -0
  155. package/src/components/manage/Blocks/SlateSVG/render.jsx +42 -0
  156. package/src/components/manage/Blocks/SlateSVG/schema.js +12 -0
  157. package/src/components/manage/Blocks/SlateSVG/styles.less +6 -0
  158. package/src/components/manage/Blocks/SpeciesBanner/View.jsx +109 -0
  159. package/src/components/manage/Blocks/SpeciesBanner/index.js +17 -0
  160. package/src/components/manage/Blocks/SpeciesBanner/schema.js +19 -0
  161. package/src/components/manage/Blocks/SpeciesBanner/style.less +115 -0
  162. package/src/components/manage/Blocks/SpeciesClassification/View.jsx +19 -0
  163. package/src/components/manage/Blocks/SpeciesClassification/index.js +17 -0
  164. package/src/components/manage/Blocks/SpeciesClassification/schema.js +19 -0
  165. package/src/components/manage/Blocks/SpeciesClassification/style.less +3 -0
  166. package/src/components/manage/Blocks/SpeciesDistribution/View.jsx +97 -0
  167. package/src/components/manage/Blocks/SpeciesDistribution/index.js +23 -0
  168. package/src/components/manage/Blocks/SpeciesDistribution/schema.js +19 -0
  169. package/src/components/manage/Blocks/SpeciesDistribution/style.less +5 -0
  170. package/src/components/manage/Blocks/SpeciesProtectedSites/View.jsx +97 -0
  171. package/src/components/manage/Blocks/SpeciesProtectedSites/index.js +23 -0
  172. package/src/components/manage/Blocks/SpeciesProtectedSites/schema.js +19 -0
  173. package/src/components/manage/Blocks/SpeciesProtectedSites/style.less +5 -0
  174. package/src/components/manage/Blocks/StackedBarChart/Chart.jsx +127 -0
  175. package/src/components/manage/Blocks/StackedBarChart/ChartContext.jsx +3 -0
  176. package/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx +116 -0
  177. package/src/components/manage/Blocks/StackedBarChart/View.jsx +64 -0
  178. package/src/components/manage/Blocks/StackedBarChart/index.js +17 -0
  179. package/src/components/manage/Blocks/StackedBarChart/schema.js +25 -0
  180. package/src/components/manage/Blocks/StackedBarChart/style.less +37 -0
  181. package/src/components/manage/Blocks/TilesImages/Edit.jsx +32 -0
  182. package/src/components/manage/Blocks/TilesImages/View.jsx +37 -0
  183. package/src/components/manage/Blocks/TilesImages/index.js +23 -0
  184. package/src/components/manage/Blocks/TilesImages/schema.js +72 -0
  185. package/src/components/manage/Blocks/TilesImages/styles.less +57 -0
  186. package/src/components/theme/AppExtras/CopyPaste/CopyPaste.jsx +176 -0
  187. package/src/components/theme/AppExtras/CopyPaste/index.js +3 -0
  188. package/src/components/theme/AppExtras/CopyPaste/style.less +18 -0
  189. package/src/components/theme/AppExtras/MultilingualRedirector/MultilingualRedirector.jsx +35 -0
  190. package/src/components/theme/AppExtras/index.js +13 -0
  191. package/src/components/theme/Footer/Footer.jsx +209 -0
  192. package/src/components/theme/Header/Header.jsx +81 -0
  193. package/src/components/theme/LanguageSelector/LanguageSelector.jsx +79 -0
  194. package/src/components/theme/LanguageSelector/styles.less +44 -0
  195. package/src/components/theme/Navigation/Navigation.jsx +453 -0
  196. package/src/components/theme/Sitemap/Sitemap.jsx +152 -0
  197. package/src/fonts/OpenSans-Bold.ttf +0 -0
  198. package/src/fonts/OpenSans-Regular.ttf +0 -0
  199. package/src/fonts/OpenSans-Semibold.ttf +0 -0
  200. package/src/fonts/Rajdhani-Bold.ttf +0 -0
  201. package/src/fonts/Rajdhani-Regular.ttf +0 -0
  202. package/src/grid.js +78 -0
  203. package/src/helpers.js +148 -0
  204. package/src/hocs/index.js +6 -0
  205. package/src/hocs/useResizeObserver.jsx +26 -0
  206. package/src/hocs/withLocalStorage.jsx +37 -0
  207. package/src/hocs/withScreenSize.jsx +43 -0
  208. package/src/icons/home.svg +12 -0
  209. package/src/icons/info.svg +5 -0
  210. package/src/icons/n2k-logo-transparent.png +0 -0
  211. package/src/icons/n2k-logo.png +0 -0
  212. package/src/icons/natura2000.svg +142 -0
  213. package/src/icons/placeholders/Algae.png +0 -0
  214. package/src/icons/placeholders/Amphibians.png +0 -0
  215. package/src/icons/placeholders/Birds.png +0 -0
  216. package/src/icons/placeholders/Conifers.png +0 -0
  217. package/src/icons/placeholders/Fishes.png +0 -0
  218. package/src/icons/placeholders/Fungi.png +0 -0
  219. package/src/icons/placeholders/Mammals.png +0 -0
  220. package/src/icons/placeholders/Plants.png +0 -0
  221. package/src/icons/placeholders/Reptiles.png +0 -0
  222. package/src/icons/placeholders/default.png +0 -0
  223. package/src/index.js +163 -0
  224. package/src/less/globals.less +3 -0
  225. package/src/less/styles.less +691 -0
  226. package/src/less/variables.less +2 -0
  227. package/src/static/cca.svg +61 -0
  228. package/src/static/ec.png +0 -0
  229. package/src/static/eea.png +0 -0
  230. package/src/static/eu.jpg +0 -0
  231. package/src/static/forest.svg +100 -0
  232. package/src/static/wise.png +0 -0
  233. package/src/store.js +24 -0
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { Container } from 'semantic-ui-react';
3
+
4
+ import './style.less';
5
+
6
+ const View = (props) => {
7
+ const provider_data = props.provider_data || {};
8
+ const data = (provider_data?.number || []).reduce(function (data, key, i) {
9
+ data[provider_data.species_group_name[i]] = key;
10
+ return data;
11
+ }, {});
12
+
13
+ return (
14
+ <div className="species-banner full-width">
15
+ <div className="species-container">
16
+ <Container className="species-wrapper">
17
+ {/* <Grid size="12">
18
+ <Grid.Row>
19
+ {Object.entries(data).map(([item, value], index) => (
20
+ <Grid.Column
21
+ key={index}
22
+ mobile="6"
23
+ tablet="6"
24
+ computer="3"
25
+ className="species-box"
26
+ >
27
+ <div className="upper">
28
+ <span>{value}</span>
29
+ </div>
30
+ <div className="lower">
31
+ <span>{item}</span>
32
+ </div>
33
+ </Grid.Column>
34
+ ))}
35
+ </Grid.Row>
36
+ </Grid> */}
37
+ <div className="species-wrapper">
38
+ {Object.entries(data).map(([item, value], index) => (
39
+ <div key={index} className="species-box">
40
+ <div className="upper">
41
+ <span>{value}</span>
42
+ </div>
43
+ <div className="lower">
44
+ <span>{item}</span>
45
+ </div>
46
+ </div>
47
+ ))}
48
+ </div>
49
+ </Container>
50
+ </div>
51
+ </div>
52
+ );
53
+ };
54
+
55
+ export default View;
@@ -0,0 +1,17 @@
1
+ import SiteProtectedSpeciesView from './View';
2
+ import getSchema from './schema';
3
+
4
+ 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
+ site_protected_species: {
10
+ view: SiteProtectedSpeciesView,
11
+ getSchema: getSchema,
12
+ title: 'Site protected species',
13
+ },
14
+ },
15
+ };
16
+ return config;
17
+ };
@@ -0,0 +1,19 @@
1
+ const getSchema = (props) => {
2
+ return {
3
+ title: 'Site protected species',
4
+
5
+ fieldsets: [
6
+ {
7
+ id: 'default',
8
+ title: 'Default',
9
+ fields: [],
10
+ },
11
+ ],
12
+
13
+ properties: {},
14
+
15
+ required: [],
16
+ };
17
+ };
18
+
19
+ export default getSchema;
@@ -0,0 +1,90 @@
1
+ @import (multiple, reference, optional) '../../theme.config';
2
+ @type: extra;
3
+ @element: custom;
4
+
5
+ div#view .ui.container.species-wrapper > * {
6
+ margin-bottom: 0;
7
+ }
8
+
9
+ .species-banner {
10
+ position: relative;
11
+ height: 320px;
12
+ background: linear-gradient(to left, transparent, rgba(0, 0, 0, 0.7)),
13
+ url('./images/background.webp');
14
+ background-position: center;
15
+ background-repeat: no-repeat;
16
+ background-size: cover;
17
+ font-family: 'RajdhaniB';
18
+
19
+ .species-container {
20
+ position: absolute;
21
+ top: 50%;
22
+ left: 50%;
23
+ width: 100%;
24
+ transform: translate(-50%, -50%);
25
+ }
26
+
27
+ .species-wrapper {
28
+ display: flex;
29
+ flex-flow: row;
30
+ margin: 0 auto !important;
31
+ overflow-x: auto;
32
+ }
33
+
34
+ .species-wrapper:before,
35
+ .species-wrapper:after {
36
+ flex: 1;
37
+ content: '';
38
+ }
39
+
40
+ .species-box {
41
+ margin: 0.5em 1.5em;
42
+
43
+ .upper {
44
+ position: relative;
45
+ width: 110px;
46
+ height: 110px;
47
+ margin: auto;
48
+ background-color: #eaeaea;
49
+ border-radius: 50%;
50
+
51
+ > span {
52
+ position: absolute;
53
+ top: 50%;
54
+ left: 50%;
55
+ color: #013c60;
56
+ font-family: inherit;
57
+ font-size: 55px;
58
+ transform: translate(-50%, -50%);
59
+ }
60
+ }
61
+
62
+ .lower {
63
+ margin-top: 1em;
64
+ text-align: center;
65
+
66
+ span {
67
+ color: #fff;
68
+ font-family: inherit;
69
+ font-size: 19px;
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ @media only screen and (max-width: @largeMonitorBreakpoint) {
76
+ .species-banner {
77
+ .species-box {
78
+ width: 100px;
79
+
80
+ .upper {
81
+ width: 80px;
82
+ height: 80px;
83
+
84
+ span {
85
+ font-size: 40px;
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,107 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Message, Container } from 'semantic-ui-react';
3
+ import Map from '@eeacms/volto-openlayers-map/Map';
4
+ import { Interactions } from '@eeacms/volto-openlayers-map/Interactions';
5
+ import { Controls } from '@eeacms/volto-openlayers-map/Controls';
6
+ import { Layers, Layer } from '@eeacms/volto-openlayers-map/Layers';
7
+ import { openlayers } from '@eeacms/volto-openlayers-map';
8
+ import { getSiteShapeURL } from './index';
9
+ import './style.less';
10
+
11
+ const View = (props) => {
12
+ const [options, setOptions] = React.useState({});
13
+ const [vectorSource, setVectorSource] = useState(null);
14
+ const { extent, format, proj, style, source } = openlayers;
15
+ const provider_data = props.provider_data || {};
16
+ const { site_code = [] } = provider_data;
17
+
18
+ useEffect(() => {
19
+ if (__SERVER__) return;
20
+ setVectorSource(new source.Vector());
21
+ /* eslint-disable-next-line */
22
+ }, []);
23
+
24
+ useEffect(() => {
25
+ if (__SERVER__ || !vectorSource || !site_code[0]) return;
26
+ const esrijsonFormat = new format.EsriJSON();
27
+ // Get site shape
28
+ fetch(getSiteShapeURL(site_code[0])).then(function (response) {
29
+ if (response.status !== 200) return;
30
+ response.json().then(function (data) {
31
+ if (data.features && data.features.length > 0) {
32
+ const features = esrijsonFormat.readFeatures(data);
33
+ if (features.length > 0) {
34
+ vectorSource.addFeatures(features);
35
+ const vectorExtent = vectorSource.getExtent();
36
+ let size = extent.getSize(vectorExtent);
37
+ setOptions({
38
+ ...options,
39
+ extent: new extent.buffer(vectorExtent, size[0] * 0.1),
40
+ });
41
+ }
42
+ }
43
+ });
44
+ });
45
+ /* eslint-disable-next-line */
46
+ }, [site_code?.[0]]);
47
+
48
+ if (__SERVER__ || !vectorSource) return '';
49
+ return (
50
+ <div className="site-shape-wrapper full-width">
51
+ <div className="site-shape">
52
+ <Map
53
+ view={{
54
+ center: proj.fromLonLat([20, 50]),
55
+ showFullExtent: true,
56
+ zoom: 5,
57
+ }}
58
+ {...options}
59
+ >
60
+ <Layers>
61
+ <Layer.Tile zIndex={0} />
62
+ <Layer.Vector
63
+ source={vectorSource}
64
+ style={
65
+ new style.Style({
66
+ fill: new style.Fill({
67
+ color: 'rgba(255,255,255,0.4)',
68
+ }),
69
+ stroke: new style.Stroke({
70
+ color: '#04A77D',
71
+ width: 3,
72
+ lineDash: [5, 7],
73
+ }),
74
+ })
75
+ }
76
+ zIndex={1}
77
+ />
78
+ </Layers>
79
+ <Controls attribution={true} zoom={false} />
80
+ <Interactions
81
+ doubleClickZoom={false}
82
+ dragAndDrop={false}
83
+ dragPan={false}
84
+ keyboardPan={false}
85
+ keyboardZoom={false}
86
+ mouseWheelZoom={false}
87
+ pointer={false}
88
+ select={false}
89
+ />
90
+ </Map>
91
+ </div>
92
+ <Container className="map-info-notice">
93
+ <Message>
94
+ <p>
95
+ The designations employed and the presentation of material on this
96
+ map do not imply the expression of any opinion whatsoever on the
97
+ part of the European Union concerning the legal status of any
98
+ country, territory, city or area or of its authorities, or
99
+ concerning the delimitation of its frontiers or boundaries.
100
+ </p>
101
+ </Message>
102
+ </Container>
103
+ </div>
104
+ );
105
+ };
106
+
107
+ export default View;
@@ -0,0 +1,23 @@
1
+ import SiteShapeView from './View';
2
+ import getSchema from './schema';
3
+
4
+ export function getSiteShapeURL(site_code) {
5
+ return encodeURI(
6
+ `https://bio.discomap.eea.europa.eu/arcgis/rest/services/ProtectedSites/Natura2000Sites/MapServer/2/query?f=json&where=SITECODE LIKE '%${site_code.toUpperCase()}%'&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=SITECODE,SITENAME,OBJECTID&outSR=102100`,
7
+ );
8
+ }
9
+
10
+ export default (config) => {
11
+ config.blocks.blocksConfig.custom_connected_block = {
12
+ ...config.blocks.blocksConfig.custom_connected_block,
13
+ blocks: {
14
+ ...config.blocks.blocksConfig.custom_connected_block.blocks,
15
+ site_shape: {
16
+ view: SiteShapeView,
17
+ getSchema: getSchema,
18
+ title: 'Site shape',
19
+ },
20
+ },
21
+ };
22
+ return config;
23
+ };
@@ -0,0 +1,19 @@
1
+ const getSchema = (props) => {
2
+ return {
3
+ title: 'Site shape',
4
+
5
+ fieldsets: [
6
+ {
7
+ id: 'default',
8
+ title: 'Default',
9
+ fields: [],
10
+ },
11
+ ],
12
+
13
+ properties: {},
14
+
15
+ required: [],
16
+ };
17
+ };
18
+
19
+ export default getSchema;
@@ -0,0 +1,15 @@
1
+ div#view .ui.container > .site-shape-wrapper,
2
+ div#view .ui.container > .site-shape {
3
+ margin-bottom: 0;
4
+ }
5
+
6
+ .site-shape {
7
+ display: flex;
8
+ justify-content: center;
9
+ margin-bottom: 0;
10
+ background-color: #f8f8f8;
11
+
12
+ &.visible.transition {
13
+ display: flex !important;
14
+ }
15
+ }
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { Dropdown } from 'semantic-ui-react';
3
+ import { Icon } from '@plone/volto/components';
4
+ import upSVG from '@plone/volto/icons/up.svg';
5
+ import downSVG from '@plone/volto/icons/down.svg';
6
+
7
+ const antonyms = {
8
+ ASC: 'DESC',
9
+ DESC: 'ASC',
10
+ };
11
+
12
+ const View = (props) => {
13
+ const { sortBy, setSortBy } = props;
14
+
15
+ const sortByOptions = [
16
+ { text: 'Alphabetical', value: 'scientific_name', key: 'scientific_name' },
17
+ ];
18
+
19
+ return (
20
+ <Dropdown aria-label="Sort species by" text="SORT BY" floating button>
21
+ <Dropdown.Menu>
22
+ {sortByOptions.map((option) => (
23
+ <Dropdown.Item
24
+ key={option.text}
25
+ active={sortBy === option.value}
26
+ onClick={(e, data) => {
27
+ const activePoperty = sortBy[0];
28
+ const activeOrder = sortBy[1];
29
+ const newOrder =
30
+ activePoperty === option.value ? antonyms[activeOrder] : 'ASC';
31
+ setSortBy([option.value, newOrder]);
32
+ }}
33
+ >
34
+ <p>
35
+ {option.text}
36
+ {sortBy[0] === option.value ? (
37
+ <Icon
38
+ name={sortBy[1] === 'ASC' ? upSVG : downSVG}
39
+ size="14px"
40
+ />
41
+ ) : (
42
+ ''
43
+ )}
44
+ </p>
45
+ </Dropdown.Item>
46
+ ))}
47
+ </Dropdown.Menu>
48
+ </Dropdown>
49
+ );
50
+ };
51
+
52
+ export default View;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Container } from 'semantic-ui-react';
3
+ import cx from 'classnames';
4
+
5
+ const SpeciesGroups = (props) => {
6
+ const [speciesGroups, setSpeciesGroups] = React.useState([]);
7
+ const {
8
+ provider_data = {},
9
+ activeSpeciesGroup = 'All',
10
+ setActiveSpeciesGroup = () => {},
11
+ } = props;
12
+
13
+ React.useEffect(() => {
14
+ setSpeciesGroups([
15
+ ...(provider_data.species_group_name?.length ? ['All'] : []),
16
+ ...new Set(provider_data.species_group_name || []),
17
+ ]);
18
+ /* eslint-disable-next-line */
19
+ }, [JSON.stringify(provider_data)]);
20
+
21
+ return (
22
+ <div className="species-groups">
23
+ <Container>
24
+ {speciesGroups.map((species) => (
25
+ <button
26
+ key={`group-filter-${species}`}
27
+ className={cx({
28
+ 'species-group': true,
29
+ active: activeSpeciesGroup === species,
30
+ })}
31
+ onClick={() => {
32
+ setActiveSpeciesGroup(species);
33
+ }}
34
+ >
35
+ {species}
36
+ </button>
37
+ ))}
38
+ </Container>
39
+ </div>
40
+ );
41
+ };
42
+
43
+ export default SpeciesGroups;
@@ -0,0 +1,200 @@
1
+ import React from 'react';
2
+ import {
3
+ Container,
4
+ Dropdown,
5
+ Sidebar,
6
+ Checkbox,
7
+ Label,
8
+ } from 'semantic-ui-react';
9
+ import { Icon } from '@plone/volto/components';
10
+ import filterSVG from '@plone/volto/icons/filter.svg';
11
+ import clearSVG from '@plone/volto/icons/clear.svg';
12
+
13
+ import SpeciesGroups from './SpeciesGroups';
14
+ import SortBy from './SortBy';
15
+
16
+ import { filtersLabels } from '../utils';
17
+
18
+ const SidebarFilter = (props) => {
19
+ const { activeFilters, filters, filter, index, setActiveFilters } = props;
20
+ return (
21
+ <div className="filter">
22
+ <div className="header">
23
+ <p className="title">
24
+ {filtersLabels[filter].getTitle().toUpperCase()}
25
+ {!index ? (
26
+ <button
27
+ className="reset-button"
28
+ onClick={() => {
29
+ setActiveFilters({});
30
+ }}
31
+ >
32
+ Reset
33
+ </button>
34
+ ) : (
35
+ ''
36
+ )}
37
+ </p>
38
+ </div>
39
+ {Object.keys(filters[filter]).map((field) => (
40
+ <div key={filtersLabels[filter][field]} className="checkbox-wrapper">
41
+ <Checkbox
42
+ name={filter}
43
+ label={filtersLabels[filter][field]}
44
+ checked={activeFilters[filter]?.includes(field) || false}
45
+ onClick={() => {
46
+ const newActiveFilters = { ...activeFilters };
47
+ if (newActiveFilters[filter]?.includes(field)) {
48
+ newActiveFilters[filter].splice(
49
+ newActiveFilters[filter].indexOf(field),
50
+ 1,
51
+ );
52
+ } else {
53
+ newActiveFilters[filter] = [
54
+ ...(activeFilters[filter] || []),
55
+ field,
56
+ ];
57
+ }
58
+ if (!newActiveFilters[filter].length) {
59
+ delete newActiveFilters[filter];
60
+ }
61
+ setActiveFilters(newActiveFilters);
62
+ }}
63
+ />
64
+ <p className="count">{filters[filter][field]}</p>
65
+ </div>
66
+ ))}
67
+ </div>
68
+ );
69
+ };
70
+
71
+ const View = (props) => {
72
+ const [visible, setVisible] = React.useState(false);
73
+ const [filters, setFilters] = React.useState({});
74
+ const {
75
+ provider_data,
76
+ activeFilters,
77
+ filteredSpecies,
78
+ pagination,
79
+ sortBy,
80
+ species,
81
+ setActiveFilters,
82
+ setPagination,
83
+ setSortBy,
84
+ } = props;
85
+ const itemsPerPageOptions = [
86
+ { key: '10', text: '10', value: 10 },
87
+ { key: '25', text: '25', value: 25 },
88
+ { key: '50', text: '50', value: 50 },
89
+ { key: '100', text: '100', value: 100 },
90
+ ];
91
+
92
+ const updateFilters = () => {
93
+ const newFilters = {};
94
+ Object.keys(filtersLabels).forEach((filter) => {
95
+ newFilters[filter] = {};
96
+ for (let key in filtersLabels[filter]) {
97
+ if (key !== 'getTitle') {
98
+ newFilters[filter][key] =
99
+ filteredSpecies.filter((species) => {
100
+ return !!species.filter((specimen) => specimen[filter] === key)
101
+ .length;
102
+ }).length || 'none';
103
+ }
104
+ }
105
+ });
106
+ setFilters(newFilters);
107
+ };
108
+
109
+ React.useEffect(() => {
110
+ if (provider_data && species.length) {
111
+ updateFilters();
112
+ }
113
+ /* eslint-disable-next-line */
114
+ }, [filteredSpecies]);
115
+
116
+ return (
117
+ <div className="species-filters">
118
+ <SpeciesGroups {...props} />
119
+ <Container>
120
+ <div className="active-filters">
121
+ {Object.keys(activeFilters).map((filter) =>
122
+ activeFilters[filter].map((field) => (
123
+ <Label
124
+ className="active-filter"
125
+ key={`active-filter-${field}`}
126
+ as="span"
127
+ >
128
+ {filtersLabels[filter][field]}
129
+ <Icon
130
+ name={clearSVG}
131
+ size="18px"
132
+ onClick={() => {
133
+ const newActiveFilters = { ...activeFilters };
134
+ if (newActiveFilters[filter]?.includes(field)) {
135
+ newActiveFilters[filter].splice(
136
+ newActiveFilters[filter].indexOf(field),
137
+ 1,
138
+ );
139
+ }
140
+ if (!newActiveFilters[filter].length) {
141
+ delete newActiveFilters[filter];
142
+ }
143
+ setActiveFilters(newActiveFilters);
144
+ }}
145
+ />
146
+ </Label>
147
+ )),
148
+ )}
149
+ </div>
150
+ <div className="toolbar">
151
+ <SortBy sortBy={sortBy} setSortBy={setSortBy} />
152
+ <Dropdown
153
+ aria-label="Set number of species per page"
154
+ placeholder="Items per page"
155
+ value={pagination.itemsPerPage}
156
+ floating
157
+ button
158
+ options={itemsPerPageOptions}
159
+ onChange={(e, data) => {
160
+ setPagination({ ...pagination, itemsPerPage: data.value });
161
+ }}
162
+ />
163
+ <button aria-label="Set filters" onClick={() => setVisible(!visible)}>
164
+ <Icon name={filterSVG} size="24px" />
165
+ </button>
166
+ </div>
167
+ </Container>
168
+ <Sidebar
169
+ as="div"
170
+ animation="overlay"
171
+ direction="right"
172
+ onHide={() => setVisible(false)}
173
+ vertical
174
+ visible={visible}
175
+ width="wide"
176
+ >
177
+ <div className="sidebar-header">
178
+ <p className="title">Filters</p>
179
+ <button className="clear-button" onClick={() => setVisible(false)}>
180
+ <Icon name={clearSVG} size="20px" color="#fff" />
181
+ </button>
182
+ </div>
183
+ <div className="filters">
184
+ {Object.keys(filters).map((filter, index) => (
185
+ <SidebarFilter
186
+ key={filter}
187
+ index={index}
188
+ activeFilters={activeFilters}
189
+ filters={filters}
190
+ filter={filter}
191
+ setActiveFilters={setActiveFilters}
192
+ />
193
+ ))}
194
+ </div>
195
+ </Sidebar>
196
+ </div>
197
+ );
198
+ };
199
+
200
+ export default View;
@@ -0,0 +1,4 @@
1
+ import SpeciesGroupsFilter from './SpeciesGroups';
2
+ import Filters from './View';
3
+
4
+ export { SpeciesGroupsFilter, Filters };