diff --git a/RELEASE.md b/RELEASE.md index 8ad7c3aa6..a2864c1d5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -41,6 +41,20 @@ - ... --> +## Versione X.X.X (dd/mm/yyyy) + +### Migliorie + +- 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à + +- ... + +### Fix + +- La pagina non dà più errore quando si imposta una ricorrenza con impostazione "Termina dopo tot. ricorrenze". + ## Versione 11.25.3 (12/12/2024) ### Migliorie diff --git a/src/components/ItaliaTheme/View/Commons/Dates.jsx b/src/components/ItaliaTheme/View/Commons/Dates.jsx index fc25e542c..6ea82e5e4 100644 --- a/src/components/ItaliaTheme/View/Commons/Dates.jsx +++ b/src/components/ItaliaTheme/View/Commons/Dates.jsx @@ -85,6 +85,7 @@ const Dates = ({ content, show_image, moment: momentlib, rrule }) => { const start = viewDate(intl.locale, content.start); // format and save date into new variable depending on recurrence of event const end = viewDate(intl.locale, actualEndDate); + const openEnd = content?.open_end; const wholeDay = content?.whole_day; const rdates = rruleSet?.rdates() ?? []; @@ -133,11 +134,11 @@ const Dates = ({ content, show_image, moment: momentlib, rrule }) => {
- {end.format('DD')} + {end?.format('DD')} - {end.format('MMMM')} - {!end.isSame(start, 'year') && ( - {end.format('YYYY')} + {end?.format('MMMM')} + {!end?.isSame(start, 'year') && ( + {end?.format('YYYY')} )}
@@ -148,7 +149,7 @@ const Dates = ({ content, show_image, moment: momentlib, rrule }) => { > - {!content.whole_day && `${end.format('HH:mm')} - `} + {!content.whole_day && `${end?.format('HH:mm')} - `} {intl.formatMessage(messages.end)} diff --git a/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx b/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx index d886f4f67..baf99adf7 100644 --- a/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx +++ b/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx @@ -36,18 +36,20 @@ const PageHeaderEventDates = ({ content, moment, rrule }) => { const actualEndDate = getRealEventEnd(content, rruleSet); - const wholeDay = content?.whole_day; + // const wholeDay = content?.whole_day; const openEnd = content?.open_end; // show only start when event starts and ends in same day or if a recurrence is set // because to set a recurrence, the event must have the same date as start and end date const renderOnlyStart = Moment(content.end).format('DD-MM-Y') === - Moment(content.start).format('DD-MM-Y') && !content.recurrence; + Moment(content.start).format('DD-MM-Y'); + let eventRecurrenceText = null; if (content['@type'] === 'Event') { if (content.recurrence) { const isRecurrenceByDay = content.recurrence.includes('BYDAY=+'); + const isRecurrenceByMonthDay = content.recurrence.includes('BYMONTHDAY='); const isWeekdaySunday = content.recurrence .split('BYDAY')[1] ?.includes('SU'); @@ -55,7 +57,10 @@ const PageHeaderEventDates = ({ content, moment, rrule }) => { const RRULE_LANGUAGE = rrulei18n(intl, Moment); eventRecurrenceText = rruleSet.rrules()[0]?.toText( (t) => { - if (Moment.locale(intl.locale) === 'it' && isRecurrenceByDay) { + if ( + Moment.locale(intl.locale) === 'it' && + (isRecurrenceByDay || isRecurrenceByMonthDay) + ) { RRULE_LANGUAGE.strings.th = '°'; RRULE_LANGUAGE.strings.nd = '°'; RRULE_LANGUAGE.strings.rd = '°'; @@ -79,11 +84,11 @@ const PageHeaderEventDates = ({ content, moment, rrule }) => { return content['@type'] === 'Event' ? (

- {!Moment(content.end).isSame(actualEndDate) && + {(content.recurrence || !renderOnlyStart) && !openEnd && - !renderOnlyStart && `dal ${Moment(content.start).format('DD-MM-Y')} al ${endDate}`} - {(renderOnlyStart || Moment(content.end).isSame(actualEndDate)) && + {!content.recurrence && + renderOnlyStart && !openEnd && `${Moment(content.start).format('DD-MM-Y')}`} {openEnd && diff --git a/src/helpers/dates.js b/src/helpers/dates.js index bf7fde920..58464e1e7 100644 --- a/src/helpers/dates.js +++ b/src/helpers/dates.js @@ -48,7 +48,8 @@ export const getRealStartAndEndWithRecurrence = ( export const getRealEventEnd = (content, rruleSet) => { let actualEndDate = content.end; - if (content.recurrence) { + + if (content.recurrence && rruleSet.rrules()[0].options.until) { actualEndDate = rruleSet.rrules()[0].options.until; } return actualEndDate;