diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 6f4b802e98..5bfb043c2f 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -213,12 +213,14 @@ class calendar_uiforms extends calendar_ui 'id' => 1, ); } + $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; + $end = isset($_GET['end']) ? Api\DateTime::to($_GET['end'], 'ts') : $start + $duration; return array( 'participant_types' => $participant_types, 'participants' => $participants, 'owner' => $owner, 'start' => $start, - 'end' => $start + (int) $this->bo->cal_prefs['defaultlength']*60, + 'end' => $end, 'tzid' => $this->bo->common_prefs['tz'], 'priority' => 2, // normal 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, diff --git a/calendar/js/app.js b/calendar/js/app.js index 19c077cfb2..91ad0b3969 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -65,6 +65,9 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( owner: egw.user('account_id') }, + /** + * These are the keys we keep to set & remember the status, others are discarded + */ states_to_save: ['owner','status_filter','filter','cat_id','view','sortby','planner_view','weekend'], // If you are in one of these views and select a date in the sidebox, the view @@ -542,7 +545,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( if(!sortable.sortable('instance')) { sortable.sortable({ - cancel: "#divAppboxHeader, .calendar_calWeekNavHeader, .calendar_plannerHeader", + cancel: "#divAppboxHeader, .calendar_calWeekNavHeader, .calendar_calDayColHeader, .calendar_plannerHeader", handle: '.calendar_calGridHeader', //placeholder: "srotable_cal_wk_ph", axis:"y", diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 8c2be12bc4..83cc8da55a 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -129,10 +129,6 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e this._drawGrid(); } - // Actions may be set on a parent, so we need to explicitly get in here - // and get ours - this._link_actions(this.options.actions || this._parent.options.actions || []); - // Automatically bind drag and resize for every event using jQuery directly // - no action system - var planner = this; @@ -268,13 +264,26 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e planner.vertical_bar .html(''+date(egw.preference('timeformat','calendar') == 12 ? 'h:ia' : 'H:i',formatDate)+'') .show(); + + if(planner.drag_create.event && planner.drag_create.parent && planner.drag_create.end) + { + + planner.drag_create.end.date = time.toJSON() + planner._drag_update_event(); + } } else { // No (valid) time, just hide planner.vertical_bar.hide(); } - }); + }) + .on('mousedown', jQuery.proxy(this._mouse_down, this)) + .on('mouseup', jQuery.proxy(this._mouse_up, this)); + + // Actions may be set on a parent, so we need to explicitly get in here + // and get ours + this._link_actions(this.options.actions || this._parent.options.actions || []); // Customize and override some draggable settings this.div.on('dragcreate','.calendar_calEvent', function(event, ui) { @@ -742,12 +751,6 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e this.widget._drawGrid(); - // Update actions - if(this.widget._actionManager) - { - this.widget._link_actions(this.widget._actionManager.children); - } - if(this.trigger) { this.widget.change(); @@ -1909,6 +1912,9 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e { var result = true; + // Drag to create in progress + if(this.drag_create.start !== null) return; + // Is this click in the event stuff, or in the header? if(!this.options.readonly && this.gridHeader.has(_ev.target).length === 0 && !jQuery(_ev.target).hasClass('calendar_plannerRowHeader')) { diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 34c3a93e32..74a31cdacf 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -328,6 +328,27 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. }) .on('mousemove', function(event) { timegrid._get_time_from_position(event.clientX, event.clientY); + + if(timegrid.drag_create.event && timegrid.drag_create.parent && timegrid.drag_create.end) + { + var end = jQuery.extend({}, timegrid.gridHover[0].dataset); + if(end.date) + { + timegrid.date_helper.set_year(end.date.substring(0,4)); + timegrid.date_helper.set_month(end.date.substring(4,6)); + timegrid.date_helper.set_date(end.date.substring(6,8)); + if(end.hour) + { + timegrid.date_helper.set_hours(end.hour); + } + if(end.minute) + { + timegrid.date_helper.set_minutes(end.minute); + } + timegrid.drag_create.end.date = timegrid.date_helper.get_value(); + } + timegrid._drag_update_event(); + } }) .on('mouseout', function(event) { if(timegrid.div.has(event.relatedTarget).length === 0) @@ -1782,6 +1803,9 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. click: function(_ev) { var result = true; + + // Drag to create in progress + if(this.drag_create.start !== null) return; // Drag to create in progress if(this.drag_create.start !== null) return; @@ -2250,4 +2274,4 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. } } });}).call(this); -et2_register_widget(et2_calendar_timegrid, ["calendar-timegrid"]); \ No newline at end of file +et2_register_widget(et2_calendar_timegrid, ["calendar-timegrid"]);