design-comuni-plone-theme 10.0.0 → 10.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.
- package/CHANGELOG.md +21 -0
- package/locales/de/LC_MESSAGES/volto.po +2 -0
- package/locales/en/LC_MESSAGES/volto.po +2 -0
- package/locales/es/LC_MESSAGES/volto.po +2 -0
- package/locales/fr/LC_MESSAGES/volto.po +2 -0
- package/locales/it/LC_MESSAGES/volto.po +2 -0
- package/locales/volto.pot +3 -1
- package/package.json +1 -1
- package/src/components/ItaliaTheme/GalleryPreview/GalleryPreview.jsx +2 -2
- package/src/components/ItaliaTheme/View/BandoView/BandoView.jsx +3 -10
- package/src/components/ItaliaTheme/View/Commons/SideMenu.jsx +3 -0
- package/src/components/ItaliaTheme/View/Commons/SideMenuByTitles.jsx +212 -0
- package/src/components/ItaliaTheme/View/DocumentoView/DocumentoView.jsx +4 -11
- package/src/components/ItaliaTheme/View/EventoView/EventoView.jsx +3 -11
- package/src/components/ItaliaTheme/View/NewsItemView/NewsItemView.jsx +6 -16
- package/src/components/ItaliaTheme/View/PaginaArgomentoView/PaginaArgomentoViewNoBlocks.jsx +3 -11
- package/src/components/ItaliaTheme/View/PersonaView/PersonaView.jsx +3 -10
- package/src/components/ItaliaTheme/View/ServizioView/ServizioView.jsx +3 -10
- package/src/components/ItaliaTheme/View/UOView/UOView.jsx +3 -9
- package/src/components/ItaliaTheme/View/VenueView/VenueView.jsx +3 -11
- package/src/components/ItaliaTheme/View/ViewUtils.jsx +69 -1
- package/src/components/ItaliaTheme/View/index.js +6 -0
- package/src/config/italiaConfig.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [10.1.1](https://github.com/redturtle/design-comuni-plone-theme/compare/v10.1.0...v10.1.1) (2023-11-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* fix sideMenuByTitles to remove duplicate text title when it is hidden ([9da33c8](https://github.com/redturtle/design-comuni-plone-theme/commit/9da33c8d5f5470e20873a04e5963d66a3cc46515))
|
|
9
|
+
|
|
10
|
+
## [10.1.0](https://github.com/redturtle/design-comuni-plone-theme/compare/v10.0.0...v10.1.0) (2023-11-06)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* Sidemenu customizable ([#388](https://github.com/redturtle/design-comuni-plone-theme/issues/388)) ([94fa0c1](https://github.com/redturtle/design-comuni-plone-theme/commit/94fa0c107f73acb9b7e89638f613206391cefc46))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* GalleryPreview ([29f0299](https://github.com/redturtle/design-comuni-plone-theme/commit/29f02990f1e7467e536f151c9e86821c1b0c9e98))
|
|
21
|
+
* locales ([14d268b](https://github.com/redturtle/design-comuni-plone-theme/commit/14d268be970d6fccce06c0c24f99c67745735fef))
|
|
22
|
+
* useSideMenu observer ([bd2e4ab](https://github.com/redturtle/design-comuni-plone-theme/commit/bd2e4ab451d4bc5a05b2673cdbf4a2b05038f4b4))
|
|
23
|
+
|
|
3
24
|
## [10.0.0](https://github.com/redturtle/design-comuni-plone-theme/compare/v8.9.0...v10.0.0) (2023-11-03)
|
|
4
25
|
|
|
5
26
|
|
|
@@ -164,6 +164,7 @@ msgid "Content in evidence"
|
|
|
164
164
|
msgstr ""
|
|
165
165
|
|
|
166
166
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
167
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
167
168
|
# defaultMessage: Contenuto
|
|
168
169
|
msgid "Contenuto"
|
|
169
170
|
msgstr ""
|
|
@@ -2214,6 +2215,7 @@ msgid "incarico"
|
|
|
2214
2215
|
msgstr ""
|
|
2215
2216
|
|
|
2216
2217
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
2218
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
2217
2219
|
# defaultMessage: Indice della pagina
|
|
2218
2220
|
msgid "index"
|
|
2219
2221
|
msgstr ""
|
|
@@ -149,6 +149,7 @@ msgid "Content in evidence"
|
|
|
149
149
|
msgstr ""
|
|
150
150
|
|
|
151
151
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
152
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
152
153
|
# defaultMessage: Contenuto
|
|
153
154
|
msgid "Contenuto"
|
|
154
155
|
msgstr "Content"
|
|
@@ -2199,6 +2200,7 @@ msgid "incarico"
|
|
|
2199
2200
|
msgstr "assignment"
|
|
2200
2201
|
|
|
2201
2202
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
2203
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
2202
2204
|
# defaultMessage: Indice della pagina
|
|
2203
2205
|
msgid "index"
|
|
2204
2206
|
msgstr "Page index"
|
|
@@ -158,6 +158,7 @@ msgid "Content in evidence"
|
|
|
158
158
|
msgstr "Contenido destacado"
|
|
159
159
|
|
|
160
160
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
161
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
161
162
|
# defaultMessage: Contenuto
|
|
162
163
|
msgid "Contenuto"
|
|
163
164
|
msgstr "Contenido"
|
|
@@ -2208,6 +2209,7 @@ msgid "incarico"
|
|
|
2208
2209
|
msgstr "Compromiso"
|
|
2209
2210
|
|
|
2210
2211
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
2212
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
2211
2213
|
# defaultMessage: Indice della pagina
|
|
2212
2214
|
msgid "index"
|
|
2213
2215
|
msgstr "Índice de página"
|
|
@@ -166,6 +166,7 @@ msgid "Content in evidence"
|
|
|
166
166
|
msgstr ""
|
|
167
167
|
|
|
168
168
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
169
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
169
170
|
# defaultMessage: Contenuto
|
|
170
171
|
msgid "Contenuto"
|
|
171
172
|
msgstr "Contenu"
|
|
@@ -2216,6 +2217,7 @@ msgid "incarico"
|
|
|
2216
2217
|
msgstr "Engagement"
|
|
2217
2218
|
|
|
2218
2219
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
2220
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
2219
2221
|
# defaultMessage: Indice della pagina
|
|
2220
2222
|
msgid "index"
|
|
2221
2223
|
msgstr "Index des pages"
|
|
@@ -149,6 +149,7 @@ msgid "Content in evidence"
|
|
|
149
149
|
msgstr "Contenuto in primo piano"
|
|
150
150
|
|
|
151
151
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
152
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
152
153
|
# defaultMessage: Contenuto
|
|
153
154
|
msgid "Contenuto"
|
|
154
155
|
msgstr "Contenuto"
|
|
@@ -2199,6 +2200,7 @@ msgid "incarico"
|
|
|
2199
2200
|
msgstr "incarico"
|
|
2200
2201
|
|
|
2201
2202
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
2203
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
2202
2204
|
# defaultMessage: Indice della pagina
|
|
2203
2205
|
msgid "index"
|
|
2204
2206
|
msgstr "Indice della pagina"
|
package/locales/volto.pot
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
msgid ""
|
|
2
2
|
msgstr ""
|
|
3
3
|
"Project-Id-Version: Plone\n"
|
|
4
|
-
"POT-Creation-Date: 2023-11-
|
|
4
|
+
"POT-Creation-Date: 2023-11-06T09:06:10.531Z\n"
|
|
5
5
|
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
6
6
|
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
7
7
|
"MIME-Version: 1.0\n"
|
|
@@ -151,6 +151,7 @@ msgid "Content in evidence"
|
|
|
151
151
|
msgstr ""
|
|
152
152
|
|
|
153
153
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
154
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
154
155
|
# defaultMessage: Contenuto
|
|
155
156
|
msgid "Contenuto"
|
|
156
157
|
msgstr ""
|
|
@@ -2201,6 +2202,7 @@ msgid "incarico"
|
|
|
2201
2202
|
msgstr ""
|
|
2202
2203
|
|
|
2203
2204
|
#: components/ItaliaTheme/View/Commons/SideMenu
|
|
2205
|
+
#: components/ItaliaTheme/View/Commons/SideMenuByTitles
|
|
2204
2206
|
# defaultMessage: Indice della pagina
|
|
2205
2207
|
msgid "index"
|
|
2206
2208
|
msgstr ""
|
package/package.json
CHANGED
|
@@ -34,8 +34,8 @@ const GalleryPreview = ({ id, viewIndex, setViewIndex, items }) => {
|
|
|
34
34
|
const [modalIsOpen, setModalIsOpen] = useState(false);
|
|
35
35
|
const image = items[viewIndex];
|
|
36
36
|
|
|
37
|
-
let checkUrlImage = image
|
|
38
|
-
? image
|
|
37
|
+
let checkUrlImage = image?.image_field
|
|
38
|
+
? image?.image_scales?.[image?.image_field]?.[0]?.scales?.larger?.download
|
|
39
39
|
: image?.image?.scales?.larger?.download ||
|
|
40
40
|
image?.image_scales?.image[0]?.scales?.larger?.download;
|
|
41
41
|
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* @module components/theme/View/BandoView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
SideMenu,
|
|
11
10
|
PageHeader,
|
|
12
11
|
RelatedItems,
|
|
13
12
|
BandoPlaceholderAfterContent,
|
|
@@ -22,6 +21,7 @@ import {
|
|
|
22
21
|
RelatedItemInEvidence,
|
|
23
22
|
SkipToMainContent,
|
|
24
23
|
ContentTypeViewSections,
|
|
24
|
+
useSideMenu,
|
|
25
25
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
26
26
|
|
|
27
27
|
export const BandoViewSectionsOrder = [
|
|
@@ -44,15 +44,8 @@ export const BandoViewSectionsOrder = [
|
|
|
44
44
|
*/
|
|
45
45
|
const BandoView = ({ content, location }) => {
|
|
46
46
|
let documentBody = createRef();
|
|
47
|
-
const
|
|
47
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
48
48
|
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (documentBody.current) {
|
|
51
|
-
if (__CLIENT__) {
|
|
52
|
-
setSideMenuElements(documentBody.current);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}, [documentBody]);
|
|
56
49
|
return (
|
|
57
50
|
<>
|
|
58
51
|
<div className="container px-4 my-4 bando-view">
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/* ****************
|
|
2
|
+
Costuisce il SideMenu utilizzando tutti gli h2 che trova nella parte di destra del contenuto.
|
|
3
|
+
******************/
|
|
4
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
5
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
6
|
+
/* eslint-disable no-unused-expressions */
|
|
7
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
8
|
+
import React, { useEffect, useState, useCallback, useMemo } from 'react';
|
|
9
|
+
import { throttle } from 'lodash';
|
|
10
|
+
import {
|
|
11
|
+
Progress,
|
|
12
|
+
Accordion,
|
|
13
|
+
AccordionBody,
|
|
14
|
+
AccordionHeader,
|
|
15
|
+
} from 'design-react-kit';
|
|
16
|
+
import cx from 'classnames';
|
|
17
|
+
|
|
18
|
+
const messages = defineMessages({
|
|
19
|
+
index: {
|
|
20
|
+
id: 'index',
|
|
21
|
+
defaultMessage: 'Indice',
|
|
22
|
+
},
|
|
23
|
+
contenuto: {
|
|
24
|
+
id: 'Contenuto',
|
|
25
|
+
defaultMessage: 'Contenuto',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const extractHeaders = (elements, intl) => {
|
|
30
|
+
let item;
|
|
31
|
+
let headers = [];
|
|
32
|
+
for (var index = 0; index < elements.length; index++) {
|
|
33
|
+
item = elements[index];
|
|
34
|
+
|
|
35
|
+
if (item.id === 'text-body') {
|
|
36
|
+
const h = item.getElementsByTagName('h2');
|
|
37
|
+
|
|
38
|
+
for (var hi = 0; hi < h.length; hi++) {
|
|
39
|
+
headers.push({
|
|
40
|
+
id: h[hi].id,
|
|
41
|
+
title: h[hi].innerText,
|
|
42
|
+
item: h[hi],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
let item_header = item.querySelector('#header-' + item.id);
|
|
47
|
+
if (item_header) {
|
|
48
|
+
headers.push({
|
|
49
|
+
id: item.id,
|
|
50
|
+
title: item_header.textContent,
|
|
51
|
+
item: item,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return headers;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* SideMenuByTitles view component class.
|
|
61
|
+
* @function SideMenuByTitles
|
|
62
|
+
* @params {object} content: Content object.
|
|
63
|
+
* @returns {string} Markup of the component.
|
|
64
|
+
*/
|
|
65
|
+
const SideMenuByTitles = ({ data, content_uid }) => {
|
|
66
|
+
const intl = useIntl();
|
|
67
|
+
|
|
68
|
+
const [headers, setHeaders] = useState([]);
|
|
69
|
+
const [activeSection, setActiveSection] = useState(null);
|
|
70
|
+
const [scrollY, setScrollY] = useState(0);
|
|
71
|
+
const [isClient, setIsClient] = useState(false);
|
|
72
|
+
|
|
73
|
+
const [isNavOpen, setIsNavOpen] = useState(
|
|
74
|
+
__CLIENT__ ? window.innerWidth >= 992 : false,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setIsClient(true);
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
const handleScroll = useCallback(() => {
|
|
82
|
+
const scrollOffset = 0.1 * window.innerHeight;
|
|
83
|
+
setScrollY(window.scrollY);
|
|
84
|
+
const headersHeights = headers
|
|
85
|
+
.map((section) => {
|
|
86
|
+
const element = document.getElementById(section.id);
|
|
87
|
+
return {
|
|
88
|
+
id: section.id,
|
|
89
|
+
top: element?.getBoundingClientRect()?.top,
|
|
90
|
+
};
|
|
91
|
+
})
|
|
92
|
+
.filter((section) => section.top <= scrollOffset);
|
|
93
|
+
if (headersHeights.length > 0) {
|
|
94
|
+
const section = headersHeights.reduce(
|
|
95
|
+
(prev, curr) => (prev.top > curr.top ? prev : curr),
|
|
96
|
+
headers[0],
|
|
97
|
+
);
|
|
98
|
+
setActiveSection(section.id);
|
|
99
|
+
} else {
|
|
100
|
+
setActiveSection(null); //di default nessun header è selezionato.
|
|
101
|
+
}
|
|
102
|
+
}, [headers, activeSection]);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (data?.children) {
|
|
106
|
+
const extractedHeaders = extractHeaders(data.children, intl);
|
|
107
|
+
|
|
108
|
+
if (extractedHeaders.length > 0) {
|
|
109
|
+
setHeaders(extractedHeaders);
|
|
110
|
+
// setActiveSection(extractedHeaders[0].id); //di default nessun header è selezionato.
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, [data, content_uid]);
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (headers.length > 0)
|
|
117
|
+
window.addEventListener('scroll', throttledHandleScroll, {
|
|
118
|
+
passive: true,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return () => {
|
|
122
|
+
window.removeEventListener('scroll', throttledHandleScroll);
|
|
123
|
+
};
|
|
124
|
+
}, [headers]);
|
|
125
|
+
|
|
126
|
+
const throttledHandleScroll = throttle(handleScroll, 100);
|
|
127
|
+
|
|
128
|
+
const handleClickAnchor = (id) => (e) => {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
if (window.innerWidth < 992) {
|
|
131
|
+
setIsNavOpen(false);
|
|
132
|
+
}
|
|
133
|
+
// Blur a link
|
|
134
|
+
document.getElementById(`item-${id}`).blur();
|
|
135
|
+
// Focus on section
|
|
136
|
+
document.getElementById(id).focus({ preventScroll: true });
|
|
137
|
+
// Scroll to section
|
|
138
|
+
// setTimeout hack should wait for rerender after setIsNavOpen
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
document.getElementById(id)?.scrollIntoView?.({
|
|
141
|
+
behavior: 'smooth',
|
|
142
|
+
block: 'start',
|
|
143
|
+
});
|
|
144
|
+
}, 0);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const yCountEnd = isClient
|
|
148
|
+
? document.querySelector('#main-content-section')
|
|
149
|
+
: null;
|
|
150
|
+
|
|
151
|
+
const progressValue = useMemo(() => {
|
|
152
|
+
if (!isClient) return 0;
|
|
153
|
+
return (scrollY - yCountEnd.offsetTop) / yCountEnd.offsetHeight || 0;
|
|
154
|
+
}, [scrollY, isClient]);
|
|
155
|
+
|
|
156
|
+
return headers?.length > 0 ? (
|
|
157
|
+
<div className="sticky-wrapper navbar-wrapper page-side-menu">
|
|
158
|
+
<nav className="navbar it-navscroll-wrapper navbar-expand-lg">
|
|
159
|
+
<div className="menu-wrapper">
|
|
160
|
+
<div className="link-list-wrapper menu-link-list">
|
|
161
|
+
<div className="accordion-wrapper">
|
|
162
|
+
<Accordion>
|
|
163
|
+
<AccordionHeader
|
|
164
|
+
active={isNavOpen}
|
|
165
|
+
onToggle={() => {
|
|
166
|
+
setIsNavOpen(!isNavOpen);
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
<h3>{intl.formatMessage(messages.index)}</h3>
|
|
170
|
+
</AccordionHeader>
|
|
171
|
+
<div className="mb-3">
|
|
172
|
+
<Progress
|
|
173
|
+
value={progressValue > 0 ? 100 * progressValue : 0}
|
|
174
|
+
role="progressbar"
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
<AccordionBody
|
|
178
|
+
active={isNavOpen}
|
|
179
|
+
className={
|
|
180
|
+
isNavOpen
|
|
181
|
+
? 'accordion-collapse show'
|
|
182
|
+
: 'accordion-collapse collapse'
|
|
183
|
+
}
|
|
184
|
+
>
|
|
185
|
+
<ul className="link-list" data-element="page-index">
|
|
186
|
+
{headers.map((item, i) => {
|
|
187
|
+
return (
|
|
188
|
+
<li className="nav-item" key={item.id}>
|
|
189
|
+
<a
|
|
190
|
+
className={cx('nav-link', {
|
|
191
|
+
active: item.id === activeSection,
|
|
192
|
+
})}
|
|
193
|
+
href={`#${item.id}`}
|
|
194
|
+
onClick={handleClickAnchor(item.id)}
|
|
195
|
+
id={`item-${item.id}`}
|
|
196
|
+
>
|
|
197
|
+
<span>{item.title}</span>
|
|
198
|
+
</a>
|
|
199
|
+
</li>
|
|
200
|
+
);
|
|
201
|
+
})}
|
|
202
|
+
</ul>
|
|
203
|
+
</AccordionBody>
|
|
204
|
+
</Accordion>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
</nav>
|
|
209
|
+
</div>
|
|
210
|
+
) : null;
|
|
211
|
+
};
|
|
212
|
+
export default SideMenuByTitles;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module components/theme/View/DocumentoView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import {
|
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
DocumentoDocAllegati,
|
|
18
18
|
DocumentoUlterioriInformazioni,
|
|
19
19
|
ContentImage,
|
|
20
|
-
SideMenu,
|
|
21
20
|
PageHeader,
|
|
22
21
|
RelatedItems,
|
|
23
22
|
RelatedItemInEvidence,
|
|
24
23
|
SkipToMainContent,
|
|
25
24
|
ContentTypeViewSections,
|
|
25
|
+
useSideMenu,
|
|
26
26
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
27
27
|
|
|
28
28
|
export const DocumentoViewSectionsOrder = [
|
|
@@ -48,16 +48,9 @@ export const DocumentoViewSectionsOrder = [
|
|
|
48
48
|
*/
|
|
49
49
|
const DocumentoView = ({ content, location }) => {
|
|
50
50
|
let documentBody = createRef();
|
|
51
|
-
const
|
|
52
|
-
//const userLogged = useSelector((state) => state.userSession);
|
|
51
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
if (documentBody.current) {
|
|
56
|
-
if (__CLIENT__) {
|
|
57
|
-
setSideMenuElements(documentBody.current);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, [documentBody]);
|
|
53
|
+
//const userLogged = useSelector((state) => state.userSession);
|
|
61
54
|
|
|
62
55
|
return (
|
|
63
56
|
<>
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* @module components/theme/View/EventoView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
ContentImage,
|
|
11
|
-
SideMenu,
|
|
12
11
|
PageHeader,
|
|
13
12
|
RelatedItems,
|
|
14
13
|
EventoPlaceholderAfterContent,
|
|
@@ -25,6 +24,7 @@ import {
|
|
|
25
24
|
SkipToMainContent,
|
|
26
25
|
ContentTypeViewSections,
|
|
27
26
|
EventoSponsors,
|
|
27
|
+
useSideMenu,
|
|
28
28
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
29
29
|
|
|
30
30
|
export const EventoViewSectionsOrder = [
|
|
@@ -53,15 +53,7 @@ export const EventoViewSectionsOrder = [
|
|
|
53
53
|
*/
|
|
54
54
|
const EventoView = ({ content, location }) => {
|
|
55
55
|
let documentBody = createRef();
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (documentBody.current) {
|
|
60
|
-
if (__CLIENT__) {
|
|
61
|
-
setSideMenuElements(documentBody.current);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}, [documentBody]);
|
|
56
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
65
57
|
|
|
66
58
|
return (
|
|
67
59
|
<>
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* @module components/theme/View/NewsItemView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { createRef
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import {
|
|
10
10
|
PageHeader,
|
|
11
|
-
SideMenu,
|
|
12
11
|
ContentImage,
|
|
13
12
|
RelatedItems,
|
|
14
13
|
NewsItemPlaceholderAfterContent,
|
|
@@ -23,6 +22,8 @@ import {
|
|
|
23
22
|
NewsItemDataset,
|
|
24
23
|
NewsItemMetadata,
|
|
25
24
|
ContentTypeViewSections,
|
|
25
|
+
useSideMenu,
|
|
26
|
+
useReadingTime,
|
|
26
27
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
27
28
|
|
|
28
29
|
export const NewsItemViewSectionsOrder = [
|
|
@@ -47,9 +48,9 @@ export const NewsItemViewSectionsOrder = [
|
|
|
47
48
|
* @returns {string} Markup of the component.
|
|
48
49
|
*/
|
|
49
50
|
const NewsItemView = ({ content, location }) => {
|
|
50
|
-
const [readingtime, setReadingtime] = useState(0);
|
|
51
51
|
let documentBody = createRef();
|
|
52
|
-
const
|
|
52
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
53
|
+
const { readingtime } = useReadingTime(content, documentBody);
|
|
53
54
|
|
|
54
55
|
let related_items = [];
|
|
55
56
|
if (content?.notizie_correlate?.length > 0) {
|
|
@@ -59,17 +60,6 @@ const NewsItemView = ({ content, location }) => {
|
|
|
59
60
|
related_items = [...related_items, ...content.relatedItems];
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (documentBody.current) {
|
|
64
|
-
if (__CLIENT__) {
|
|
65
|
-
setReadingtime(
|
|
66
|
-
readingTime(content.title, content.description, documentBody),
|
|
67
|
-
);
|
|
68
|
-
setSideMenuElements(documentBody.current);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}, [content.description, content.title, documentBody]);
|
|
72
|
-
|
|
73
63
|
return (
|
|
74
64
|
<>
|
|
75
65
|
<div className="container px-4 my-4 newsitem-view">
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
* @module components/theme/View/PaginaArgomentoViewNoBlocks
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { createRef
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { defineMessages, useIntl } from 'react-intl';
|
|
9
9
|
import {
|
|
10
10
|
GenericCard,
|
|
11
11
|
ContentImage,
|
|
12
|
-
SideMenu,
|
|
13
12
|
PageHeader,
|
|
14
13
|
OfficeCard,
|
|
15
14
|
RichTextSection,
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
SkipToMainContent,
|
|
21
20
|
RelatedItems,
|
|
22
21
|
RelatedItemInEvidence,
|
|
22
|
+
useSideMenu,
|
|
23
23
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
24
24
|
|
|
25
25
|
// import { getBaseUrl } from '@plone/volto/helpers';
|
|
@@ -68,15 +68,7 @@ const messages = defineMessages({
|
|
|
68
68
|
const PaginaArgomentoViewNoBlocks = ({ content }) => {
|
|
69
69
|
const intl = useIntl();
|
|
70
70
|
let documentBody = createRef();
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (documentBody.current) {
|
|
75
|
-
if (__CLIENT__) {
|
|
76
|
-
setSideMenuElements(documentBody.current);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, [documentBody]);
|
|
71
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
80
72
|
|
|
81
73
|
return (
|
|
82
74
|
<>
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* @module components/theme/View/PersonaView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { createRef
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
SideMenu,
|
|
11
10
|
PageHeader,
|
|
12
11
|
RelatedItems,
|
|
13
12
|
PersonaRuolo,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
RelatedItemInEvidence,
|
|
20
19
|
SkipToMainContent,
|
|
21
20
|
ContentTypeViewSections,
|
|
21
|
+
useSideMenu,
|
|
22
22
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
23
23
|
|
|
24
24
|
export const PersonaViewSectionsOrder = [
|
|
@@ -36,14 +36,7 @@ export const PersonaViewSectionsOrder = [
|
|
|
36
36
|
*/
|
|
37
37
|
const PersonaView = ({ content }) => {
|
|
38
38
|
let documentBody = createRef();
|
|
39
|
-
const
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (documentBody.current) {
|
|
42
|
-
if (__CLIENT__) {
|
|
43
|
-
setSideMenuElements(documentBody.current);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}, [documentBody]);
|
|
39
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
47
40
|
|
|
48
41
|
return (
|
|
49
42
|
<>
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* @module components/theme/View/ServizioView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { createRef
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useIntl } from 'react-intl';
|
|
9
9
|
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
10
10
|
import {
|
|
11
|
-
SideMenu,
|
|
12
11
|
PageHeader,
|
|
13
12
|
ContentImage,
|
|
14
13
|
ServizioPlaceholderAfterContent,
|
|
@@ -38,6 +37,7 @@ import {
|
|
|
38
37
|
ServizioArgomenti,
|
|
39
38
|
ServizioMetatag,
|
|
40
39
|
ContentTypeViewSections,
|
|
40
|
+
useSideMenu,
|
|
41
41
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
42
42
|
|
|
43
43
|
export const ServizioViewSectionsOrder = (props) => [
|
|
@@ -109,14 +109,7 @@ const ServizioView = ({ content, moment }) => {
|
|
|
109
109
|
Moment.locale(intl.locale);
|
|
110
110
|
|
|
111
111
|
const documentBody = createRef();
|
|
112
|
-
const
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
if (documentBody.current) {
|
|
115
|
-
if (__CLIENT__) {
|
|
116
|
-
setSideMenuElements(documentBody.current);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}, [documentBody]);
|
|
112
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
120
113
|
|
|
121
114
|
return (
|
|
122
115
|
<>
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
* @module components/theme/View/UOView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { createRef
|
|
6
|
+
import React, { createRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import {
|
|
10
10
|
PageHeader,
|
|
11
11
|
UOServices,
|
|
12
12
|
RelatedItems,
|
|
13
|
-
SideMenu,
|
|
14
13
|
ContentImage,
|
|
15
14
|
UOPlaceholderAfterContent,
|
|
16
15
|
UOPlaceholderAfterRelatedItems,
|
|
@@ -23,6 +22,7 @@ import {
|
|
|
23
22
|
RelatedItemInEvidence,
|
|
24
23
|
SkipToMainContent,
|
|
25
24
|
ContentTypeViewSections,
|
|
25
|
+
useSideMenu,
|
|
26
26
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
27
27
|
|
|
28
28
|
export const UOViewSectionsOrder = [
|
|
@@ -56,13 +56,7 @@ export const UOViewSectionsOrder = [
|
|
|
56
56
|
*/
|
|
57
57
|
const UOView = ({ content }) => {
|
|
58
58
|
let documentBody = createRef();
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (documentBody.current && __CLIENT__) {
|
|
63
|
-
setSideMenuElements(documentBody.current);
|
|
64
|
-
}
|
|
65
|
-
}, [documentBody]);
|
|
59
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
66
60
|
|
|
67
61
|
return (
|
|
68
62
|
<>
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* @module components/theme/View/VenueView
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { createRef, useEffect
|
|
6
|
+
import React, { createRef, useEffect } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
SideMenu,
|
|
11
10
|
PageHeader,
|
|
12
11
|
ContentImage,
|
|
13
12
|
RelatedItems,
|
|
@@ -23,6 +22,7 @@ import {
|
|
|
23
22
|
VenueContacts,
|
|
24
23
|
VenueMoreInfos,
|
|
25
24
|
ContentTypeViewSections,
|
|
25
|
+
useSideMenu,
|
|
26
26
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
27
27
|
|
|
28
28
|
export const VenueViewSectionsOrder = [
|
|
@@ -56,15 +56,7 @@ export const VenueViewSectionsOrder = [
|
|
|
56
56
|
*/
|
|
57
57
|
const VenueView = ({ content }) => {
|
|
58
58
|
let documentBody = createRef();
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (documentBody.current) {
|
|
63
|
-
if (__CLIENT__) {
|
|
64
|
-
setSideMenuElements(documentBody.current);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, [documentBody]);
|
|
59
|
+
const { sideMenuElements, SideMenu } = useSideMenu(content, documentBody);
|
|
68
60
|
|
|
69
61
|
useEffect(() => {
|
|
70
62
|
if (
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { IntlProvider } from 'react-intl';
|
|
3
3
|
import { renderToString } from 'react-dom/server';
|
|
4
|
+
import { SideMenu } from 'design-comuni-plone-theme/components/ItaliaTheme/View';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
4
6
|
|
|
5
7
|
export const readingTime = (title, description, htmlBody) => {
|
|
6
8
|
const body = htmlBody.current.textContent;
|
|
@@ -13,3 +15,69 @@ export const readingTime = (title, description, htmlBody) => {
|
|
|
13
15
|
|
|
14
16
|
export const getHTMLString = (content, locale) =>
|
|
15
17
|
renderToString(<IntlProvider locale={locale}>{content}</IntlProvider>);
|
|
18
|
+
|
|
19
|
+
//Hook per avere il reading time di una pagina
|
|
20
|
+
export const useReadingTime = (content, documentBody) => {
|
|
21
|
+
const [readingtime, setReadingtime] = useState(0);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (documentBody.current) {
|
|
25
|
+
if (__CLIENT__) {
|
|
26
|
+
setReadingtime(
|
|
27
|
+
readingTime(content.title, content.description, documentBody),
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, [content.description, content.title, documentBody]);
|
|
32
|
+
|
|
33
|
+
return { readingtime, setReadingtime };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//Hook per avere i SideMenu elements di una pagina
|
|
37
|
+
export const useSideMenu = (content, documentBody) => {
|
|
38
|
+
const [sideMenuElements, setSideMenuElements] = useState(null);
|
|
39
|
+
const [observer, setObserver] = useState(null);
|
|
40
|
+
const updateSideMenuOnLoadingBlocks =
|
|
41
|
+
config.settings?.italiaThemeViewsConfig?.[content['@type']]
|
|
42
|
+
?.updateSideMenuOnLoadingBlocks ?? false;
|
|
43
|
+
const SideMenuComponent =
|
|
44
|
+
config.settings?.italiaThemeViewsConfig?.[content['@type']]?.sideMenu ??
|
|
45
|
+
SideMenu;
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (documentBody.current) {
|
|
49
|
+
if (__CLIENT__) {
|
|
50
|
+
setSideMenuElements(documentBody.current);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [content.description, content.title, documentBody]);
|
|
54
|
+
|
|
55
|
+
//observer is needed for loadable blocks like listing and rss, if you want to use their title's for SideMenu
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!updateSideMenuOnLoadingBlocks) return;
|
|
59
|
+
|
|
60
|
+
if (!observer) {
|
|
61
|
+
const obs = updateSideMenuOnLoadingBlocks
|
|
62
|
+
? new MutationObserver((mutationList) => {
|
|
63
|
+
setSideMenuElements(documentBody.current);
|
|
64
|
+
})
|
|
65
|
+
: null;
|
|
66
|
+
setObserver(obs);
|
|
67
|
+
}
|
|
68
|
+
if (observer) {
|
|
69
|
+
observer.observe(documentBody.current, {
|
|
70
|
+
//attributes: true,
|
|
71
|
+
childList: true,
|
|
72
|
+
subtree: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return () => {
|
|
76
|
+
if (observer) {
|
|
77
|
+
observer.disconnect();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [observer, setObserver, documentBody, updateSideMenuOnLoadingBlocks]);
|
|
81
|
+
|
|
82
|
+
return { sideMenuElements, setSideMenuElements, SideMenu: SideMenuComponent };
|
|
83
|
+
};
|
|
@@ -5,6 +5,12 @@ export {
|
|
|
5
5
|
RichTextRender,
|
|
6
6
|
richTextHasContent,
|
|
7
7
|
} from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/RichTextRender';
|
|
8
|
+
export {
|
|
9
|
+
useSideMenu,
|
|
10
|
+
useReadingTime,
|
|
11
|
+
readingTime,
|
|
12
|
+
getHTMLString,
|
|
13
|
+
} from 'design-comuni-plone-theme/components/ItaliaTheme/View/ViewUtils';
|
|
8
14
|
|
|
9
15
|
export RenderBlocks from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/RenderBlocks';
|
|
10
16
|
export RelatedNewsArticles from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/RelatedNewsArticles';
|
|
@@ -191,6 +191,8 @@ export default function applyConfig(voltoConfig) {
|
|
|
191
191
|
// sections: [
|
|
192
192
|
// //sections order for Venue content-type view. See components/ItaliaTheme/View/VenueView/VenueView.jsx for default VenueViewSectionsOrder
|
|
193
193
|
// ],
|
|
194
|
+
// updateSideMenuOnLoadingBlocks:false, //serve se si vuole fare in modo che il sideMenu si aggiorni con i titli dei blocchi presenti nel testo
|
|
195
|
+
// sideMenu:null // qui va messo il component da usare per fare il SideMenu, se non è impostato viene usato quello di default
|
|
194
196
|
// },
|
|
195
197
|
},
|
|
196
198
|
siteProperties: {
|