From 0861a6d58ca19813a133c80ba40705512423c2f5 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 18 Nov 2015 17:44:22 +0000 Subject: [PATCH] Fix some more sneaky caching / refresh bugs --- calendar/inc/class.calendar_uilist.inc.php | 2 +- calendar/js/app.js | 12 +++-- calendar/js/et2_widget_daycol.js | 57 +++++++++++----------- calendar/js/et2_widget_event.js | 1 + 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index c8bdb80146..bb4160542d 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -368,7 +368,7 @@ class calendar_uilist extends calendar_ui } if ($params['col_filter']['participant']) { - $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : (int) $params['col_filter']['participant']; + $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array((int) $params['col_filter']['participant']); } elseif (!$params['col_filter'] || !array_key_exists('participant',$params['col_filter'])) { diff --git a/calendar/js/app.js b/calendar/js/app.js index 1d4364bfb4..38bdcb7293 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -2203,7 +2203,7 @@ app.classes.calendar = AppJS.extend( { // Cache is by date (and owner, if seperate) var date = t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate()); - var cache_id = app.classes.calendar._daywise_cache_id(date, seperate_owners ? value[i].owner : state.owner||false); + var cache_id = app.classes.calendar._daywise_cache_id(date, seperate_owners && value[i].owner ? value[i].owner : state.owner||false); if(egw.dataHasUID(cache_id)) { @@ -2285,7 +2285,7 @@ app.classes.calendar = AppJS.extend( col_filter: {participant: (typeof state.owner == 'string' || typeof state.owner == 'number' ? [state.owner] : state.owner)}, filter:'custom', // Must be custom to get start & end dates status_filter: state.filter, - cat_id: state.cat_id, + cat_id: state.cat_id.join('') != '' ? state.cat_id : false, search: state.keywords, csv_export: false }); @@ -2371,9 +2371,13 @@ app.classes.calendar = AppJS.extend( var expanded_date = ''+t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate()); if(typeof(updated_days[expanded_date]) === 'undefined') { - updated_days[expanded_date] = []; + // Check to make sure it's in range first, expanded_date could be after our end + if(expanded_date >= bounds.first && expanded_date <= bounds.last) + { + updated_days[expanded_date] = []; + } } - if(record.data.date !== expanded_date) + if(record.data.date !== expanded_date && typeof updated_days[expanded_date] !== 'undefined') { // Copy, to avoid unwanted changes by reference updated_days[expanded_date].push(record.data.row_id); diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index 0aaaf2a390..b410c42a7b 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -268,24 +268,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM], // Register for updates on events for this day var cache_id = app.classes.calendar._daywise_cache_id(new_date,this.options.owner); - egw.dataRegisterUID(cache_id, function(event_ids) { - var events = []; - if(event_ids == null || typeof event_ids.length == 'undefined') event_ids = []; - for(var i = 0; i < event_ids.length; i++) - { - var event = egw.dataGetUIDdata('calendar::'+event_ids[i]); - event = event.data || false; - if(event && event.date && ( - event.date === this.options.date || - // Accept multi-day events - new Date(event.start) <= this.date //&& new Date(event.end) >= this.date - )) - { - events.push(event); - } - } - this._update_events(events); - },this,this.getInstanceManager().execId,this.id); + egw.dataRegisterUID(cache_id, this._data_callback,this,this.getInstanceManager().execId,this.id); if(events) { this._update_events(events); @@ -314,19 +297,35 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM], this.div.attr('data-sortable-id', this.options.owner); // Register for updates on events for this day - egw.dataRegisterUID(app.classes.calendar._daywise_cache_id(this.options.date,this.options.owner), function(event_ids) { - var events = []; - if(event_ids == null || typeof event_ids.length == 'undefined') event_ids = []; - for(var i = 0; i < event_ids.length; i++) + egw.dataRegisterUID( + app.classes.calendar._daywise_cache_id(this.options.date,this.options.owner), + this._data_callback,this,this.getInstanceManager().execId,this.id + ); + }, + + /** + * Callback used when the daywise data changes + * + * @param {String[]} event_ids + * @returns {undefined} + */ + _data_callback: function(event_ids) { + var events = []; + if(event_ids == null || typeof event_ids.length == 'undefined') event_ids = []; + for(var i = 0; i < event_ids.length; i++) + { + var event = egw.dataGetUIDdata('calendar::'+event_ids[i]); + event = event.data || false; + if(event && event.date && ( + event.date === this.options.date || + // Accept multi-day events + new Date(event.start) <= this.date //&& new Date(event.end) >= this.date + )) { - var event = egw.dataGetUIDdata('calendar::'+event_ids[i]).data; - if(event && event.date && event.date === this.options.date) - { - events.push(event); - } + events.push(event); } - this._update_events(events); - },this,this.getInstanceManager().execId,this.id); + } + this._update_events(events); }, set_left: function(left) { diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 13a6decb40..dcc33ae7e9 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -117,6 +117,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], this.div.remove(); this.div = null; + $j('body.egw_tooltip').remove(); // Unregister, or we'll continue to be notified... if(this.options.value)