@eeacms/volto-n2k 1.1.1 → 1.1.3
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 +19 -2
- package/package.json +1 -1
- package/src/components/manage/Blocks/ExploreHabitats/View.jsx +71 -66
- package/src/components/manage/Blocks/HabitatsBanner/View.jsx +4 -1
- package/src/components/manage/Blocks/ImageText/Edit.jsx +1 -2
- package/src/components/manage/Blocks/SiteHabitatsList/Filters/HabitatsGroups.jsx +49 -0
- package/src/components/manage/Blocks/SiteHabitatsList/Filters/SortBy.jsx +52 -0
- package/src/components/manage/Blocks/SiteHabitatsList/Filters/View.jsx +201 -0
- package/src/components/manage/Blocks/SiteHabitatsList/Filters/index.js +4 -0
- package/src/components/manage/Blocks/SiteHabitatsList/View.jsx +214 -84
- package/src/components/manage/Blocks/SiteHabitatsList/style.less +256 -45
- package/src/components/manage/Blocks/SiteHabitatsList/utils.js +33 -0
- package/src/components/manage/Blocks/SiteHabitatsListOld/View.jsx +106 -0
- package/src/components/manage/Blocks/SiteHabitatsListOld/index.js +17 -0
- package/src/components/manage/Blocks/SiteHabitatsListOld/schema.js +19 -0
- package/src/components/manage/Blocks/SiteHabitatsListOld/style.less +70 -0
- package/src/components/manage/Blocks/SiteProtectedHabitats/View.jsx +11 -9
- package/src/components/manage/Blocks/SiteProtectedSpecies/View.jsx +11 -9
- package/src/components/manage/Blocks/SiteSpeciesList/Filters/SortBy.jsx +1 -1
- package/src/components/manage/Blocks/SiteSpeciesList/Filters/SpeciesGroups.jsx +10 -4
- package/src/components/manage/Blocks/SiteSpeciesList/Filters/View.jsx +1 -0
- package/src/components/manage/Blocks/SiteSpeciesList/style.less +30 -22
- package/src/components/manage/Blocks/SpeciesBanner/View.jsx +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import findIndex from 'lodash/findIndex';
|
|
3
|
+
import { Icon } from '@plone/volto/components';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { getObjectByIndex } from '@eeacms/volto-n2k/helpers';
|
|
7
|
+
import downKeySVG from '@plone/volto/icons/down-key.svg';
|
|
8
|
+
import upKeySVG from '@plone/volto/icons/up-key.svg';
|
|
9
|
+
import './style.less';
|
|
10
|
+
|
|
11
|
+
const View = (props) => {
|
|
12
|
+
const [habitats, setHabitats] = React.useState({});
|
|
13
|
+
const [expandedHabitats, setExpandedHabitats] = React.useState([]);
|
|
14
|
+
const { provider_data = {}, placeholder = 'No results' } = props;
|
|
15
|
+
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
const newHabitats = {};
|
|
18
|
+
if (provider_data?.habitat_group?.length) {
|
|
19
|
+
provider_data.habitat_group.forEach((habitat, index) => {
|
|
20
|
+
if (!newHabitats[habitat]) {
|
|
21
|
+
newHabitats[habitat] = [];
|
|
22
|
+
}
|
|
23
|
+
newHabitats[habitat].push(getObjectByIndex(provider_data, index));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
setHabitats(newHabitats);
|
|
27
|
+
/* eslint-disable-next-line */
|
|
28
|
+
}, [JSON.stringify(provider_data)]);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="site-habitats-list">
|
|
32
|
+
{Object.keys(habitats)?.length ? (
|
|
33
|
+
Object.keys(habitats)
|
|
34
|
+
.sort((a, b) => a.localeCompare(b))
|
|
35
|
+
.map((habitat) => {
|
|
36
|
+
const expanded = expandedHabitats.includes(habitat);
|
|
37
|
+
return (
|
|
38
|
+
<div className="habitat" key={habitat}>
|
|
39
|
+
<div
|
|
40
|
+
className={cx({
|
|
41
|
+
'habitat-toolbar': true,
|
|
42
|
+
marginless: !expanded,
|
|
43
|
+
})}
|
|
44
|
+
>
|
|
45
|
+
<div className="habitat-name">
|
|
46
|
+
<h3>{habitat}</h3>
|
|
47
|
+
<p className="count">{habitats[habitat].length}</p>
|
|
48
|
+
</div>
|
|
49
|
+
<Icon
|
|
50
|
+
name={expanded ? upKeySVG : downKeySVG}
|
|
51
|
+
onClick={(e) => {
|
|
52
|
+
const index = findIndex(
|
|
53
|
+
expandedHabitats,
|
|
54
|
+
(name) => name === habitat,
|
|
55
|
+
);
|
|
56
|
+
if (index === -1) {
|
|
57
|
+
setExpandedHabitats((prevExpandedHabitats) => [
|
|
58
|
+
...prevExpandedHabitats,
|
|
59
|
+
habitat,
|
|
60
|
+
]);
|
|
61
|
+
} else {
|
|
62
|
+
setExpandedHabitats((prevExpandedHabitats) => {
|
|
63
|
+
const newExpandedHabitats = [...prevExpandedHabitats];
|
|
64
|
+
newExpandedHabitats.splice(index, 1);
|
|
65
|
+
return newExpandedHabitats;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
}}
|
|
71
|
+
color="#8C8C8C"
|
|
72
|
+
size="32px"
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
{expanded
|
|
77
|
+
? habitats[habitat].map((item, index) => (
|
|
78
|
+
<div
|
|
79
|
+
className="habitat-item"
|
|
80
|
+
key={`${habitat}-${index}-item`}
|
|
81
|
+
>
|
|
82
|
+
<Link
|
|
83
|
+
className="description"
|
|
84
|
+
to={`/habitats/${item.code_2000}`}
|
|
85
|
+
>
|
|
86
|
+
{item.habitat_description} ({item.code_2000})
|
|
87
|
+
</Link>
|
|
88
|
+
<p className="coverage">
|
|
89
|
+
{item.coverage_ha.toFixed(2)} ha (
|
|
90
|
+
{(item.coverage_ha / 100).toFixed(4)} km
|
|
91
|
+
<sup>2</sup>)
|
|
92
|
+
</p>
|
|
93
|
+
</div>
|
|
94
|
+
))
|
|
95
|
+
: ''}
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
})
|
|
99
|
+
) : (
|
|
100
|
+
<p>{placeholder}</p>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default View;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// import SiteHabitatsList from './View';
|
|
2
|
+
// import getSchema from './schema';
|
|
3
|
+
|
|
4
|
+
export default function applyConfig(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_habitats_list: {
|
|
10
|
+
// view: SiteHabitatsList,
|
|
11
|
+
// getSchema: getSchema,
|
|
12
|
+
// title: 'Site habitats list',
|
|
13
|
+
// },
|
|
14
|
+
// },
|
|
15
|
+
// };
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
.site-habitats-list {
|
|
2
|
+
.icon {
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.habitat {
|
|
7
|
+
padding: 1rem 2rem;
|
|
8
|
+
border: 1px solid #e8e8e8;
|
|
9
|
+
border-radius: 10px;
|
|
10
|
+
margin-bottom: 1rem;
|
|
11
|
+
background-color: #fff !important;
|
|
12
|
+
|
|
13
|
+
.habitat-toolbar {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
margin-bottom: 1rem;
|
|
18
|
+
|
|
19
|
+
&.marginless {
|
|
20
|
+
margin-bottom: 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.habitat-name {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
|
|
28
|
+
h3 {
|
|
29
|
+
margin-right: 1rem;
|
|
30
|
+
margin-bottom: 0;
|
|
31
|
+
color: #013c60;
|
|
32
|
+
font-weight: 400;
|
|
33
|
+
line-height: 25px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.count {
|
|
37
|
+
width: 24px;
|
|
38
|
+
height: 24px;
|
|
39
|
+
border-radius: 6px;
|
|
40
|
+
margin-bottom: 0;
|
|
41
|
+
background-color: #00a390;
|
|
42
|
+
color: #fff !important;
|
|
43
|
+
font-weight: bold;
|
|
44
|
+
line-height: 24px;
|
|
45
|
+
text-align: center;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.habitat-item {
|
|
50
|
+
.description {
|
|
51
|
+
color: #013c60;
|
|
52
|
+
font-size: 1.2rem;
|
|
53
|
+
font-weight: 400;
|
|
54
|
+
|
|
55
|
+
&:hover {
|
|
56
|
+
opacity: 0.9;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.coverage {
|
|
61
|
+
color: #8c8c8c;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
p {
|
|
65
|
+
margin-bottom: 0;
|
|
66
|
+
}
|
|
67
|
+
margin-bottom: 1rem;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -27,16 +27,18 @@ const View = (props) => {
|
|
|
27
27
|
<div className="habitats-container">
|
|
28
28
|
<Container className="habitats-wrapper">
|
|
29
29
|
<div className="habitats-wrapper">
|
|
30
|
-
{Object.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
{Object.keys(habitats)
|
|
31
|
+
.sort((a, b) => a.localeCompare(b))
|
|
32
|
+
.map((habitat, index) => (
|
|
33
|
+
<div key={index} className="habitat-box">
|
|
34
|
+
<div className="upper">
|
|
35
|
+
<span>{habitats[habitat].length}</span>
|
|
36
|
+
</div>
|
|
37
|
+
<div className="lower">
|
|
38
|
+
<span>{habitat}</span>
|
|
39
|
+
</div>
|
|
34
40
|
</div>
|
|
35
|
-
|
|
36
|
-
<span>{habitat}</span>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
))}
|
|
41
|
+
))}
|
|
40
42
|
</div>
|
|
41
43
|
</Container>
|
|
42
44
|
</div>
|
|
@@ -35,16 +35,18 @@ const View = (props) => {
|
|
|
35
35
|
</Grid.Row>
|
|
36
36
|
</Grid> */}
|
|
37
37
|
<div className="species-wrapper">
|
|
38
|
-
{Object.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
{Object.keys(data)
|
|
39
|
+
.sort((a, b) => a.localeCompare(b))
|
|
40
|
+
.map((species, index) => (
|
|
41
|
+
<div key={index} className="species-box">
|
|
42
|
+
<div className="upper">
|
|
43
|
+
<span>{data[species]}</span>
|
|
44
|
+
</div>
|
|
45
|
+
<div className="lower">
|
|
46
|
+
<span>{species}</span>
|
|
47
|
+
</div>
|
|
45
48
|
</div>
|
|
46
|
-
|
|
47
|
-
))}
|
|
49
|
+
))}
|
|
48
50
|
</div>
|
|
49
51
|
</Container>
|
|
50
52
|
</div>
|
|
@@ -13,7 +13,7 @@ const View = (props) => {
|
|
|
13
13
|
const { sortBy, setSortBy } = props;
|
|
14
14
|
|
|
15
15
|
const sortByOptions = [
|
|
16
|
-
{ text: '
|
|
16
|
+
{ text: 'Name', value: 'scientific_name', key: 'scientific_name' },
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
return (
|
|
@@ -11,10 +11,16 @@ const SpeciesGroups = (props) => {
|
|
|
11
11
|
} = props;
|
|
12
12
|
|
|
13
13
|
React.useEffect(() => {
|
|
14
|
-
setSpeciesGroups(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
setSpeciesGroups(
|
|
15
|
+
[
|
|
16
|
+
...(provider_data.species_group_name?.length ? ['All'] : []),
|
|
17
|
+
...new Set(provider_data.species_group_name || []),
|
|
18
|
+
].sort((a, b) => {
|
|
19
|
+
if (a === 'All') return -1;
|
|
20
|
+
if (b === 'All') return 1;
|
|
21
|
+
return a.localeCompare(b);
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
18
24
|
/* eslint-disable-next-line */
|
|
19
25
|
}, [JSON.stringify(provider_data)]);
|
|
20
26
|
|
|
@@ -49,39 +49,47 @@ div#view .site-species-list .species-list .ui.container > * {
|
|
|
49
49
|
.species-groups {
|
|
50
50
|
margin-bottom: 1rem;
|
|
51
51
|
background-color: #00a390;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
|
|
54
|
+
button.species-group {
|
|
55
|
+
padding: 1rem;
|
|
56
|
+
border: none;
|
|
57
|
+
background-color: transparent;
|
|
58
|
+
color: #fff !important;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
font-size: 16px;
|
|
61
|
+
text-transform: uppercase;
|
|
62
|
+
|
|
63
|
+
&::after {
|
|
64
|
+
display: block;
|
|
65
|
+
width: calc(100% + 8px);
|
|
66
|
+
height: 3px;
|
|
67
|
+
margin-top: 2px;
|
|
68
|
+
background: transparent;
|
|
69
|
+
content: '';
|
|
70
|
+
transform: translateX(-4px);
|
|
61
71
|
}
|
|
62
72
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
color: #fff !important;
|
|
68
|
-
cursor: pointer;
|
|
69
|
-
font-size: 16px;
|
|
70
|
-
text-transform: uppercase;
|
|
71
|
-
|
|
72
|
-
&.active,
|
|
73
|
-
&:hover {
|
|
74
|
-
padding-bottom: calc(1rem - 3px);
|
|
75
|
-
border-bottom: 3px solid #fff;
|
|
73
|
+
&.active,
|
|
74
|
+
&:hover {
|
|
75
|
+
&::after {
|
|
76
|
+
background: #ffffff;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
}
|
|
80
|
+
|
|
81
|
+
.ui.container {
|
|
82
|
+
display: block;
|
|
83
|
+
overflow-x: auto;
|
|
84
|
+
text-align: center;
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
.ui.sidebar {
|
|
82
89
|
background-color: #fff !important;
|
|
83
90
|
|
|
84
91
|
&.right.visible {
|
|
92
|
+
z-index: 800;
|
|
85
93
|
box-shadow: 0px 0px 13px -5px #000000;
|
|
86
94
|
}
|
|
87
95
|
|
|
@@ -12,6 +12,7 @@ import arrowLeft from '@eeacms/volto-n2k/icons/arrow-left.svg';
|
|
|
12
12
|
import arrowRight from '@eeacms/volto-n2k/icons/arrow-right.svg';
|
|
13
13
|
|
|
14
14
|
import './style.less';
|
|
15
|
+
import 'swiper/css';
|
|
15
16
|
|
|
16
17
|
const SwiperLoader = loadable.lib(() => import('swiper'));
|
|
17
18
|
const SwiperReactLoader = loadable.lib(() => import('swiper/react'));
|