@eeacms/volto-datahub 1.0.19 → 1.0.21

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,6 +4,17 @@ 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.21](https://github.com/eea/volto-datahub/compare/1.0.20...1.0.21) - 15 March 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Add read more for description [kreafox - [`ef255b7`](https://github.com/eea/volto-datahub/commit/ef255b731cfb5c1269006a3f611848bc244ad2bd)]
12
+ ### [1.0.20](https://github.com/eea/volto-datahub/compare/1.0.19...1.0.20) - 14 March 2023
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - Fix archived item condition [kreafox - [`8c0d70a`](https://github.com/eea/volto-datahub/commit/8c0d70afc7429b7c0382350d291ea68e7a55e37b)]
17
+ - Add archived label [kreafox - [`be58335`](https://github.com/eea/volto-datahub/commit/be583359b5de2a198a13c55b1191e2f8b7dab193)]
7
18
  ### [1.0.19](https://github.com/eea/volto-datahub/compare/1.0.18...1.0.19) - 14 March 2023
8
19
 
9
20
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "@eeacms/volto-datahub: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Accordion } from 'semantic-ui-react';
3
3
  import { Icon } from 'semantic-ui-react';
4
4
  import { DateTime } from '@eeacms/search';
5
- import { isInternal, SVGIcon } from '../utils.js';
5
+ import { isInternal, SVGIcon, isObsolete } from '../utils.js';
6
6
  import DatasetItemDownloadList from './DatasetItemDownloadList';
7
7
 
8
8
  import lockSVG from 'remixicon/icons/System/lock-line.svg';
@@ -34,6 +34,8 @@ const DatasetItemsList = (props) => {
34
34
  temporalDateRange,
35
35
  publicationDateForResource,
36
36
  } = dataset;
37
+ const archived = isObsolete(dataset.cl_status);
38
+
37
39
  return (
38
40
  <React.Fragment key={index}>
39
41
  <Accordion.Title
@@ -43,12 +45,13 @@ const DatasetItemsList = (props) => {
43
45
  >
44
46
  <span className="dataset-title">
45
47
  {dataset.resourceTitleObject.default}
48
+
46
49
  <span className="formats">
47
50
  {(dataset.format || [])
48
51
  .filter((item, pos, self) => self.indexOf(item) === pos)
49
52
  .map((item, i) => {
50
53
  return (
51
- <span className="format-label" key={i}>
54
+ <span className="dh-label" key={i}>
52
55
  {item}
53
56
  </span>
54
57
  );
@@ -61,7 +64,7 @@ const DatasetItemsList = (props) => {
61
64
  .filter((item, pos, self) => self.indexOf(item) === pos)
62
65
  .map((item, i) => {
63
66
  return (
64
- <span className="format-label" key={i}>
67
+ <span className="dh-label" key={i}>
65
68
  {item}
66
69
  </span>
67
70
  );
@@ -70,15 +73,17 @@ const DatasetItemsList = (props) => {
70
73
  ) : (
71
74
  <>
72
75
  {['ESRI', 'OGC'].includes(dataset.linkProtocol) && (
73
- <span className="format-label">
74
- {dataset.linkProtocol}
75
- </span>
76
+ <span className="dh-label">{dataset.linkProtocol}</span>
76
77
  )}
77
78
  </>
78
79
  )}
79
- </span>
80
80
 
81
- {isInternal(dataset) && <SVGIcon name={lockSVG} size="18" />}
81
+ {archived && (
82
+ <span className="dh-label inverted">Archived</span>
83
+ )}
84
+
85
+ {isInternal(dataset) && <SVGIcon name={lockSVG} size="18" />}
86
+ </span>
82
87
  </span>
83
88
  <Icon className="ri-arrow-down-s-line" />
84
89
  </Accordion.Title>
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Portal } from 'react-portal';
3
3
  import { useDispatch, useSelector } from 'react-redux';
4
4
  import { Link, useLocation } from 'react-router-dom';
5
- import { Container, Icon } from 'semantic-ui-react';
5
+ import { Container, Icon, Button } from 'semantic-ui-react';
6
6
  import { Toolbar } from '@plone/volto/components';
7
7
  import { BodyClass } from '@plone/volto/helpers';
8
8
  import config from '@plone/volto/registry';
@@ -21,6 +21,21 @@ import { setDatahubResult } from '@eeacms/volto-datahub/store';
21
21
  import { isObsolete } from './utils.js';
22
22
 
23
23
  const appName = 'datahub';
24
+ const WORD_COUNT = 60;
25
+
26
+ const splitContent = (content, wordCount) => {
27
+ const words = content.split(' ');
28
+ let firstTextPart = '',
29
+ secondTextPart = '';
30
+ words.forEach((word, idx) => {
31
+ if (idx < wordCount) {
32
+ firstTextPart += ' ' + word;
33
+ } else {
34
+ secondTextPart += ' ' + word;
35
+ }
36
+ });
37
+ return [firstTextPart.trim(), secondTextPart.trim()];
38
+ };
24
39
 
25
40
  function IsomorphicPortal({ children }) {
26
41
  const [isClient, setIsClient] = React.useState();
@@ -75,6 +90,13 @@ function ItemView(props) {
75
90
 
76
91
  const rawTitle = item && item._meta.found ? title?.raw || '' : docid;
77
92
 
93
+ const splitDescription = description?.raw.split(' ').length > WORD_COUNT;
94
+ const [firstTextPart, secondTextPart] = splitContent(
95
+ description?.raw,
96
+ WORD_COUNT,
97
+ );
98
+ const [isReadMore, setIsReadMore] = React.useState(false);
99
+
78
100
  React.useEffect(() => {
79
101
  const handler = async () => {
80
102
  if (item) {
@@ -139,7 +161,21 @@ function ItemView(props) {
139
161
  </IsomorphicPortal>
140
162
 
141
163
  <div className="dataset-container">
142
- <Callout>{description?.raw}</Callout>
164
+ <Callout>
165
+ {splitDescription ? (
166
+ <p>
167
+ {firstTextPart} {isReadMore ? secondTextPart : ''}
168
+ <Button
169
+ onClick={() => setIsReadMore(!isReadMore)}
170
+ className={`see-more ${isReadMore ? 'open' : 'close'}`}
171
+ >
172
+ {isReadMore ? 'See less' : ' See more'}
173
+ </Button>
174
+ </p>
175
+ ) : (
176
+ <p>{description?.raw}</p>
177
+ )}
178
+ </Callout>
143
179
  </div>
144
180
 
145
181
  <DatasetsView item={item} appConfig={appConfig} />