diff --git a/RELEASE.md b/RELEASE.md index d3774576a..64f545c40 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -45,6 +45,7 @@ ### Migliorie +- Se vengono aggiunte o rimosse date dalla ricorrenza di un CT evento, nel sottotitolo viene aggiunta l'indicazione di controllare le eccezioni nella sezione apposita. - Il sottotitolo del CT Evento mostra il range di date per tutti gli eventi con ricorrenza o con una data di fine diversa dalla data di inizio. ### Novità diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po index e8d5b7970..4d8b66b99 100644 --- a/locales/de/LC_MESSAGES/volto.po +++ b/locales/de/LC_MESSAGES/volto.po @@ -1998,6 +1998,11 @@ msgstr "" msgid "exceeded_chars" msgstr "" +#: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates +# defaultMessage: con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata. +msgid "exceptionDates" +msgstr "" + #: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderDates # defaultMessage: Scadenza msgid "expire" diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po index 569e9d0e6..3b44c5d78 100644 --- a/locales/en/LC_MESSAGES/volto.po +++ b/locales/en/LC_MESSAGES/volto.po @@ -1983,6 +1983,11 @@ msgstr "Read more" msgid "exceeded_chars" msgstr "" +#: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates +# defaultMessage: con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata. +msgid "exceptionDates" +msgstr "with some exceptions. Please see the dedicated section for more information." + #: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderDates # defaultMessage: Scadenza msgid "expire" diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po index eb9583948..c73914f28 100644 --- a/locales/es/LC_MESSAGES/volto.po +++ b/locales/es/LC_MESSAGES/volto.po @@ -1992,6 +1992,11 @@ msgstr "" msgid "exceeded_chars" msgstr "El texto excede la longitud recomendada" +#: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates +# defaultMessage: con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata. +msgid "exceptionDates" +msgstr "" + #: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderDates # defaultMessage: Scadenza msgid "expire" diff --git a/locales/fr/LC_MESSAGES/volto.po b/locales/fr/LC_MESSAGES/volto.po index f9e046cc5..6d25e3f77 100644 --- a/locales/fr/LC_MESSAGES/volto.po +++ b/locales/fr/LC_MESSAGES/volto.po @@ -2000,6 +2000,11 @@ msgstr "" msgid "exceeded_chars" msgstr "" +#: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates +# defaultMessage: con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata. +msgid "exceptionDates" +msgstr "" + #: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderDates # defaultMessage: Scadenza msgid "expire" diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po index 567f5aee9..6ae4139d9 100644 --- a/locales/it/LC_MESSAGES/volto.po +++ b/locales/it/LC_MESSAGES/volto.po @@ -1983,6 +1983,11 @@ msgstr "Leggi di più" msgid "exceeded_chars" msgstr "Il testo supera la lunghezza consigliata perciò verrà tagliato." +#: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates +# defaultMessage: con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata. +msgid "exceptionDates" +msgstr "con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata." + #: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderDates # defaultMessage: Scadenza msgid "expire" diff --git a/locales/volto.pot b/locales/volto.pot index 94c5c21a8..01ee2901c 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2024-11-25T14:46:11.571Z\n" +"POT-Creation-Date: 2024-12-12T10:58:07.184Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n" @@ -1985,6 +1985,11 @@ msgstr "" msgid "exceeded_chars" msgstr "" +#: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates +# defaultMessage: con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata. +msgid "exceptionDates" +msgstr "" + #: components/ItaliaTheme/View/Commons/PageHeader/PageHeaderDates # defaultMessage: Scadenza msgid "expire" diff --git a/src/components/ItaliaTheme/View/Commons/Dates.jsx b/src/components/ItaliaTheme/View/Commons/Dates.jsx index 6ea82e5e4..029e3867b 100644 --- a/src/components/ItaliaTheme/View/Commons/Dates.jsx +++ b/src/components/ItaliaTheme/View/Commons/Dates.jsx @@ -4,7 +4,11 @@ import { rrulei18n } from '@plone/volto/components/manage/Widgets/RecurrenceWidg import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable'; import { Card, CardTitle, CardBody } from 'design-react-kit'; import PropTypes from 'prop-types'; -import { viewDate, getRealEventEnd } from 'design-comuni-plone-theme/helpers'; +import { + viewDate, + getRealEventEnd, + getRecurrenceExceptionDates, +} from 'design-comuni-plone-theme/helpers'; const messages = defineMessages({ start: { @@ -88,14 +92,9 @@ const Dates = ({ content, show_image, moment: momentlib, rrule }) => { const openEnd = content?.open_end; const wholeDay = content?.whole_day; - const rdates = rruleSet?.rdates() ?? []; - const exdates = rruleSet?.exdates() ?? []; - const additionalDates = rdates.reduce((acc, curr) => { - const isExdate = exdates.some((b) => b.toString() === curr.toString()); - if (!isExdate) { - return [...acc, curr]; - } else return acc; - }, []); + + const { additionalDates, removedDates } = + getRecurrenceExceptionDates(rruleSet); return content ? ( <> @@ -173,10 +172,10 @@ const Dates = ({ content, show_image, moment: momentlib, rrule }) => { ))} )} - {exdates.length > 0 && ( + {removedDates.length > 0 && (
{intl.formatMessage(messages.excluded_dates)}
- {exdates.map((exDate) => ( + {removedDates.map((exDate) => (
{viewDate(intl.locale, exDate, 'dddd DD MMMM YYYY')}
diff --git a/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx b/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx index baf99adf7..758f82be2 100644 --- a/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx +++ b/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx @@ -4,13 +4,21 @@ import PropTypes from 'prop-types'; import { rrulei18n } from '@plone/volto/components/manage/Widgets/RecurrenceWidget/Utils'; import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable'; -import { getRealEventEnd } from 'design-comuni-plone-theme/helpers'; +import { + getRealEventEnd, + getRecurrenceExceptionDates, +} from 'design-comuni-plone-theme/helpers'; const messages = defineMessages({ dateStart: { id: 'dal {dateStart} fino a conclusione', defaultMessage: 'dal {dateStart} fino a conclusione', }, + exceptionDates: { + id: 'exceptionDates', + defaultMessage: + 'con alcune eccezioni. Per maggiori informazioni controllare la sezione dedicata.', + }, }); /** @@ -82,6 +90,10 @@ const PageHeaderEventDates = ({ content, moment, rrule }) => { // format and save date into new variable depending on recurrence of event const endDate = Moment(actualEndDate).format('DD-MM-Y'); + // check if there are exception dates added to the recurrence to add info + const { additionalDates, removedDates } = + getRecurrenceExceptionDates(rruleSet); + return content['@type'] === 'Event' ? (

{(content.recurrence || !renderOnlyStart) && @@ -96,7 +108,12 @@ const PageHeaderEventDates = ({ content, moment, rrule }) => { dateStart: `${Moment(content.start).format('DD-MM-Y')}`, })} {eventRecurrenceText && ( -

{eventRecurrenceText}
+
+ {eventRecurrenceText} + {(additionalDates.length > 0 || removedDates.length > 0) && ( + {intl.formatMessage(messages.exceptionDates)} + )} +
)}

) : null; diff --git a/src/helpers/dates.js b/src/helpers/dates.js index 58464e1e7..4c25ae409 100644 --- a/src/helpers/dates.js +++ b/src/helpers/dates.js @@ -54,3 +54,22 @@ export const getRealEventEnd = (content, rruleSet) => { } return actualEndDate; }; + +export const getRecurrenceExceptionDates = (rruleSet) => { + const rdates = rruleSet?.rdates() ?? []; + const exdates = rruleSet?.exdates() ?? []; + + const additionalDates = rdates.reduce((acc, curr) => { + const isExdate = exdates.some((b) => b.toString() === curr.toString()); + if (!isExdate) { + return [...acc, curr]; + } else return acc; + }, []); + + const exceptionDates = { + additionalDates: additionalDates, + removedDates: exdates, + }; + + return exceptionDates; +}; diff --git a/src/helpers/index.js b/src/helpers/index.js index e64d0531d..f8b0335bb 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -22,6 +22,7 @@ export { viewDate, getRealStartAndEndWithRecurrence, getRealEventEnd, + getRecurrenceExceptionDates, } from 'design-comuni-plone-theme/helpers/dates'; export { getSiteProperty } from 'design-comuni-plone-theme/helpers/config'; export { useDebouncedEffect } from 'design-comuni-plone-theme/helpers/debounce';