From 2dc457c00787ea9715f9f59e069bbe6bfb904a22 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 6 Oct 2020 13:55:06 -0600 Subject: [PATCH] Calendar: More checks to avoid 0 duration events --- calendar/inc/class.calendar_uiforms.inc.php | 5 +++++ calendar/js/app.js | 8 ++++++++ calendar/js/app.ts | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 5b21e99084..3497142461 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -359,6 +359,11 @@ class calendar_uiforms extends calendar_ui unset($content['alarm'][$id]); } } + if($content['end'] && $content['start'] >= $content['end']) + { + unset($content['end']); + $content['duration'] = $this->bo->cal_prefs['defaultlength']*60; + } if ($content['duration']) { $content['end'] = $content['start'] + $content['duration']; diff --git a/calendar/js/app.js b/calendar/js/app.js index 9c061cee86..e4b2d527cb 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1287,6 +1287,14 @@ var CalendarApp = /** @class */ (function (_super) { if (recur_end && recur_end.getValue && !recur_end.getValue()) { recur_end.set_min(widget.getValue()); } + // Update end date, min duration is 1 minute + var end = widget.getRoot().getDOMWidgetById('end'); + var start_time = new Date(widget.getValue()); + var end_time = new Date(end.getValue()); + if (end_time <= start_time) { + start_time.setMinutes(start_time.getMinutes() + 1); + end.set_value(start_time); + } } // Update currently selected alarm time this.alarm_custom_date(); diff --git a/calendar/js/app.ts b/calendar/js/app.ts index 504693c396..cd143b6592 100644 --- a/calendar/js/app.ts +++ b/calendar/js/app.ts @@ -1347,9 +1347,20 @@ class CalendarApp extends EgwApp { recur_end.set_min(widget.getValue()); } + + // Update end date, min duration is 1 minute + let end = widget.getRoot().getDOMWidgetById('end'); + let start_time = new Date(widget.getValue()); + let end_time = new Date(end.getValue()); + if(end_time <= start_time) + { + start_time.setMinutes(start_time.getMinutes() + 1); + end.set_value(start_time); + } } // Update currently selected alarm time this.alarm_custom_date(); + } /**