Fix events missing if home loaded before calendar

This commit is contained in:
Nathan Gray 2016-01-27 17:35:25 +00:00
parent 8d8b916499
commit 794d6aee5c
5 changed files with 56 additions and 4 deletions

View File

@ -74,7 +74,11 @@ class calendar_favorite_portlet extends home_favorite_portlet
if($this->favorite['state']['start']) $ui->search_params['start'] = $this->favorite['state']['start'];
if($this->favorite['state']['cat_id']) $ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
// Owner can be 0 for current user
if(array_key_exists('owner',$this->favorite['state'])) $ui->search_params['users'] = explode(',',$this->favorite['state']['owner']);
if(array_key_exists('owner',$this->favorite['state'])) $ui->search_params['users'] = $this->favorite['state']['owner'];
if($ui->search_params['users'] && !is_array($ui->search_params['users']))
{
$ui->search_params['users'] = explode(',',$ui->search_params['users']);
}
if($this->favorite['state']['filter']) $ui->search_params['filter'] = $this->favorite['state']['filter'];
if($this->favorite['state']['sortby']) $ui->search_params['sortby'] = $this->favorite['state']['sortby'];
}
@ -134,7 +138,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
$this->favorite['state']['view'] == 'day' ? 1 : 4
);
$this->actions =& $etemplate->getElementAttribute('view', 'actions');
$ui->week($days, $etemplate);
$ui->week($days, $etemplate);
return;
}

View File

@ -807,7 +807,9 @@ class calendar_uiviews extends calendar_ui
{
// Always do 7 days for a week so scrolling works properly
$this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1);
if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate']) // for more then X users, show all in one row
if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row
$days == 1 // Showing just 1 day
)
{
$content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) +
array('owner' => $users);

View File

@ -155,6 +155,7 @@ app.classes.calendar = AppJS.extend(
this.sidebox_hooked_templates.push(this.sidebox_et2);
$j(_et2.DOMContainer).hide();
this._setup_sidebox_filters();
this.state = content.data;
break;
case 'calendar.edit':
@ -1832,6 +1833,11 @@ app.classes.calendar = AppJS.extend(
*/
setState: function setState(state)
{
if(framework && framework.applications.calendar && framework.applications.calendar.hasSideboxMenuContent)
{
framework.setActiveApp(framework.applications.calendar);
}
// State should be an object, not a string, but we'll parse
if(typeof state == "string")
{
@ -3423,7 +3429,7 @@ jQuery.extend(app.classes.calendar,{
/**
* Create a cache ID for the daywise cache
*
* @param {String|Date} date
* @param {String|Date} date If a string, date should be in Ymd format
* @param {String|integer|String[]} owner
* @returns {String} Cache ID
*/

View File

@ -1309,6 +1309,27 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.set_start_date(day_list[0]);
this.set_end_date(day_list[day_list.length-1]);
}
// Sub widgets actually get their own data from egw.data, so we'll
// stick it there
var consolidated = et2_calendar_view.is_consolidated(this.options.owner, this.day_list.length == 1 ? 'day' : 'week');
for(var day in events)
{
var day_list = [];
for(var i = 0; i < events[day].length; i++)
{
day_list.push(events[day][i].row_id);
egw.dataStoreUID('calendar::'+events[day][i].row_id, events[day][i]);
}
// Might be split by user, so we have to check that too
for(var i = 0; i < this.options.owner.length; i++)
{
var owner = consolidated ? this.options.owner : this.options.owner[i];
var day_id = app.classes.calendar._daywise_cache_id(day,owner);
egw.dataStoreUID(day_id, day_list);
if(consolidated) break;
}
}
}
// Reset and calculate instead of just use the keys so we can get the weekend preference

View File

@ -383,6 +383,25 @@ var et2_calendar_view = et2_valueWidget.extend(
// Static class stuff
jQuery.extend(et2_calendar_view,
{
/**
* Check if the view should be consolidated into one, or listed seperately
* based on the user's preferences
*
* @param {string[]} owners List of owners
* @param {string} view Name of current view (day, week)
* @returns {boolean} True of only one is needed, false if each owner needs
* to be listed seperately.
*/
is_consolidated: function is_consolidated(owners, view)
{
// Seperate owners, or consolidated?
return !(
owners.length > 1 &&
(view === 'day' && owners.length < parseInt(egw.preference('day_consolidate','calendar')) ||
view === 'week' && owners.length < parseInt(egw.preference('week_consolidate','calendar')))
);
},
holiday_cache: {},
/**
* Fetch and cache a list of the year's holidays