From fe4d00551a6212dd3907e738bb23d9e26e4d309d Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 14 Oct 2016 13:34:58 -0600 Subject: [PATCH] Some bugfixes: - For some start / end date combinations, end date was incorrectly processed - Check readonly flag to avoid errors from drag & drop, click to create and drag to create --- calendar/js/et2_widget_daycol.js | 2 ++ calendar/js/et2_widget_event.js | 2 +- calendar/js/et2_widget_timegrid.js | 11 +++++++++-- calendar/js/et2_widget_view.js | 4 ++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index c9c44763c0..1eb34f05ee 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -1063,6 +1063,8 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte */ click: function(_ev) { + if(this._parent.options.readonly ) return; + // Drag to create in progress if(this._parent.drag_create.start !== null) return; diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 5cb8b75043..f7093ba99d 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -958,7 +958,7 @@ et2_calendar_event.owner_check = function owner_check(event, parent, owner_too) { options = parent.getArrayMgr("sel_options").getRoot().getEntry('owner'); } - if(event.participants && parent.options.owner) + if(event.participants && parent.options.owner.length > 0) { var parent_owner = jQuery.extend([], typeof parent.options.owner !== 'object' ? [parent.options.owner] : diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 3092c6a149..fc10ba5138 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -132,7 +132,7 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. destroy: function() { // Stop listening to tab changes - if(framework.getApplicationByName('calendar').tab) + if(typeof framework !== 'undefined' && framework.getApplicationByName('calendar').tab) { jQuery(framework.getApplicationByName('calendar').tab.contentDiv).off('show.' + this.id); } @@ -164,7 +164,7 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. this._super.apply(this, arguments); // Listen to tab show to make sure we scroll to the day start, not top - if(framework.getApplicationByName('calendar').tab) + if(typeof framework !== 'undefined' && framework.getApplicationByName('calendar').tab) { jQuery(framework.getApplicationByName('calendar').tab.contentDiv) .on('show.' + this.id, jQuery.proxy( @@ -1275,6 +1275,9 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. * @param {type} actionLinks */ _init_links_dnd: function(mgr,actionLinks) { + + if (this.options.readonly) return; + var self = this; var drop_link = mgr.getActionById('egw_link_drop'); @@ -1787,6 +1790,7 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. click: function(_ev) { var result = true; + if(this.options.readonly ) return; // Drag to create in progress if(this.drag_create.start !== null) return; @@ -1877,6 +1881,8 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. _mouse_down: function(event) { if(event.which !== 1) return; + + if (this.options.readonly) return; var start = jQuery.extend({},this.gridHover[0].dataset); if(start.date) @@ -1953,6 +1959,7 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. */ _mouse_up: function(event) { + if (this.options.readonly) return; var end = jQuery.extend({}, this.gridHover[0].dataset); if(end.date) { diff --git a/calendar/js/et2_widget_view.js b/calendar/js/et2_widget_view.js index 109e089040..acd1f7186d 100644 --- a/calendar/js/et2_widget_view.js +++ b/calendar/js/et2_widget_view.js @@ -151,6 +151,8 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend else if(typeof new_date === "string") { this.date_helper.set_year(new_date.substring(0,4)); + // Avoid overflow into next month, since we re-use date_helper + this.date_helper.set_date(1); this.date_helper.set_month(new_date.substring(4,6)); this.date_helper.set_date(new_date.substring(6,8)); } @@ -190,6 +192,8 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend else if(typeof new_date === "string") { this.date_helper.set_year(new_date.substring(0,4)); + // Avoid overflow into next month, since we re-use date_helper + this.date_helper.set_date(1); this.date_helper.set_month(new_date.substring(4,6)); this.date_helper.set_date(new_date.substring(6,8)); }