Skip to content

Commit

Permalink
[FIX] web: show event date/duration on popover
Browse files Browse the repository at this point in the history
Issue:
    - when you open a calendar event popover ,
    you can't see its time and duration

Steps To Reproduce:
    - Go to calendar and create an event.
    - Click on the event and notice you can't
    see it's time and duration in popover.

Solution:
    - We modified the `computeDateTimeAndDuration`
     function to ignore the `isTimeHidden` attribute of the record.

opw-3829004
  • Loading branch information
kawkb committed May 12, 2024
1 parent 1be5dfc commit 366ff51
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
3 changes: 1 addition & 2 deletions addons/web/static/src/views/calendar/calendar_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export class CalendarModel extends Model {
* @param {Record<string, any>} rawRecord
*/
normalizeRecord(rawRecord) {
const { fields, fieldMapping, isTimeHidden, scale } = this.meta;
const { fields, fieldMapping, isTimeHidden } = this.meta;

const startType = fields[fieldMapping.date_start].type;
const isAllDay =
Expand Down Expand Up @@ -515,7 +515,6 @@ export class CalendarModel extends Model {

const showTime =
!(fieldMapping.all_day && rawRecord[fieldMapping.all_day]) &&
scale === "month" &&
startType !== "date" &&
start.day === end.day;

Expand Down
42 changes: 27 additions & 15 deletions addons/web/static/tests/views/calendar/calendar_view_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1291,12 +1291,12 @@ QUnit.module("Views", ({ beforeEach }) => {
`,
});

await clickEvent(target, 4);
await clickEvent(target, 2);
assert.containsOnce(target, ".o_cw_popover", "should open a popover clicking on event");
assert.strictEqual(
target.querySelector(".o_cw_popover .popover-header").textContent,
"event 4",
"popover should have a title 'event 4'"
"event 2",
"popover should have a title 'event 2'"
);
assert.containsOnce(
target,
Expand All @@ -1314,10 +1314,14 @@ QUnit.module("Views", ({ beforeEach }) => {
"popover should have a close button"
);
assert.strictEqual(
target.querySelector(".o_cw_popover .list-group-item b.text-capitalize").textContent,
"December 14, 2016",
target.querySelectorAll(".o_cw_popover .list-group-item")[0].textContent.trim(),
"December 12, 2016",
"should display date 'December 14, 2016'"
);
assert.strictEqual(
target.querySelectorAll(".o_cw_popover .list-group-item")[1].textContent.trim(),
"11:55 - 15:55 (4 hours)"
);
assert.containsN(
target,
".o_cw_popover .o_cw_popover_fields_secondary .list-group-item",
Expand All @@ -1336,8 +1340,8 @@ QUnit.module("Views", ({ beforeEach }) => {
);
assert.strictEqual(
groups[0].querySelector(".o_field_char").textContent,
"event 4",
"value should be a 'event 4'"
"event 2",
"value should be a 'event 2'"
);
assert.containsOnce(groups[1], ".o_form_uri", "should apply m20 widget");
assert.strictEqual(
Expand Down Expand Up @@ -2381,7 +2385,7 @@ QUnit.module("Views", ({ beforeEach }) => {
await click(target, ".o-calendar-quick-create--edit-btn");
});

QUnit.test(`show start time of single day event for month mode`, async (assert) => {
QUnit.test(`show start time of single day event`, async (assert) => {
patchTimeZone(-240);

await makeView({
Expand Down Expand Up @@ -2411,11 +2415,7 @@ QUnit.module("Views", ({ beforeEach }) => {

// switch to week mode
await changeScale(target, "week");
assert.containsNone(
findEvent(target, 2),
".fc-content .fc-time",
"should not show time in week mode as week mode already have time on y-axis"
);
assert.containsOnce(findEvent(target, 2), ".fc-content .fc-time");
});

QUnit.test(`start time should not shown for date type field`, async (assert) => {
Expand All @@ -2437,9 +2437,15 @@ QUnit.module("Views", ({ beforeEach }) => {
".fc-content .fc-time",
"should not show time for date type field"
);

await changeScale(target, "week");
assert.containsNone(findEvent(target, 2), ".fc-content .fc-time");

await changeScale(target, "day");
assert.containsNone(findEvent(target, 2), ".fc-content .fc-time");
});

QUnit.test(`start time should not shown in month mode if hide_time is true`, async (assert) => {
QUnit.test(`start time should not shown if hide_time is true`, async (assert) => {
patchTimeZone(-240);

await makeView({
Expand All @@ -2456,6 +2462,12 @@ QUnit.module("Views", ({ beforeEach }) => {
".fc-content .fc-time",
"should not show time for hide_time attribute"
);

await changeScale(target, "week");
assert.containsNone(findEvent(target, 2), ".fc-content .fc-time");

await changeScale(target, "day");
assert.containsNone(findEvent(target, 2), ".fc-content .fc-time");
});

QUnit.test(`readonly date_start field`, async (assert) => {
Expand Down Expand Up @@ -3483,7 +3495,7 @@ QUnit.module("Views", ({ beforeEach }) => {
await click(target, ".o-calendar-quick-create--create-btn");
assert.strictEqual(
findEvent(target, 8).textContent,
"new event in quick create",
"00:00 new event in quick create",
"should display the new record after quick create dialog"
);
});
Expand Down

0 comments on commit 366ff51

Please sign in to comment.