[FIX] web: calendar's event not correctly ordered in month view
Before this commit, events were sorted by ID in month view. Event A occurring after event B would be placed on top of B instead of below. Steps to reproduce: * Go in the calendar app * Insert a event at 12:00 * Insert a event at 8:00 * Insert a event at 14:00 * Go in view month the events are not sorted (BUG) In month view, events are forced to be "allday", so the sequence used can't be based on its time but only on its ID. To fix this, this commit doesn't force the "allday" flag anymore. Task ID: 2183249
This commit is contained in:
committed by
Pierre Paridans
parent
8dfbc7d421
commit
d57470387a
@@ -768,7 +768,6 @@ return AbstractModel.extend({
|
||||
|
||||
// allow to resize in month mode
|
||||
r.reset_allday = r.allDay;
|
||||
r.allDay = true;
|
||||
r.start = date_start.toDate();
|
||||
r.end = date_stop.startOf('day').toDate();
|
||||
r.showTime = true;
|
||||
|
||||
@@ -413,7 +413,7 @@ return AbstractRenderer.extend({
|
||||
if (self.$('.o_cw_popover').length) {
|
||||
self._unselectEvent();
|
||||
} else {
|
||||
var data = {start: selectionInfo.start, end: selectionInfo.end};
|
||||
var data = {start: selectionInfo.start, end: selectionInfo.end, allDay: selectionInfo.allDay};
|
||||
if (self.state.context.default_name) {
|
||||
data.title = self.state.context.default_name;
|
||||
}
|
||||
|
||||
@@ -3370,6 +3370,35 @@ QUnit.module('Views', {
|
||||
|
||||
calendar.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('attempt to create multiples events and the same day and check the ordering on month view', async function (assert) {
|
||||
assert.expect(3);
|
||||
/*
|
||||
This test aims to verify that the order of the event in month view is coherent with their start date.
|
||||
*/
|
||||
var initDate = new Date(2020, 2, 12, 8, 0, 0); //12 of March
|
||||
this.data.event.records = [
|
||||
{id: 1, name: "Second event", start: "2020-03-12 05:00:00", stop: "2020-03-12 07:00:00", allday: false},
|
||||
{id: 2, name: "First event", start: "2020-03-12 02:00:00", stop: "2020-03-12 03:00:00", allday: false},
|
||||
{id: 3, name: "Third event", start: "2020-03-12 08:00:00", stop: "2020-03-12 09:00:00", allday: false},
|
||||
];
|
||||
var calendar = await createCalendarView({
|
||||
View: CalendarView,
|
||||
model: 'event',
|
||||
data: this.data,
|
||||
arch: `<calendar date_start="start" date_stop="stop" all_day="allday" mode="month" />`,
|
||||
archs: archs,
|
||||
viewOptions: {
|
||||
initialDate: initDate,
|
||||
},
|
||||
});
|
||||
assert.ok(calendar.$('.o_calendar_view').find('.fc-view-container').length, "should display in the calendar"); // OK
|
||||
// Testing the order of the events: by start date
|
||||
assert.strictEqual(calendar.$('.o_event_title').length, 3, "3 events should be available"); // OK
|
||||
assert.strictEqual(calendar.$('.o_event_title').first().text(), 'First event', "First event should be on top");
|
||||
calendar.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user