From 0df5d6f207de219ab274ae6abf9ebcce190d3a36 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 17 Nov 2015 17:59:23 +0000 Subject: [PATCH] Fix planner events - Createing event by clicking on row had wrong end date - Display problems from previous commit --- calendar/inc/class.calendar_uiforms.inc.php | 21 ++++++++++++++------- calendar/js/et2_widget_event.js | 2 +- calendar/js/et2_widget_planner.js | 2 +- calendar/js/et2_widget_planner_row.js | 6 +++--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index c36803938f..6200b02ff8 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -116,11 +116,18 @@ class calendar_uiforms extends calendar_ui // by default include the owner as participant (the user can remove him) $extra_participants[] = $owner; - $start = $this->bo->date2ts(array( - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, - 'hour' => (int) (isset($_GET['hour']) && (int) $_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), - 'minute' => (int) $_GET['minute'], - )); + if(isset($_GET['start'])) + { + $start = egw_time::to($_GET['start'], 'ts'); + } + else + { + $start = $this->bo->date2ts(array( + 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, + 'hour' => (int) (isset($_GET['hour']) && (int) $_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), + 'minute' => (int) $_GET['minute'], + )); + } //echo "

_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."

\n"; $participant_types['u'] = $participant_types = $participants = array(); @@ -1393,8 +1400,8 @@ foreach($recur_event as $_k => $_v) error_log($_k . ': ' . array2string($_v)); } } // set new start and end if given by $_GET - if(isset($_GET['start'])) { $event['start'] = $_GET['start']; } - if(isset($_GET['end'])) { $event['end'] = $_GET['end']; } + if(isset($_GET['start'])) { $event['start'] = egw_time::to($_GET['start'],'ts'); } + if(isset($_GET['end'])) { $event['end'] = egw_time::to($_GET['end'],'ts'); } if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } // check if the event is the whole day $start = $this->bo->date2array($event['start']); diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index e04b6d0e0d..31cf60ccb6 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -482,7 +482,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], _sameday_check: function(event) { // Event somehow got orphaned - if(!this._parent || !this._parent.instanceOf(et2_calendar_daycol)) + if(!this._parent) { return false; } diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 96cfe439af..17c9ca9a0b 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -1842,7 +1842,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize var row = $j(_ev.target).closest('.calendar_plannerRowWidget'); var data = row.length ? row[0].dataset : {}; this.egw().open(null, 'calendar', 'add', jQuery.extend({ - date: date.toJSON(), + start: date.toJSON(), hour: date.getUTCHours(), minute: date.getUTCMinutes() },data) , '_blank'); diff --git a/calendar/js/et2_widget_planner_row.js b/calendar/js/et2_widget_planner_row.js index 6897ddae61..cccf88c0ba 100644 --- a/calendar/js/et2_widget_planner_row.js +++ b/calendar/js/et2_widget_planner_row.js @@ -228,7 +228,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM], { // Create event var event = et2_createWidget('calendar-event',{ - id:events[c].app_id||events[c].id, + id:events[c].id, value: events[c] },this); if(this.isInTree()) @@ -241,9 +241,9 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM], } // Seperate loop so column sorting finds all children in the right place - for(var c = 0; c < events.length; c++) + for(var c = 0; c < events.length && c < this._children.length; c++) { - this._children[c].set_value(events[c]); + this.getWidgetById(events[c].id).set_value(events[c]); } },