From e5810f793a9d4ef7b2a155337ab63b1587d10ad7 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 18 Dec 2015 17:18:05 +0000 Subject: [PATCH] Avoid calendar change event and directly update state. Avoids double state change. --- calendar/js/app.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index dc7e277aa9..2e0312f7ee 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -2849,24 +2849,29 @@ app.classes.calendar = AppJS.extend( .on('click', '.ui-datepicker-week-col', function() { var view = app.calendar.state.view; var days = app.calendar.state.days; - - // Fake a click event on the first day to get the updated date - $j(this).next().click(); + + // Avoid a full state update, we just want the calendar to update + // Directly update to avoid change event from the sidebox calendar + var date = new Date(this.nextSibling.dataset.year,this.nextSibling.dataset.month,this.nextSibling.firstChild.textContent,0,0,0); + date.setUTCHours(0); + date.setUTCMinutes(0); + date = app.calendar.date.toString(date); // Set to week view, if in one of the views where we change view if(app.calendar.sidebox_changes_views.indexOf(view) >= 0) { - app.calendar.update_state({view: 'week', date: date_widget.getValue(), days: days}); + app.calendar.update_state({view: 'week', date: date, days: days}); } else if (view == 'planner') { // Clicked a week, show just a week - app.calendar.update_state({planner_days: 7}); + app.calendar.update_state({date: date, planner_days: 7}); } else if (view == 'listview') { app.calendar.update_state({ - end_date: app.calendar.date.toString(app.classes.calendar.views.week.end_date({date:date_widget.getValue()})), + date: date, + end_date: app.calendar.date.toString(app.classes.calendar.views.week.end_date({date:date})), filter: 'week' }); }