Skip to content

Commit

Permalink
fix: changed conditions for date range in header subtitle for ct event (
Browse files Browse the repository at this point in the history
#825)

* fix: changed conditions for date range in header subtitle for ct event

* fix: managed terminates after x occurrences

---------

Co-authored-by: Piero Nicolli <[email protected]>
  • Loading branch information
sabrina-bongiovanni and pnicolli authored Dec 19, 2024
1 parent ac69380 commit bfc673d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
14 changes: 14 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions src/components/ItaliaTheme/View/Commons/Dates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() ?? [];
Expand Down Expand Up @@ -133,11 +134,11 @@ const Dates = ({ content, show_image, moment: momentlib, rrule }) => {
<div className="point-list">
<div className="point-list-aside point-list-warning">
<span className="point-date font-monospace">
{end.format('DD')}
{end?.format('DD')}
</span>
<span className="point-month">{end.format('MMMM')}</span>
{!end.isSame(start, 'year') && (
<span className="point-month">{end.format('YYYY')}</span>
<span className="point-month">{end?.format('MMMM')}</span>
{!end?.isSame(start, 'year') && (
<span className="point-month">{end?.format('YYYY')}</span>
)}
</div>
<div className="point-list-content">
Expand All @@ -148,7 +149,7 @@ const Dates = ({ content, show_image, moment: momentlib, rrule }) => {
>
<CardBody tag="div" className={'card-body'}>
<CardTitle tag="p">
{!content.whole_day && `${end.format('HH:mm')} - `}
{!content.whole_day && `${end?.format('HH:mm')} - `}
{intl.formatMessage(messages.end)}
</CardTitle>
</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,31 @@ 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');

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 = '°';
Expand All @@ -79,11 +84,11 @@ const PageHeaderEventDates = ({ content, moment, rrule }) => {

return content['@type'] === 'Event' ? (
<p className="h4 py-2">
{!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 &&
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/dates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bfc673d

Please sign in to comment.