diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index fe3e33bd87..c96847f9b6 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -1057,6 +1057,9 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte */ click: function(_ev) { + // Drag to create in progress + if(this._parent.drag_create.start !== null) return; + // Click on the title if (jQuery(_ev.target).hasClass('calendar_calAddEvent')) { diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 402d515056..95c477bacc 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -167,6 +167,21 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e } }, + /** + * If dragging to resize an event, abort drag to create + * + * @param {jQuery.Event} event + * @param {Object} ui + */ + start: function(event, ui) + { + if(planner.drag_create.start) + { + // Abort drag to create, we're dragging to resize + planner._drag_create_end({}); + } + }, + /** * Triggered at the end of resizing the calEvent. * @@ -598,7 +613,7 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e // Get its children immediately egw.json( - this.getInstanceManager().app+'.etemplate_widget_menupopup.ajax_get_options.etemplate', + 'EGroupware\\Api\\Etemplate\\Widget\\Select::ajax_get_options', ['select-cat',',,,calendar,'+cat_id[i]], function(data) { labels = labels.concat(data); @@ -1900,16 +1915,17 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e // Find the correct row so we know the parent var row = event.target.closest('.calendar_plannerRowWidget'); - var row_widget = null; for(var i = 0; i < this._children.length && row; i++) { if(this._children[i].div[0] === row) { this.drag_create.parent = this._children[i]; + // Clear cached events for re-layout + this._children[i]._cached_rows = []; break; } } - return this._drag_create_start({date: time.toJSON()}); + return this._drag_create_start(jQuery.extend({},this.drag_create.parent.node.dataset,{date: time.toJSON()})); }, /** diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 3d14aee09c..11df21de15 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -230,6 +230,21 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. } }, + /** + * If dragging to resize an event, abort drag to create + * + * @param {jQuery.Event} event + * @param {Object} ui + */ + start: function(event, ui) + { + if(timegrid.drag_create.start) + { + // Abort drag to create, we're dragging to resize + timegrid._drag_create_end({}); + } + }, + /** * Triggered at the end of resizing the calEvent. * @@ -1871,7 +1886,24 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. if(start.date) { // Set parent for event - this.drag_create.parent = this.getWidgetById(start.date); + if(this.daily_owner) + { + // Each 'day' is the same date, different user + // Find the correct row so we know the parent + var col = event.target.closest('.calendar_calDayCol'); + for(var i = 0; i < this._children.length && col; i++) + { + if(this._children[i].node === col) + { + this.drag_create.parent = this._children[i]; + break; + } + } + } + else + { + this.drag_create.parent = this.getWidgetById(start.date); + } // Format date this.date_helper.set_year(start.date.substring(0,4)); @@ -1918,6 +1950,8 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. } this.gridHover.css('cursor', ''); + + event.preventDefault(); return this._drag_create_end(end); }, diff --git a/calendar/js/et2_widget_view.js b/calendar/js/et2_widget_view.js index 3d6b66a102..cb662e8f46 100644 --- a/calendar/js/et2_widget_view.js +++ b/calendar/js/et2_widget_view.js @@ -516,9 +516,16 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend jQuery.extend(options,this.drag_create.start, end); delete(options.date); - if (this.options.owner !== app.calendar.state.owner && !options.owner) + // Make sure parent is set, if needed + if (this.drag_create.parent && this.drag_create.parent.options.owner !== app.calendar.state.owner && !options.owner) { - options.owner = this.options.owner; + options.owner = this.drag_create.parent.options.owner; + } + + // Remove empties + for(var key in options) + { + if(!options[key]) delete options[key]; } this.egw().open(null, 'calendar', 'add', options, '_blank'); @@ -540,8 +547,11 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend this.drag_create.start = null; this.drag_create.end = null; this.drag_create.parent = null; - this.drag_create.event.destroy(); - this.drag_create.event = null; + if(this.drag_create.event) + { + this.drag_create.event.destroy(); + this.drag_create.event = null; + } return false; }