Fix 4 day view not showing any days, changing to planner from day or 4 day view did not properly keep the date span

This commit is contained in:
Nathan Gray 2015-12-23 20:50:33 +00:00
parent 8ebd4efcf2
commit 17b1a3387f

View File

@ -1823,6 +1823,7 @@ app.classes.calendar = AppJS.extend(
switch(state.state.view)
{
case 'day':
case 'day4':
grid_count = state.state.owner.length > parseInt(this.egw.preference('day_consolidate','calendar')) ? 1 : state.state.owner.length;
break;
case 'week':
@ -3316,6 +3317,11 @@ jQuery.extend(app.classes.calendar,{
group_by: function(state) {
return state.sortby ? state.sortby : 0;
},
// Note: Planner has no inherent timespan as day or week does, so
// it's a little more messy to determine what timespan to show. For
// best results, we either leave the dates as set (planner_days = 0)
// to inherit from the previous view, or set either planner_days or
// start & end date.
start_date: function(state) {
// If there is no planner_days and a start date, just keep it
if(!state.planner_days && state.first && (
@ -3329,6 +3335,11 @@ jQuery.extend(app.classes.calendar,{
{
d.setUTCDate(1);
}
else if (state.days)
{
// Don't jump to start of week, coming from day or day4
return d;
}
else if (!state.planner_days)
{
d = app.calendar.date.start_of_week(d);
@ -3376,6 +3387,12 @@ jQuery.extend(app.classes.calendar,{
d.setUTCDate(d.getUTCDate() + parseInt(state.planner_days)-1);
delete state.planner_days;
}
else if (state.days)
{
// This one comes from a grid view, but we'll use it
d.setUTCDate(d.getUTCDate() + parseInt(state.days)-1);
delete state.days;
}
// Avoid killing the view by not showing more than 100 days
else if (state.last && state.last > state.first && (new Date(state.last) - new Date(state.first)) < (100 * 24 * 3600 * 1000) )
{