@eeacms/volto-clms-theme 1.1.153 → 1.1.154
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 +11 -0
- package/package.json +1 -1
- package/src/components/CLMSDatasetDetailView/DataSetInfoContent.jsx +28 -29
- package/src/components/CLMSDatasetDetailView/DownloadDataSetContent.jsx +32 -31
- package/src/components/CLMSTechnicalLibraryView/CLMSTechnicalLibraryView.jsx +6 -1
- package/src/components/CclUtils/index.js +1 -0
- package/src/components/CclUtils/sanitizedHTML.js +11 -0
- package/src/components/CclUtils/sanitizedHTML.test.js +22 -0
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.1.154](https://github.com/eea/volto-clms-theme/compare/1.1.153...1.1.154) - 23 May 2024
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- fix [Mikel Larreategi - [`709240b`](https://github.com/eea/volto-clms-theme/commit/709240bc8ed40d07a11fbfc385f334a0bc9547e6)]
|
|
12
|
+
- simplify conditions [Mikel Larreategi - [`37ae35d`](https://github.com/eea/volto-clms-theme/commit/37ae35dbdf1832e8d9cc2bc57d696ddef2d770d6)]
|
|
13
|
+
- rename function [Mikel Larreategi - [`fa4efb0`](https://github.com/eea/volto-clms-theme/commit/fa4efb0fad0d0bdb745ec0821aa271b3fdfabe37)]
|
|
14
|
+
- add tsets [Mikel Larreategi - [`68cd6d0`](https://github.com/eea/volto-clms-theme/commit/68cd6d0e4aaa084c1a723a4614cf2d1ca1fed41b)]
|
|
15
|
+
- fix [Unai Etxaburu - [`95eaff9`](https://github.com/eea/volto-clms-theme/commit/95eaff909334117782059acb0fc815f217d7099d)]
|
|
16
|
+
- isEmpty util created to secure no empty html is stored in dataset data [Unai Etxaburu - [`48f2143`](https://github.com/eea/volto-clms-theme/commit/48f21430975eaaf9f1f6ebdc2eea8cb62af449c9)]
|
|
17
|
+
- add subject param to the on demand TL rendering link [Ion Lizarazu - [`8e90ff4`](https://github.com/eea/volto-clms-theme/commit/8e90ff4f84bc3e4d38db2e004f3d822c13f9a1af)]
|
|
7
18
|
### [1.1.153](https://github.com/eea/volto-clms-theme/compare/1.1.152...1.1.153) - 22 May 2024
|
|
8
19
|
|
|
9
20
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
|
16
16
|
import { hasBlocksData } from '@plone/volto/helpers';
|
|
17
17
|
|
|
18
18
|
import './datasetinfocontent.less';
|
|
19
|
+
import { sanitizedHTML } from '../CclUtils';
|
|
19
20
|
|
|
20
21
|
const DataSetInfoContent = (props) => {
|
|
21
22
|
const dispatch = useDispatch();
|
|
@@ -24,6 +25,12 @@ const DataSetInfoContent = (props) => {
|
|
|
24
25
|
const searchSubrequests = useSelector((state) => state.search.subrequests);
|
|
25
26
|
let libraries = searchSubrequests?.[id]?.items || [];
|
|
26
27
|
let librariesPending = searchSubrequests?.[id]?.loading;
|
|
28
|
+
let validationClearHTMLTags = sanitizedHTML(validation?.data);
|
|
29
|
+
let citationClearHTMLTags = sanitizedHTML(citation?.data);
|
|
30
|
+
let technical_documents_accordion_text = sanitizedHTML(
|
|
31
|
+
props.technical_documents_accordion_text?.data,
|
|
32
|
+
);
|
|
33
|
+
|
|
27
34
|
React.useEffect(() => {
|
|
28
35
|
if (UID) {
|
|
29
36
|
dispatch(
|
|
@@ -115,24 +122,20 @@ const DataSetInfoContent = (props) => {
|
|
|
115
122
|
''
|
|
116
123
|
)}
|
|
117
124
|
</CclInfoContainer>
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
marginBottom={true}
|
|
133
|
-
children={<StringToHTML string={citation?.data} />}
|
|
134
|
-
></CclCitation>
|
|
135
|
-
)}
|
|
125
|
+
{validationClearHTMLTags !== '' && (
|
|
126
|
+
<CclCitation
|
|
127
|
+
title="Validation status"
|
|
128
|
+
marginBottom={true}
|
|
129
|
+
children={<StringToHTML string={validation.data} />}
|
|
130
|
+
></CclCitation>
|
|
131
|
+
)}
|
|
132
|
+
{citationClearHTMLTags !== '' && (
|
|
133
|
+
<CclCitation
|
|
134
|
+
title="Dataset citation"
|
|
135
|
+
marginBottom={true}
|
|
136
|
+
children={<StringToHTML string={citation?.data} />}
|
|
137
|
+
></CclCitation>
|
|
138
|
+
)}
|
|
136
139
|
<div className="dataset-info-documents dropdown">
|
|
137
140
|
<div className="accordion-block">
|
|
138
141
|
{renderAccordion(geonetwork_identifiers?.items, libraries) && (
|
|
@@ -317,17 +320,13 @@ const DataSetInfoContent = (props) => {
|
|
|
317
320
|
duration={500}
|
|
318
321
|
height={'auto'}
|
|
319
322
|
>
|
|
320
|
-
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
props.technical_documents_accordion_text?.data
|
|
328
|
-
}
|
|
329
|
-
/>
|
|
330
|
-
)}
|
|
323
|
+
{technical_documents_accordion_text !== '' && (
|
|
324
|
+
<StringToHTML
|
|
325
|
+
string={
|
|
326
|
+
props.technical_documents_accordion_text?.data
|
|
327
|
+
}
|
|
328
|
+
/>
|
|
329
|
+
)}
|
|
331
330
|
<CclRelatedListingView
|
|
332
331
|
id={'dataset-info-technicals'}
|
|
333
332
|
properties={{ ...props }}
|
|
@@ -5,11 +5,23 @@ import { useSelector } from 'react-redux';
|
|
|
5
5
|
import CclButton from '@eeacms/volto-clms-theme/components/CclButton/CclButton';
|
|
6
6
|
import CclDownloadTable from '@eeacms/volto-clms-theme/components/CclDownloadTable/CclDownloadTable';
|
|
7
7
|
import CclLoginModal from '@eeacms/volto-clms-theme/components/CclLoginModal/CclLoginModal';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
StringToHTML,
|
|
10
|
+
sanitizedHTML,
|
|
11
|
+
} from '@eeacms/volto-clms-theme/components/CclUtils';
|
|
9
12
|
|
|
10
13
|
const DownloadDataSetContent = (data, token) => {
|
|
11
14
|
const user = useSelector((state) => state?.users?.user);
|
|
12
15
|
const locale = useSelector((state) => state?.intl?.locale);
|
|
16
|
+
let download_other_ways_access_dataset = sanitizedHTML(
|
|
17
|
+
data.download_other_ways_access_dataset?.data,
|
|
18
|
+
);
|
|
19
|
+
let download_full_dataset_text = sanitizedHTML(
|
|
20
|
+
data.download_full_dataset_text?.data,
|
|
21
|
+
);
|
|
22
|
+
let download_by_area_extra_text = sanitizedHTML(
|
|
23
|
+
data.download_by_area_extra_text?.data,
|
|
24
|
+
);
|
|
13
25
|
|
|
14
26
|
return (
|
|
15
27
|
<div>
|
|
@@ -66,42 +78,31 @@ const DownloadDataSetContent = (data, token) => {
|
|
|
66
78
|
</div>
|
|
67
79
|
)}
|
|
68
80
|
|
|
69
|
-
{data?.downloadable_full_dataset &&
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<StringToHTML
|
|
75
|
-
string={data.download_by_area_extra_text?.data || ''}
|
|
76
|
-
/>
|
|
77
|
-
</div>
|
|
78
|
-
)}
|
|
81
|
+
{data?.downloadable_full_dataset && download_by_area_extra_text !== '' && (
|
|
82
|
+
<div className="dataset-download-area">
|
|
83
|
+
<StringToHTML string={data.download_by_area_extra_text?.data || ''} />
|
|
84
|
+
</div>
|
|
85
|
+
)}
|
|
79
86
|
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
string={data.download_full_dataset_text?.data || ''}
|
|
87
|
-
/>
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
87
|
+
{download_full_dataset_text !== '' && (
|
|
88
|
+
<div className="dataset-download-area">
|
|
89
|
+
<h2>Download full dataset</h2>
|
|
90
|
+
<StringToHTML string={data.download_full_dataset_text?.data || ''} />
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
90
93
|
|
|
91
94
|
{data.downloadable_files?.items?.length > 0 && (
|
|
92
95
|
<CclDownloadTable dataset={data}></CclDownloadTable>
|
|
93
96
|
)}
|
|
94
97
|
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
98
|
+
{download_other_ways_access_dataset !== '' && (
|
|
99
|
+
<div className="dataset-access-container">
|
|
100
|
+
<h2>You can also access this dataset</h2>
|
|
101
|
+
<StringToHTML
|
|
102
|
+
string={data?.download_other_ways_access_dataset?.data || ''}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
)}
|
|
105
106
|
</div>
|
|
106
107
|
);
|
|
107
108
|
};
|
|
@@ -7,6 +7,9 @@ const CLMSTechnicalLibraryView = (props) => {
|
|
|
7
7
|
const textToForm = encodeURIComponent(
|
|
8
8
|
`I want the following document ${content.title} ${content['@id']}`,
|
|
9
9
|
);
|
|
10
|
+
const subjectToForm = encodeURIComponent(
|
|
11
|
+
'I want to ask for an on-demand document',
|
|
12
|
+
);
|
|
10
13
|
|
|
11
14
|
return (
|
|
12
15
|
<div className="ccl-container">
|
|
@@ -22,7 +25,9 @@ const CLMSTechnicalLibraryView = (props) => {
|
|
|
22
25
|
<>
|
|
23
26
|
<p>
|
|
24
27
|
You are requesting an on-demand document. Please contact the{' '}
|
|
25
|
-
<a
|
|
28
|
+
<a
|
|
29
|
+
href={`/en/contact-service-helpdesk?text=${textToForm}&subject=${subjectToForm}`}
|
|
30
|
+
>
|
|
26
31
|
service desk
|
|
27
32
|
</a>{' '}
|
|
28
33
|
to obtain it.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const sanitizedHTML = (strToSanitize) => {
|
|
2
|
+
if (strToSanitize === undefined) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
const parser = new DOMParser();
|
|
6
|
+
let myHTML = parser.parseFromString(strToSanitize, 'text/html');
|
|
7
|
+
// let test = strToSanitize.replace(/(<([^>]+)>)/gi, '');
|
|
8
|
+
// console.log('myHTML', myHTML);
|
|
9
|
+
// console.log('test', test);
|
|
10
|
+
return myHTML.body.textContent || '';
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { sanitizedHTML } from './sanitizedHTML';
|
|
2
|
+
|
|
3
|
+
describe('Test empty things', () => {
|
|
4
|
+
it('Undefined', () => {
|
|
5
|
+
expect(sanitizedHTML(undefined)).toBe('');
|
|
6
|
+
});
|
|
7
|
+
it('Empty HTML P', () => {
|
|
8
|
+
expect(sanitizedHTML('<p></p>')).toBe('');
|
|
9
|
+
});
|
|
10
|
+
it('Empty HTML P with br', () => {
|
|
11
|
+
expect(sanitizedHTML('<p><br/></p>')).toBe('');
|
|
12
|
+
});
|
|
13
|
+
it('Empty HTML P with br and body', () => {
|
|
14
|
+
expect(sanitizedHTML('<html><body><p><br/></p></body></html>')).toBe('');
|
|
15
|
+
});
|
|
16
|
+
it('Some content', () => {
|
|
17
|
+
expect(sanitizedHTML('<strong>Some content</strong>')).toBe('Some content');
|
|
18
|
+
});
|
|
19
|
+
it('Some content with spaces', () => {
|
|
20
|
+
expect(sanitizedHTML('<strong> </strong>')).toBe(' ');
|
|
21
|
+
});
|
|
22
|
+
});
|