From b7c144423c7e245c57505e08fcf1ace9a5d92e54 Mon Sep 17 00:00:00 2001 From: ralf Date: Mon, 1 Jul 2024 11:39:28 +0200 Subject: [PATCH] fix adding and deleting of explicit recurrences / rdates (also disable recur-enddate in UI for RDates) --- calendar/inc/class.calendar_boupdate.inc.php | 6 ++++-- calendar/inc/class.calendar_uiforms.inc.php | 13 +++++++++++-- calendar/js/app.ts | 3 ++- calendar/lang/egw_de.lang | 1 + calendar/lang/egw_en.lang | 1 + 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index b0ed531063..fe5aa7aa88 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1577,8 +1577,10 @@ class calendar_boupdate extends calendar_bo $event['created'] = $save_event['created'] = $this->now; $event['creator'] = $save_event['creator'] = $this->user; } - $set_recurrences = $old_event ? abs(Api\DateTime::to($event['recur_enddate'] ?? null, 'utc') - Api\DateTime::to($old_event['recur_enddate'] ?? null, 'utc')) > 1 || - count($old_event['recur_exception'] ?? []) != count($event['recur_exception'] ?? []) : false; + $set_recurrences = !$old_event ? false : + abs(Api\DateTime::to($event['recur_enddate'] ?? null, 'utc') - Api\DateTime::to($old_event['recur_enddate'] ?? null, 'utc')) > 1 || + count($old_event['recur_exception'] ?? []) != count($event['recur_exception'] ?? []) || + count($old_event['recur_rdates'] ?? []) != count($event['recur_rdates'] ?? []); $set_recurrences_start = 0; if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && !empty($event['recur_type'])) { diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 5f4545eca4..35837a0d31 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -344,8 +344,17 @@ class calendar_uiforms extends calendar_ui unset($content['recur_rdates']['delete_rdate']); if (($key = array_search($date, $content['recur_rdates'])) !== false) { - unset($content['recur_rdates'][$key]); - $content['recur_rdates'] = array_values($content['recur_rdates']); + // if this is an initial edit, simply remove the rdate + if (empty($content['id'])) + { + unset($content['recur_rdates'][$key]); + $content['recur_rdates'] = array_values($content['recur_rdates']); + } + // otherwise add the recurrence as (deleted) exception + elseif (!in_array($date, $content['recur_exception'])) + { + $content['recur_exception'][] = $date; + } } } // delete an alarm diff --git a/calendar/js/app.ts b/calendar/js/app.ts index 56da6bf188..c934332210 100644 --- a/calendar/js/app.ts +++ b/calendar/js/app.ts @@ -317,7 +317,7 @@ export class CalendarApp extends EgwApp { this.freetime_search(); } - //send Syncronus ajax request to the server to unlock the on close entry + //send synchronous ajax request to the server to unlock the on close entry //set onbeforeunload with json request to send request when the window gets close by X button if (content.data.lock_token) { @@ -1421,6 +1421,7 @@ export class CalendarApp extends EgwApp { addRdate.set_disabled(recurType.value != 9); recurRdate.set_disabled(recurType.value != 9); + this.et2.getWidgetById('recur_enddate')?.set_disabled(recurType.value == 9); } } diff --git a/calendar/lang/egw_de.lang b/calendar/lang/egw_de.lang index f4bba6d119..cf73c18e3d 100644 --- a/calendar/lang/egw_de.lang +++ b/calendar/lang/egw_de.lang @@ -36,6 +36,7 @@ add recurrence calendar de Wiederholung hinzufügen add timesheet entry calendar de Stundenzettel hinzufügen added calendar de Neuer Termin added by synchronization calendar de Durch Synchronisation hinzugefügt +added recurrence on %1. calendar de Wiederholung am %1 hinzugefügt. after calendar de Nach after %1 calendar de Nach dem %1 after current date calendar de Nach dem aktuellen Datum diff --git a/calendar/lang/egw_en.lang b/calendar/lang/egw_en.lang index 5b68e1f494..45b28b7d1c 100644 --- a/calendar/lang/egw_en.lang +++ b/calendar/lang/egw_en.lang @@ -36,6 +36,7 @@ add recurrence calendar en Add recurrence add timesheet entry calendar en Add timesheet entry added calendar en Added added by synchronization calendar en Added by synchronization +added recurrence on %1. calendar en Added recurrence on %1. after calendar en After after %1 calendar en After %1 after current date calendar en After current date