From 6eb3ca259249355f591ab8f6ef7cfbfcd036b5f8 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 15 May 2018 09:47:10 -0600 Subject: [PATCH] Fix whole day event checkbox lost the default alarm, change 24 hours label to 1 days --- calendar/inc/class.calendar_uiforms.inc.php | 2 +- calendar/js/app.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 7de85d9984..169e2b5fe0 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -338,7 +338,7 @@ class calendar_uiforms extends calendar_ui { $content['alarm'][1]['offset'] = $offset = 60 * $def_alarm; $content['start'] = $this->bo->date2array($content['start']); - $content['start'][1]['offset'] = $this->bo->date2ts($content['start']) - $offset; + $content['start'][1]['time'] = $this->bo->date2ts($content['start']) - $offset; $content['start'] = $this->bo->date2ts($content['start']); } } diff --git a/calendar/js/app.js b/calendar/js/app.js index 456a461b2e..9e6b0093cf 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -2710,7 +2710,8 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( /** * Set alarm options based on WD/Regular event user preferences - * Gets fired by wholeday checkbox + * Gets fired by wholeday checkbox. This is mainly for display purposes, + * the default alarm is calculated on the server as well. * * @param {egw object} _egw * @param {widget object} _widget whole_day checkbox @@ -2728,14 +2729,18 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( var _secs_to_label = function (_secs) { var label=''; - if (_secs <= 3600) + if (_secs < 3600) { label = self.egw.lang('%1 minutes', _secs/60); } - else if(_secs <= 86400) + else if(_secs < 86400) { label = self.egw.lang('%1 hours', _secs/3600); } + else + { + label = self.egw.lang('%1 days', _secs/(3600*24)); + } return label; }; if (typeof content['alarm'][1]['default'] == 'undefined') @@ -2756,7 +2761,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( start.set_hours(0); start.set_minutes(0); time.set_value(start.get_value()); - time.set_value('-'+(60 * def_alarm)); + time.set_value(new Date(new Date(start.get_value()).valueOf() - (60*def_alarm*1000)).toJSON()); event.set_value(_secs_to_label(60 * def_alarm)); } }