Fix some more sneaky caching / refresh bugs

This commit is contained in:
Nathan Gray 2015-11-18 17:44:22 +00:00
parent adbc4d2b8b
commit 0861a6d58c
4 changed files with 38 additions and 34 deletions

View File

@ -368,7 +368,7 @@ class calendar_uilist extends calendar_ui
} }
if ($params['col_filter']['participant']) 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'])) elseif (!$params['col_filter'] || !array_key_exists('participant',$params['col_filter']))
{ {

View File

@ -2203,7 +2203,7 @@ app.classes.calendar = AppJS.extend(
{ {
// Cache is by date (and owner, if seperate) // Cache is by date (and owner, if seperate)
var date = t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate()); 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)) 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)}, 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 filter:'custom', // Must be custom to get start & end dates
status_filter: state.filter, status_filter: state.filter,
cat_id: state.cat_id, cat_id: state.cat_id.join('') != '' ? state.cat_id : false,
search: state.keywords, search: state.keywords,
csv_export: false 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()); var expanded_date = ''+t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate());
if(typeof(updated_days[expanded_date]) === 'undefined') 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 // Copy, to avoid unwanted changes by reference
updated_days[expanded_date].push(record.data.row_id); updated_days[expanded_date].push(record.data.row_id);

View File

@ -268,24 +268,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM],
// Register for updates on events for this day // Register for updates on events for this day
var cache_id = app.classes.calendar._daywise_cache_id(new_date,this.options.owner); var cache_id = app.classes.calendar._daywise_cache_id(new_date,this.options.owner);
egw.dataRegisterUID(cache_id, function(event_ids) { egw.dataRegisterUID(cache_id, this._data_callback,this,this.getInstanceManager().execId,this.id);
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);
if(events) { if(events) {
this._update_events(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); this.div.attr('data-sortable-id', this.options.owner);
// Register for updates on events for this day // 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) { egw.dataRegisterUID(
var events = []; app.classes.calendar._daywise_cache_id(this.options.date,this.options.owner),
if(event_ids == null || typeof event_ids.length == 'undefined') event_ids = []; this._data_callback,this,this.getInstanceManager().execId,this.id
for(var i = 0; i < event_ids.length; i++) );
},
/**
* 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; events.push(event);
if(event && event.date && event.date === this.options.date)
{
events.push(event);
}
} }
this._update_events(events); }
},this,this.getInstanceManager().execId,this.id); this._update_events(events);
}, },
set_left: function(left) { set_left: function(left) {

View File

@ -117,6 +117,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this.div.remove(); this.div.remove();
this.div = null; this.div = null;
$j('body.egw_tooltip').remove();
// Unregister, or we'll continue to be notified... // Unregister, or we'll continue to be notified...
if(this.options.value) if(this.options.value)