[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
This commit is contained in:
Romeo Fragomeli
2020-03-31 15:37:13 +00:00
parent 0150141756
commit dc43b00553
2 changed files with 45 additions and 5 deletions
@@ -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) {
@@ -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: `
<calendar
event_open_popup="true"
quick_add="False"
date_start="start"
date_stop="stop"
all_day="allday"
mode="week"
/>
`,
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();
});
});
});