Skip to content

Commit 3c9ddc9

Browse files
authored
Merge branch 'main' into 69848-object-browser-list-status
2 parents b3e4180 + 1d061e8 commit 3c9ddc9

File tree

7 files changed

+266
-26
lines changed

7 files changed

+266
-26
lines changed

locales/it/LC_MESSAGES/volto.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ msgstr "A volte non capivo se stavo procedendo correttamente"
24572457
#: overrideTranslations
24582458
# defaultMessage: Check this box if the value entered in this field can be used only once.
24592459
msgid "field_unique_description"
2460-
msgstr "Seleziona questo checkbox se il valore inserito in questo campo può essere utilizzato solo una volta"
2460+
msgstr "Richiedi un valore univoco: il valore inserito dagli utenti in questo campo non può essere già stato utilizzato in altre compilazioni del form."
24612461

24622462
#: overrideTranslations
24632463
# defaultMessage: Unique field

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"volto-dropdownmenu": "4.1.3",
153153
"volto-editablefooter": "5.1.7",
154154
"volto-feedback": "0.7.2",
155-
"volto-form-block": "3.16.0",
155+
"volto-form-block": "3.17.0",
156156
"volto-gdpr-privacy": "2.2.12",
157157
"volto-google-analytics": "2.0.0",
158158
"volto-multilingual-widget": "3.2.1",

src/components/ItaliaTheme/Blocks/Listing/PhotogalleryTemplate.jsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
1717
import {
1818
ListingImage,
1919
ListingLinkMore,
20-
NextArrow,
21-
PrevArrow,
2220
SingleSlideWrapper,
2321
CarouselWrapper,
2422
ButtonPlayPause,
2523
} from 'design-comuni-plone-theme/components/ItaliaTheme';
24+
import { useSlider } from 'design-comuni-plone-theme/components/ItaliaTheme/Slider/slider';
2625
import { GalleryPreview } from 'design-comuni-plone-theme/components/ItaliaTheme';
2726

2827
const messages = defineMessages({
@@ -48,13 +47,22 @@ const PhotogalleryTemplate = ({
4847
reactSlick,
4948
titleLine,
5049
linkmore_id_lighthouse,
50+
block,
5151
}) => {
5252
const intl = useIntl();
53-
const slider = useRef(null);
53+
//const slider = useRef(null);
5454
const [autoplay, setAutoplay] = useState(false);
5555
const [viewImageIndex, setViewImageIndex] = useState(null);
5656
const Slider = reactSlick.default;
5757

58+
const {
59+
slider,
60+
focusSlide,
61+
SliderNextArrow,
62+
SliderPrevArrow,
63+
handleSlideKeydown,
64+
} = useSlider(autoplay, setAutoplay, block);
65+
5866
const toggleAutoplay = () => {
5967
if (!slider?.current) return;
6068
if (autoplay) {
@@ -80,7 +88,7 @@ const PhotogalleryTemplate = ({
8088
pauseOnDotsHover: true,
8189
swipe: true,
8290
swipeToSlide: true,
83-
focusOnSelect: true,
91+
focusOnSelect: false,
8492
draggable: true,
8593
accessibility: true,
8694
responsive: [
@@ -109,8 +117,8 @@ const PhotogalleryTemplate = ({
109117
},
110118
},
111119
],
112-
nextArrow: <NextArrow />,
113-
prevArrow: <PrevArrow />,
120+
nextArrow: <SliderNextArrow intl={intl} />,
121+
prevArrow: <SliderPrevArrow intl={intl} />,
114122
appendDots: (dots) => (
115123
<div>
116124
<ButtonPlayPause
@@ -124,6 +132,7 @@ const PhotogalleryTemplate = ({
124132
</ul>
125133
</div>
126134
),
135+
afterChange: focusSlide, // Custom handling of focus for a11y
127136
};
128137

129138
const getCaption = (item) => item.description ?? item.rights ?? null;
@@ -138,7 +147,7 @@ const PhotogalleryTemplate = ({
138147
};
139148

140149
return (
141-
<div className="photogallery">
150+
<div className="photogallery" id={'outside-slider-' + block}>
142151
<Container className="px-4">
143152
{title && (
144153
<Row>
@@ -149,7 +158,7 @@ const PhotogalleryTemplate = ({
149158
</Col>
150159
</Row>
151160
)}
152-
<div className="slider-container px-4 px-md-0">
161+
<div className="slider-container px-4 px-md-0" id={'slider_' + block}>
153162
<CarouselWrapper className="it-card-bg">
154163
<Slider {...settings} ref={slider}>
155164
{items.map((item, i) => {
@@ -167,19 +176,25 @@ const PhotogalleryTemplate = ({
167176
noWrapLink: true,
168177
showDefault: true,
169178
};
179+
const nextIndex = i < items.length - 1 ? i + 1 : null;
180+
const prevIndex = i > 0 ? i - 1 : null;
181+
170182
return (
171183
<SingleSlideWrapper
172184
className={cx('', {
173185
'single-slide': items.length === 1,
174186
})}
175187
key={item['@id']}
176188
index={i}
189+
onKeyDown={handleSlideKeydown(i, prevIndex, nextIndex)}
177190
>
178191
{!show_image_popup ? (
179192
<UniversalLink
180193
item={item}
181194
openLinkInNewTab={true}
182195
title={intl.formatMessage(messages.viewImage)}
196+
tabIndex={0}
197+
data-slide={i}
183198
>
184199
{figure(imageProps, item)}
185200
</UniversalLink>
@@ -205,6 +220,8 @@ const PhotogalleryTemplate = ({
205220
aria-label={`${intl.formatMessage(
206221
messages.viewPreview,
207222
)} ${item.title}`}
223+
tabIndex={0}
224+
data-slide={i}
208225
>
209226
{figure(imageProps, item)}
210227
</a>

src/components/ItaliaTheme/Slider/SingleSlideWrapper.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ const SingleSlideWrapper = (props) => {
1818
key={wrapperKey}
1919
data-slide={index}
2020
role="group"
21+
aria-roledescription="slide"
2122
aria-label={
2223
intl.formatMessage(messages.carouselSlide) +
2324
' ' +
2425
(index ? index + 1 : '') +
25-
' - ' +
26-
(props['aria-label'] ?? '')
26+
(props['aria-label'] ? ' - ' + props['aria-label'] : '')
2727
}
2828
onKeyDown={onKeyDown}
2929
onClick={(e) => {

src/customizations/volto-form-block/components/Sidebar.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const Sidebar = ({
9696
}}
9797
formData={data}
9898
onChangeBlock={() => {}}
99+
block={block}
99100
/>
100101
{!datatableEnabled && (
101102
<SidebarDataActions
@@ -170,6 +171,7 @@ const Sidebar = ({
170171
}}
171172
formData={subblockData}
172173
onChangeBlock={() => {}}
174+
block={block}
173175
/>
174176
</Accordion.Content>
175177
</div>

src/customizations/volto-form-block/components/View.jsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// CUSTOMIZATION:
22
// - added warning state to form
33
// - backport for https://github.com/collective/volto-form-block/pull/122
4-
4+
// - handle field errors coming from backend
55
import React, { useState, useEffect, useReducer, useRef } from 'react';
66
import { useSelector, useDispatch } from 'react-redux';
77
import PropTypes from 'prop-types';
@@ -356,11 +356,41 @@ const View = ({ data, id, path }) => {
356356
});
357357
}
358358
} else if (submitResults?.error) {
359-
let errorDescription = `${
360-
JSON.parse(submitResults.error.response?.text ?? '{}')?.message
361-
}`;
359+
//CUSTOM: handle field errors coming from backend
360+
let fieldsErrors = [];
361+
let errorDescription = '';
362+
363+
try {
364+
errorDescription = `${
365+
JSON.parse(submitResults.error.response?.text ?? '{}')?.message
366+
}`;
367+
368+
if (errorDescription.startsWith('[')) {
369+
fieldsErrors = JSON.parse(
370+
errorDescription.replaceAll('"', '\\"').replaceAll("'", '"'),
371+
);
372+
}
373+
} catch (e) {
374+
errorDescription = 'Error parsing error response';
375+
}
362376

363-
setFormState({ type: FORM_STATES.error, error: errorDescription });
377+
// fieldsErrors = [
378+
// { field_id: '1767088715579', label: 'univoco', message: 'Errore' },
379+
// ];
380+
if (fieldsErrors?.length > 0) {
381+
const v = [];
382+
fieldsErrors.forEach((fieldError) => {
383+
v.push({
384+
field: getFieldName(fieldError.label, fieldError.field_id),
385+
message: fieldError.message,
386+
});
387+
});
388+
setFormErrors(v);
389+
setFormState({ type: FORM_STATES.error });
390+
} else {
391+
setFormErrors([]);
392+
setFormState({ type: FORM_STATES.error, error: errorDescription });
393+
}
364394
}
365395
// eslint-disable-next-line react-hooks/exhaustive-deps
366396
}, [submitResults]);

0 commit comments

Comments
 (0)