From dc43b00553ba8c18f18b9818ea3a64dc0d92d8fe Mon Sep 17 00:00:00 2001 From: Romeo Fragomeli Date: Fri, 20 Mar 2020 13:26:15 +0000 Subject: [PATCH] [FIX] web: avoid to set allDay when the duration of a event is 24H * n Before this commit, when the duration of an event is "24H * n". The event is set as allDay. This is strange to have a event that start a 8H and end at 8H of next days and the event is in the allDay slot. After this commit, we don't change the allDay flag anymore. Steps to reproduce: * Open calendar in week view * Create a event from 8 -> 16 * Then resize the end of this event from 16 -> 8 of the next day (BUG) Task ID: 2183249 --- .../src/js/views/calendar/calendar_model.js | 5 --- .../web/static/tests/views/calendar_tests.js | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/views/calendar/calendar_model.js b/addons/web/static/src/js/views/calendar/calendar_model.js index f927889a7c8..a404b618480 100644 --- a/addons/web/static/src/js/views/calendar/calendar_model.js +++ b/addons/web/static/src/js/views/calendar/calendar_model.js @@ -45,11 +45,6 @@ return AbstractModel.extend({ var start = event.start.clone(); var end = event.end && event.end.clone(); - // Detects allDay events (86400000 = 1 day in ms) - if (event.allDay || (end && end.diff(start) % 86400000 === 0)) { - event.allDay = true; - } - // Set end date if not existing if (!end || end.diff(start) < 0) { // undefined or invalid end date if (event.allDay) { diff --git a/addons/web/static/tests/views/calendar_tests.js b/addons/web/static/tests/views/calendar_tests.js index 295c2aa540e..a6cc85f833e 100644 --- a/addons/web/static/tests/views/calendar_tests.js +++ b/addons/web/static/tests/views/calendar_tests.js @@ -3464,6 +3464,51 @@ QUnit.module('Views', { calendar.destroy(); }); + QUnit.test("drag and drop 24h event on week mode", async function (assert) { + assert.expect(1); + + var calendar = await createCalendarView({ + View: CalendarView, + model: 'event', + data: this.data, + arch: ` + + `, + archs: archs, + viewOptions: { + initialDate: initialDate, + }, + }, {positionalClicks: true}); + + var top = calendar.$('.fc-axis:contains(8:00)').offset().top + 5; + var left = calendar.$('.fc-day:eq(2)').offset().left + 5; + + try { + testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown"); + } catch (e) { + calendar.destroy(); + throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.'); + } + + top = calendar.$('.fc-axis:contains(8:00)').offset().top - 5; + var leftNextDay = calendar.$('.fc-day:eq(3)').offset().left + 5; + testUtils.dom.triggerPositionalMouseEvent(leftNextDay, top, "mousemove"); + await testUtils.dom.triggerPositionalMouseEvent(leftNextDay, top, "mouseup"); + await testUtils.nextTick(); + assert.equal($('.o_field_boolean.o_field_widget[name=allday] input').is(':checked'), false, + "The event must not have the all_day active"); + await testUtils.dom.click($('.modal button.btn:contains(Discard)')); + + calendar.destroy(); + }); + }); });