Better support for storing a planner view as a favorite - detects months better

This commit is contained in:
Nathan Gray 2016-01-13 22:58:20 +00:00
parent 70686f0847
commit 36672c5626

View File

@ -1788,6 +1788,13 @@ app.classes.calendar = AppJS.extend(
state.keywords = listview.activeFilters.search;
}
}
else if (state.view == 'planner')
{
// Normally we don't use the planner days, but we'll set it so
// favorites can come back to the current view
var timeDiff = Math.abs(new Date(state.last).getTime() - new Date(state.first).getTime());
state.planner_days = Math.ceil(timeDiff / (1000 * 3600 * 24));
}
// Don't store date or first and last
delete state.date;
@ -3547,7 +3554,8 @@ jQuery.extend(app.classes.calendar,{
return state.first;
}
var d = app.calendar.View.start_date.call(this, state);
if(state.sortby && state.sortby === 'month')
if(state.sortby && state.sortby === 'month' ||
[28,30,31].indexOf(state.planner_days||0) >= 0)
{
d.setUTCDate(1);
}
@ -3599,8 +3607,16 @@ jQuery.extend(app.classes.calendar,{
d.setUTCFullYear(d.getUTCFullYear() + 1);
}
else if (state.planner_days)
{
if([28,30,31].indexOf(state.planner_days||0) >= 0)
{
// Month view
d = new Date(d.getFullYear(),d.getUTCMonth() + 1, 0);
}
else
{
d.setUTCDate(d.getUTCDate() + parseInt(state.planner_days)-1);
}
delete state.planner_days;
}
else if (state.days)