From c3e12ee644fe2fa6497baf21245cdd430f820dfa Mon Sep 17 00:00:00 2001 From: Hardik Prajapati Date: Thu, 15 Apr 2021 11:53:48 +0000 Subject: [PATCH] [FIX] web: centered event name while dragging in month mode before this commit, the name of the event and hour is not correctly centered while dragging the pill in month mode. This commit fixes the issue by adding the CSS property. after this commit, the name of the event and hour should be correctly centered while dragging the pill in month mode. TaskID-2506060 closes odoo/odoo#73553 X-original-commit: 59156daa150bf285626600f0a999dfe9838e1344 Signed-off-by: Simon Genin (ges@odoo) --- .../src/legacy/js/views/calendar/calendar_renderer.js | 1 + addons/web/static/src/legacy/scss/web_calendar.scss | 5 +++++ addons/web/static/tests/legacy/views/calendar_tests.js | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/js/views/calendar/calendar_renderer.js b/addons/web/static/src/legacy/js/views/calendar/calendar_renderer.js index 29c04fadee3..2bc53e005b0 100644 --- a/addons/web/static/src/legacy/js/views/calendar/calendar_renderer.js +++ b/addons/web/static/src/legacy/js/views/calendar/calendar_renderer.js @@ -518,6 +518,7 @@ return AbstractRenderer.extend({ $(self.calendarElement).find(self._computeEventSelector(mouseLeaveInfo)).removeClass('o_cw_custom_hover'); }, eventDragStart: function (mouseDragInfo) { + mouseDragInfo.el.classList.add(mouseDragInfo.view.type); $(self.calendarElement).find(`[data-event-id=${mouseDragInfo.event.id}]`).addClass('o_cw_custom_hover'); self._unselectEvent(); }, diff --git a/addons/web/static/src/legacy/scss/web_calendar.scss b/addons/web/static/src/legacy/scss/web_calendar.scss index 1cb4c30c15a..28636d85b8b 100644 --- a/addons/web/static/src/legacy/scss/web_calendar.scss +++ b/addons/web/static/src/legacy/scss/web_calendar.scss @@ -37,6 +37,11 @@ $o-cw-filter-avatar-size: 20px; color: $body-color; } + &.fc-dragging.fc-day-grid-event.dayGridMonth .fc-content { + @include text-truncate(); + margin: 4px 4px 3px; + } + .fc-bg { background-color: mix(theme-color('primary'), white); // Used for placeholder events only (on creation) @include size(101%); // Compensate border diff --git a/addons/web/static/tests/legacy/views/calendar_tests.js b/addons/web/static/tests/legacy/views/calendar_tests.js index b1d959775cd..18e407b59ce 100644 --- a/addons/web/static/tests/legacy/views/calendar_tests.js +++ b/addons/web/static/tests/legacy/views/calendar_tests.js @@ -3060,7 +3060,7 @@ QUnit.module('Views', { }); QUnit.test("drag and drop on month mode", async function (assert) { - assert.expect(2); + assert.expect(3); const calendar = await createCalendarView({ arch: @@ -3085,6 +3085,14 @@ QUnit.module('Views', { await testUtils.dom.click($('.modal button.btn-primary')); await testUtils.nextTick(); + await testUtils.dom.dragAndDrop( + calendar.$('.fc-event:contains("event 1")'), + calendar.$('.fc-day-grid .fc-row:eq(3) .fc-day-top:eq(1)'), + { disableDrop: true }, + ); + assert.hasClass(calendar.$('.o_calendar_widget > [data-event-id="1"]'), 'dayGridMonth', + "should have dayGridMonth class"); + // Move event to another day (on 19 december) await testUtils.dom.dragAndDrop( calendar.$('.fc-event:contains("An event")'),