From 47813048abe91ef81eebe7530b9c46fd990e845f Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 6 Aug 2015 17:14:20 +0000 Subject: [PATCH] Calendar et2 conversion bugs: - Home favorites were missing data - View selectbox did not show Planner when you clicked the button - Weekend toggle did not affect multi-week view - Refresh lost the event if it changed day --- calendar/js/et2_widget_daycol.js | 4 +-- calendar/js/et2_widget_event.js | 6 ++-- calendar/js/et2_widget_planner.js | 48 +++++++++++++++++++++++++-- calendar/js/et2_widget_planner_row.js | 3 +- calendar/js/et2_widget_timegrid.js | 14 +++++--- calendar/templates/default/app.css | 8 +++++ calendar/templates/pixelegg/app.css | 9 ++++- 7 files changed, 78 insertions(+), 14 deletions(-) diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index 0cb5c78a3b..55aa2c8388 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -246,14 +246,14 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea /** * Set the owner of this day * - * @param {number} _owner Account ID + * @param {number|number[]} _owner Account ID */ set_owner: function(_owner) { if(_owner !== this.options.owner) { egw.dataUnregisterUID(app.classes.calendar._daywise_cache_id+(this.options.date,this.options.owner),false,this); - this.options.owner = parseInt(_owner); + this.options.owner = _owner; this.div.attr('data-sortable-id', this.options.owner); // Register for updates on events for this day diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 7064fc6dc4..7c27f1a451 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -99,7 +99,9 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], // Register for updates var app_id = this.options.value.app_id ? this.options.value.app_id : this.options.value.id + (this.options.value.recur_type ? ':'+this.options.value.recur_date : ''); egw.dataRegisterUID('calendar::'+app_id, function(event) { - if(this._parent && this.options.value.date && event.date != this.options.value.date) + // Check for changing days in the grid view + if(this._parent && this._parent.instanceOf(et2_calendar_daycol) && + this.options.value.date && event.date != this.options.value.date) { // Date changed, reparent var new_parent = this._parent._parent.getWidgetById(event.date); @@ -112,8 +114,8 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], // Could not find the right date this._parent.removeChild(this); this.destroy(); + return; } - return; } // Copy to avoid changes, which may cause nm problems this.options.value = jQuery.extend({},event); diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 88520daca1..d68a874e97 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -591,7 +591,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize */ _header_months: function(start, days) { - var content = '
'; + var content = '
'; var days_in_month = 0; var day_width = 100 / days; for(var t = new Date(start),left = 0,i = 0; i < days; t.setUTCDate(t.getUTCDate() + days_in_month),left += days_in_month*day_width,i += days_in_month) @@ -741,6 +741,8 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize { var next = new Date(t); next.setUTCDate(next.getUTCDate() + 1); + next.setUTCHours(0); + next.setUTCMinutes(0); title += this._scroll_button('right',next.toJSON()); } } @@ -772,7 +774,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize var hours = days * 24; if (days === 1) // for a single day we calculate the hours of a days, to take into account daylight saving changes (23 or 25 hours) { - var t = new Date(start.getUTCFullYear(),start.getUTCMonth(),start.getUTCDate()); + var t = new Date(start.getUTCFullYear(),start.getUTCMonth(),start.getUTCDate(),-start.getTimezoneOffset()/60); var s = new Date(start); s.setUTCHours(23); s.setUTCMinutes(59); @@ -789,7 +791,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize { var title = date(egw.preference('timeformat','calendar') == 12 ? 'ha' : 'H',t); - content += '
'+title+"
"; + content += '
'+title+"
"; t.setHours(t.getHours()+decr); } content += "
"; // end of plannerScale @@ -1033,6 +1035,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize _fetch_data: function() { var value = []; + var fetch = false; // Remember previous day to avoid multi-days duplicating var last_data = []; @@ -1060,9 +1063,23 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize } last_data = c.data; } + else + { + fetch = true; + } t.setUTCDate(t.getUTCDate() + 1); } while(t < end); + // Need to get some more from the server + if(fetch && app.calendar) + { + app.calendar._fetch_data({ + first: this.options.start_date, + last: this.options.end_date, + owner: this.options.owner, + filter: this.options.filter + }, this.getInstanceManager()); + } return value; }, @@ -1327,6 +1344,31 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize // Click on a header, we can go there _ev.data = jQuery.extend({},_ev.target.parentNode.dataset, _ev.target.dataset); debugger; + // Handle it locally + var old_start = this.options.start_date; + if(_ev.data.date) + { + this.set_start_date(_ev.data.date); + } + if(_ev.data.planner_days) + { + _ev.data.planner_days = parseInt(_ev.data.planner_days); + if(_ev.data.planner_days) + { + var d = new Date(this.options.start_date); + d.setUTCDate(d.getUTCDate() +_ev.data.planner_days-1); + this.set_end_date(d); + } + } + else + { + var diff = Math.round((new Date(this.options.start_date) - new Date(old_start)) / (1000 * 3600 * 24)); + var end = new Date(this.options.end_date); + end.setUTCDate(end.getUTCDate() + diff) + this.set_end_date(end); + } + + // Notify anyone who's interested this.change(_ev); } else diff --git a/calendar/js/et2_widget_planner_row.js b/calendar/js/et2_widget_planner_row.js index 1c2a4b5488..25ee5101a0 100644 --- a/calendar/js/et2_widget_planner_row.js +++ b/calendar/js/et2_widget_planner_row.js @@ -354,6 +354,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM], if(this._parent.options.group_by !== 'month') { // Daywise scaling + /* Needs hourly scales that consider working hours var start_date = new Date(start.getUTCFullYear(), start.getUTCMonth(),start.getUTCDate()); var end_date = new Date(end.getUTCFullYear(), end.getUTCMonth(),end.getUTCDate()); var t_date = new Date(t.getUTCFullYear(), t.getUTCMonth(),t.getUTCDate()); @@ -378,7 +379,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM], } pos += day_percentage / days; } - + */ } pos = 100 * pos; diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 4a268c5e01..27a59fb2ec 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -320,8 +320,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz // Leave the helper there until the update is done var loading = ui.helper.clone().appendTo(ui.helper.parent()); - loading.addClass('loading'); - + // and add a loading icon so user knows something is happening + $j('.calendar_timeDemo',loading).after('
'); + event_widget.recur_prompt(function(button_id) { if(button_id === 'cancel' || !button_id) return; //Get infologID if in case if it's an integrated infolog event @@ -543,12 +544,12 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz if(typeof this.value[this.day_list[i]] === 'undefined') { var ids = (egw.dataGetUIDdata(app.classes.calendar._daywise_cache_id(this.day_list[i],this.options.owner))||{data:[]}); - for(var j = 0; j < ids.length; j++) + for(var j = 0; j < ids.data.length; j++) { this.value[this.day_list[i]] = []; - if(egw.dataHasUID('calendar::'+ids[j])) + if(egw.dataHasUID('calendar::'+ids.data[j])) { - this.value[this.day_list[i]].push(egw.dataGetUIDdata('calendar::'+ids[j]).data); + this.value[this.day_list[i]].push(egw.dataGetUIDdata('calendar::'+ids.data[j]).data); } } } @@ -561,6 +562,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz // Position $j(day.getDOMNode()).css('left', ((100/this.day_list.length).toFixed(2) * i) + '%'); } + + // Don't hold on to value any longer, use the data cache for best info + this.value = {}; // TODO: Figure out how to do this with detached nodes /* diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index d4d59ce319..2cf3fbbb38 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -701,6 +701,14 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget font-weight: bold; text-align: center; } +.calendar_d-n-d_timeCounter .loading +{ + width: 16px; + height: 16px; + position: absolute; + bottom: 0px; + right: 0px; +} #calendar-edit_action { width: 10em; diff --git a/calendar/templates/pixelegg/app.css b/calendar/templates/pixelegg/app.css index 0c45742a0e..bbca91db8f 100755 --- a/calendar/templates/pixelegg/app.css +++ b/calendar/templates/pixelegg/app.css @@ -11,7 +11,7 @@ * @package calendar * @version $Id$ */ -/* $Id: app.css 53038 2015-07-02 19:31:52Z nathangray $ */ +/* $Id: app.css 53111 2015-07-15 16:29:10Z nathangray $ */ /*Media print classes*/ @media print { .th td, @@ -701,6 +701,13 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget font-weight: bold; text-align: center; } +.calendar_d-n-d_timeCounter .loading { + width: 16px; + height: 16px; + position: absolute; + bottom: 0px; + right: 0px; +} #calendar-edit_action { width: 10em; padding-left: 10px;