Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] web: show event date/duration on popover #166279

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -495,7 +495,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 @@ -527,7 +527,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 @@ -1258,12 +1258,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 @@ -1281,10 +1281,14 @@ QUnit.module("Views", ({ beforeEach }) => {
"popover should have a close button"
);
assert.strictEqual(
target.querySelector(".o_cw_popover .list-group-item span.fw-bold").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 @@ -1303,8 +1307,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 @@ -2320,7 +2324,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 @@ -2350,11 +2354,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 @@ -2376,9 +2376,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 @@ -2395,6 +2401,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 @@ -3422,7 +3434,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