From 6e5bef9bd2b2f4644d1c10b01e8228fd29665bdd Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 2 Jun 2014 18:00:25 +0200 Subject: [PATCH] [FIX] calendar: avoid double popup, opw 606297 Some browsers (e.g. chrome) trigger onEmptyClick as well as onBeforeLightbox during drag&drop which calls two slow_create calls (and two popups). Workaround to kill the second one. --- addons/web_calendar/static/src/js/calendar.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index f7f08c3f6e3..f2cc0f74fcd 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -57,6 +57,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ this.range_stop = null; this.update_range_dates(Date.today()); this.selected_filters = []; + this.is_slow_open = false; }, view_loading: function(r) { return this.load_calendar(r); @@ -465,6 +466,13 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ }, slow_create: function(event_id, event_obj) { var self = this; + // Workaround, some browsers trigger onEmptyClick as well as onBeforeLightbox + // during drag&drop which calls two slow_create calls, kills the second one + if (this.is_slow_open) { + scheduler.deleteEvent(event_id); + return; + } + this.is_slow_open = true; if (this.current_mode() === 'month') { event_obj['start_date'].addHours(8); if (event_obj._length === 1) { @@ -487,6 +495,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ view_id: pop_infos.view_id, }); pop.on('closed', self, function() { + this.is_slow_open = false; if (!something_saved) { scheduler.deleteEvent(event_id); }