From 17b1a3387f8fdbc33bf5f2c2d8c0e4d5e25b9918 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 23 Dec 2015 20:50:33 +0000 Subject: [PATCH] Fix 4 day view not showing any days, changing to planner from day or 4 day view did not properly keep the date span --- calendar/js/app.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/calendar/js/app.js b/calendar/js/app.js index 05d6ea5374..3c156db236 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -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) ) {