Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: allow click on calendar to create new event (#40251)

Kris28baea966b14
diff --git a/frontend/discourse/app/static/full-calendar-bundle.js b/frontend/discourse/app/static/full-calendar-bundle.js
index 0cb9ca5e599..d26cfd6391f 100644
--- a/frontend/discourse/app/static/full-calendar-bundle.js
+++ b/frontend/discourse/app/static/full-calendar-bundle.js
@@ -2,5 +2,6 @@ export { Calendar } from "@fullcalendar/core";
export { default as DayGrid } from "@fullcalendar/daygrid";
export { default as TimeGrid } from "@fullcalendar/timegrid";
export { default as List } from "@fullcalendar/list";
+export { default as Interaction } from "@fullcalendar/interaction";
export { default as MomentPlugin } from "@fullcalendar/moment";
export { default as MomentTimezonePlugin } from "@fullcalendar/moment-timezone";
diff --git a/frontend/discourse/package.json b/frontend/discourse/package.json
index e6c8275e4f9..1750a2d9236 100644
--- a/frontend/discourse/package.json
+++ b/frontend/discourse/package.json
@@ -28,6 +28,7 @@
"@faker-js/faker": "^10.4.0",
"@fullcalendar/core": "^6.1.20",
"@fullcalendar/daygrid": "^6.1.20",
+ "@fullcalendar/interaction": "^6.1.20",
"@fullcalendar/list": "^6.1.20",
"@fullcalendar/moment": "^6.1.20",
"@fullcalendar/moment-timezone": "^6.1.20",
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs
index 1fe14a984a7..20caf1cf9bf 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs
@@ -5,14 +5,39 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
import { bind } from "discourse/lib/decorators";
import Category from "discourse/models/category";
import formatEventForCalendar from "../lib/format-event-for-calendar";
+import openEventComposer from "../lib/open-event-composer";
import FullCalendar from "./full-calendar";
export default class CategoryCalendar extends Component {
+ @service composer;
@service currentUser;
@service router;
@service siteSettings;
@service discoursePostEventService;
+ get canCreateEvent() {
+ if (!this.currentUser) {
+ return false;
+ }
+
+ return (
+ this.currentUser.can_create_discourse_post_event &&
+ this.currentUser.can_create_topic &&
+ this.category?.canCreateTopic
+ );
+ }
+
+ @action
+ async onDateClick(info) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: this.currentUser,
+ siteSettings: this.siteSettings,
+ info,
+ category: this.category,
+ });
+ }
+
@bind
async loadEvents(info) {
try {
@@ -119,6 +144,7 @@ export default class CategoryCalendar extends Component {
{{#if this.shouldRender}}
<FullCalendar
@onLoadEvents={{this.loadEvents}}
+ @onDateClick={{if this.canCreateEvent this.onDateClick}}
@height="650px"
@initialView={{this.categorySetting.defaultView}}
@weekends={{this.renderWeekends}}
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
index 135f676fb65..22557fb646b 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
@@ -9,6 +9,7 @@ import { modifier as modifierFn } from "ember-modifier";
import { iconHTML } from "discourse/lib/icon-library";
import loadFullCalendar from "discourse/lib/load-full-calendar";
import DiscourseURL from "discourse/lib/url";
+import { i18n } from "discourse-i18n";
import DiscoursePostEvent from "discourse/plugins/discourse-calendar/discourse/components/discourse-post-event";
import {
getCalendarButtonsText,
@@ -84,6 +85,7 @@ export default class FullCalendar extends Component {
weekends: this.args.weekends ?? true,
initialDate: this.args.initialDate,
height: this.args.height ?? "100%",
+ selectable: true,
events: async (info, successCallback, failureCallback) => {
if (this.args.onLoadEvents) {
try {
@@ -100,6 +102,7 @@ export default class FullCalendar extends Component {
calendarModule.DayGrid,
calendarModule.TimeGrid,
calendarModule.List,
+ calendarModule.Interaction,
calendarModule.MomentPlugin,
calendarModule.MomentTimezonePlugin,
],
@@ -140,6 +143,9 @@ export default class FullCalendar extends Component {
});
}
},
+ dateClick: async (info) => {
+ await this.args.onDateClick?.(info);
+ },
eventClick: async ({ el, event, jsEvent }) => {
const { postNumber, postUrl, postEvent } = event.extendedProps;
@@ -171,6 +177,11 @@ export default class FullCalendar extends Component {
this.topic.send("jumpToPost", postNumber);
}
},
+ allDayContent: () =>
+ i18n("discourse_post_event.upcoming_events_list.all_day"),
+ select: (info) => {
+ this.args.onDateClick?.(info);
+ },
});
this.calendar.render();
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjs
index 8967dbd1b40..71b1c8fb229 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjs
@@ -6,15 +6,39 @@ import moment from "moment";
import { i18n } from "discourse-i18n";
import { normalizeViewForRoute } from "../lib/calendar-view-helper";
import formatEventForCalendar from "../lib/format-event-for-calendar";
+import openEventComposer from "../lib/open-event-composer";
import FullCalendar from "./full-calendar";
export default class UpcomingEventsCalendar extends Component {
+ @service composer;
@service currentUser;
@service router;
@service capabilities;
@service siteSettings;
@service discoursePostEventService;
+ get canCreateEvent() {
+ if (!this.currentUser) {
+ return false;
+ }
+
+ return (
+ this.currentUser.can_create_discourse_post_event &&
+ this.currentUser.can_create_topic
+ );
+ }
+
+ @action
+ async onDateClick(info) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: this.currentUser,
+ siteSettings: this.siteSettings,
+ info,
+ category: null,
+ });
+ }
+
get customButtons() {
return {
mineEvents: {
@@ -141,6 +165,7 @@ export default class UpcomingEventsCalendar extends Component {
<FullCalendar
@initialDate={{@initialDate}}
@onDatesChange={{this.onDatesChange}}
+ @onDateClick={{if this.canCreateEvent this.onDateClick}}
@onLoadEvents={{this.loadEvents}}
@initialView={{@initialView}}
@customButtons={{this.customButtons}}
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/lib/open-event-composer.js b/plugins/discourse-calendar/assets/javascripts/discourse/lib/open-event-composer.js
new file mode 100644
index 00000000000..b396da700de
--- /dev/null
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/lib/open-event-composer.js
@@ -0,0 +1,65 @@
+import moment from "moment";
+
+const DEFAULT_ALL_DAY_START_HOUR = 9;
+
+function allDayStartTime(siteSettings) {
+ const [hour, minute] = (siteSettings?.all_day_event_start_time || "").split(
+ ":"
+ );
+ const parsedHour = parseInt(hour, 10);
+
+ if (isNaN(parsedHour)) {
+ return { hour: DEFAULT_ALL_DAY_START_HOUR, minute: 0 };
+ }
+
+ return { hour: parsedHour, minute: parseInt(minute, 10) || 0 };
+}
+
+export default async function openEventComposer({
+ composer,
+ currentUser,
+ siteSettings,
+ info,
+ category,
+}) {
+ const timezone =
+ currentUser?.user_option?.timezone || moment.tz.guess() || "UTC";
+
+ let start;
+ if (info.startStr) {
+ start = moment.parseZone(info.startStr);
+ } else {
+ start = moment.parseZone(info.dateStr);
+ }
+
+ if (info.allDay) {
+ const { hour, minute } = allDayStartTime(siteSettings);
+ start.hour(hour).minute(minute);
+ }
+
+ let end;
+ if (info.endStr) {
+ end = moment.parseZone(info.endStr);
+ } else {
+ end = start.clone().add(1, "hour");
+ }
+
+ const params = {
+ start: start.format("YYYY-MM-DD HH:mm"),
+ status: "public",
+ timezone,
+ end: end.format("YYYY-MM-DD HH:mm"),
+ };
+
+ let markdown = Object.entries(params)
+ .map(([key, value]) => `${key}="${value}"`)
+ .join(" ");
+
+ if (info.allDay) {
+ markdown += " allDay=true";
+ }
+
+ const body = `[event ${markdown}]\n[/event]\n`;
+
+ await composer.openNewTopic({ body, category });
+}
diff --git a/plugins/discourse-calendar/assets/stylesheets/common/full-calendar-ext.scss b/plugins/discourse-calendar/assets/stylesheets/common/full-calendar-ext.scss
index 764163d8b0e..c2f54bdaace 100644
--- a/plugins/discourse-calendar/assets/stylesheets/common/full-calendar-ext.scss
+++ b/plugins/discourse-calendar/assets/stylesheets/common/full-calendar-ext.scss
@@ -42,7 +42,22 @@
}
}
+.fc-timegrid-slot-lane {
+ cursor: pointer;
+
+ &:hover {
+ background-color: var(--tertiary-50);
+ opacity: 0.6;
+ }
+}
+
.fc-daygrid-day-frame {
+ cursor: pointer;
+
+ &:hover {
+ background-color: var(--tertiary-50);
+ }
+
.fc-daygrid-day-top {
justify-content: center;
diff --git a/plugins/discourse-calendar/config/locales/client.en.yml b/plugins/discourse-calendar/config/locales/client.en.yml
index 513961a5700..836d03a696c 100644
--- a/plugins/discourse-calendar/config/locales/client.en.yml
+++ b/plugins/discourse-calendar/config/locales/client.en.yml
@@ -392,7 +392,7 @@ en:
upcoming_events_list:
title: "Upcoming events"
empty: "No upcoming events"
- all_day: "All-day"
+ all_day: "All day"
error: "Failed to retrieve events"
try_again: "Try again"
view_all: "View all"
@@ -499,7 +499,7 @@ en:
label: "End date"
all_day:
label: "All day event"
- description: "An all-day event will not have specific times, just a date. The event will run from the start of the day to the end of the day."
+ description: "An all day event will not have specific times, just a date. The event will run from the start of the day to the end of the day."
reminders:
label: "Reminders"
types:
diff --git a/plugins/discourse-calendar/test/javascripts/acceptance/calendar-click-to-create-test.js b/plugins/discourse-calendar/test/javascripts/acceptance/calendar-click-to-create-test.js
new file mode 100644
index 00000000000..7e01d844a6c
--- /dev/null
+++ b/plugins/discourse-calendar/test/javascripts/acceptance/calendar-click-to-create-test.js
@@ -0,0 +1,209 @@
+import { click, settled, visit, waitFor } from "@ember/test-helpers";
+import moment from "moment";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+
+function noEventsPretender(server, helper) {
+ server.get("/discourse-post-event/events", () => {
+ return helper.response({ events: [] });
+ });
+}
+
+const SETTINGS = {
+ calendar_enabled: true,
+ discourse_post_event_enabled: true,
+ events_calendar_categories: "1",
+ calendar_categories: "",
+};
+
+function todayCellDate() {
+ return document.querySelector(".fc-day-today").getAttribute("data-date");
+}
+
+function cellFor(date) {
+ return document.querySelector(`.fc-daygrid-day[data-date="${date}"]`);
+}
+
+function fireMouse(type, target, x, y) {
+ target.dispatchEvent(
+ new MouseEvent(type, {
+ bubbles: true,
+ cancelable: true,
+ view: window,
+ clientX: x,
+ clientY: y,
+ })
+ );
+}
+
+// Simulates a FullCalendar click-and-drag day selection by dispatching the
+// pointer sequence (mousedown -> mousemove -> mouseup) the interaction plugin
+// listens for, using the centers of the start and end day cells.
+async function dragSelect(startEl, endEl) {
+ const start = startEl.getBoundingClientRect();
+ const end = endEl.getBoundingClientRect();
+ const startX = start.left + start.width / 2;
+ const startY = start.top + start.height / 2;
+ const endX = end.left + end.width / 2;
+ const endY = end.top + end.height / 2;
+
+ fireMouse("mousedown", startEl, startX, startY);
+ fireMouse("mousemove", document, startX + 5, startY + 5);
+ fireMouse("mousemove", endEl, endX, endY);
+ fireMouse("mouseup", document, endX, endY);
+
+ await settled();
+}
+
+// Simulates a FullCalendar click-and-drag selection down the time axis of a
+// timegrid column, from the top of the start slot to the top of the end slot.
+async function dragSelectTime(colEl, startSlotEl, endSlotEl) {
+ const col = colEl.getBoundingClientRect();
+ const startSlot = startSlotEl.getBoundingClientRect();
+ const endSlot = endSlotEl.getBoundingClientRect();
+ const x = col.left + col.width / 2;
+ const startY = startSlot.top + 1;
+ const endY = endSlot.top + 1;
+
+ fireMouse("mousedown", startSlotEl, x, startY);
+ fireMouse("mousemove", document, x, startY + 5);
+ fireMouse("mousemove", endSlotEl, x, endY);
+ fireMouse("mouseup", document, x, endY);
+
+ await settled();
+}
+
+acceptance(
+ "Calendar click to create - upcoming events (with permission)",
+ function (needs) {
+ needs.user({ can_create_discourse_post_event: true });
+ needs.settings(SETTINGS);
+ needs.pretender(noEventsPretender);
+
+ test("clicking an empty day cell opens the composer with an all-day event at 9am", async function (assert) {
+ await visit("/upcoming-events");
+ await waitFor(".fc-day-today");
+
+ const date = todayCellDate();
+ const nextDate = moment(date).add(1, "day").format("YYYY-MM-DD");
+
+ await click(".fc-day-today");
+ await waitFor(".d-editor-input");
+
+ assert
+ .dom(".d-editor-input")
+ .hasValue(
+ new RegExp(
+ `^\\[event start="${date} 09:00" status="public" timezone="[^"]+" end="${nextDate} 00:00" allDay=true\\]\\n\\[/event\\]\\n$`
+ ),
+ "composer opens with an all-day event defaulting to 9am for the clicked day"
+ );
+ });
+
+ test("dragging across multiple day cells opens the composer with a multi-day all-day event", async function (assert) {
+ await visit("/upcoming-events");
+ await waitFor(".fc-day-today");
+
+ const startDate = todayCellDate();
+ const lastDate = moment(startDate).add(2, "days").format("YYYY-MM-DD");
+ // the selection end is exclusive, so a 3-day selection ends on the 4th day
+ const endDate = moment(startDate).add(3, "days").format("YYYY-MM-DD");
+
+ await dragSelect(cellFor(startDate), cellFor(lastDate));
+ await waitFor(".d-editor-input");
+
+ assert
+ .dom(".d-editor-input")
+ .hasValue(
+ new RegExp(
+ `^\\[event start="${startDate} 09:00" status="public" timezone="[^"]+" end="${endDate} 00:00" allDay=true\\]\\n\\[/event\\]\\n$`
+ ),
+ "composer opens with an all-day event spanning the dragged range"
+ );
+ });
+
+ test("dragging across hours in the day view opens the composer with a timed event", async function (assert) {
+ await visit("/upcoming-events");
+ await waitFor(".fc-day-today");
+
+ await click(".fc-timeGridDay-button");
+ await waitFor(".fc-timegrid-slot-lane");
+
+ const col = document.querySelector(".fc-timegrid-col.fc-day-today");
+ const date = col.getAttribute("data-date");
+
+ // FullCalendar's selection end is exclusive of the released slot's start,
+ // so releasing on the 11:30 slot produces a selection ending at 12:00.
+ await dragSelectTime(
+ col,
+ document.querySelector(".fc-timegrid-slot-lane[data-time='09:00:00']"),
+ document.querySelector(".fc-timegrid-slot-lane[data-time='11:30:00']")
+ );
+ await waitFor(".d-editor-input");
+
+ assert
+ .dom(".d-editor-input")
+ .hasValue(
+ new RegExp(
+ `^\\[event start="${date} 09:00" status="public" timezone="[^"]+" end="${date} 12:00"\\]\\n\\[/event\\]\\n$`
+ ),
+ "composer opens with a timed 9am-12pm event and no allDay flag"
+ );
+ });
+ }
+);
+
+acceptance(
+ "Calendar click to create - category (with permission)",
+ function (needs) {
+ needs.user({ can_create_discourse_post_event: true });
+ needs.settings(SETTINGS);
+ needs.pretender(noEventsPretender);
+
+ test("clicking an empty day cell opens the composer prefilled with the category", async function (assert) {
+ await visit("/c/bug/1");
+ await waitFor(".fc-day-today");
+
+ const date = todayCellDate();
+ const nextDate = moment(date).add(1, "day").format("YYYY-MM-DD");
+
+ await click(".fc-day-today");
+ await waitFor(".d-editor-input");
+
+ assert
+ .dom(".d-editor-input")
+ .hasValue(
+ new RegExp(
+ `^\\[event start="${date} 09:00" status="public" timezone="[^"]+" end="${nextDate} 00:00" allDay=true\\]\\n\\[/event\\]\\n$`
+ ),
+ "composer opens with an all-day event for the clicked day"
+ );
+
+ assert.strictEqual(
+ selectKit(".category-chooser").header().value(),
+ "1",
+ "the calendar's category is preselected in the composer"
+ );
+ });
+ }
+);
+
+acceptance("Calendar click to create - no permission", function (needs) {
+ needs.user({ can_create_discourse_post_event: false });
+ needs.settings(SETTINGS);
+ needs.pretender(noEventsPretender);
+
+ test("clicking an empty day cell does nothing without event-create permission", async function (assert) {
+ await visit("/upcoming-events");
+ await waitFor(".fc-day-today");
+
+ await click(".fc-day-today");
+
+ assert
+ .dom(".d-editor-input")
+ .doesNotExist(
+ "composer does not open when the user cannot create events"
+ );
+ });
+});
diff --git a/plugins/discourse-calendar/test/javascripts/lib/open-event-composer-test.js b/plugins/discourse-calendar/test/javascripts/lib/open-event-composer-test.js
new file mode 100644
index 00000000000..cc159f6310b
--- /dev/null
+++ b/plugins/discourse-calendar/test/javascripts/lib/open-event-composer-test.js
@@ -0,0 +1,220 @@
+import { module, test } from "qunit";
+import openEventComposer from "discourse/plugins/discourse-calendar/discourse/lib/open-event-composer";
+
+function parseBbcode(body) {
+ const match = body.match(/\[event (.*?)\]\n\[\/event\]\n$/);
+ if (!match) {
+ return null;
+ }
+
+ const params = {};
+ // captures both quoted (key="value") and bare (key=value) attributes, the
+ // latter being how the allDay flag is emitted.
+ for (const pair of match[1].matchAll(/(\w+)="([^"]*)"|(\w+)=(\S+)/g)) {
+ const key = pair[1] ?? pair[3];
+ const value = pair[2] ?? pair[4];
+ params[key] = value;
+ }
+ return params;
+}
+
+module("Unit | Lib | open-event-composer", function (hooks) {
+ hooks.beforeEach(function () {
+ this.calls = [];
+ this.composer = {
+ openNewTopic: async (opts) => {
+ this.calls.push(opts);
+ },
+ };
+ });
+
+ test("all-day click defaults to 9:00 when the setting is unset", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "America/New_York" } },
+ siteSettings: { all_day_event_start_time: "" },
+ info: { dateStr: "2026-05-22", allDay: true },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.strictEqual(params.start, "2026-05-22 09:00");
+ assert.strictEqual(
+ params.end,
+ "2026-05-22 10:00",
+ "defaults to a 1h event"
+ );
+ assert.strictEqual(params.timezone, "America/New_York");
+ assert.strictEqual(params.status, "public");
+ assert.strictEqual(params.allDay, "true", "emits the allDay flag");
+ });
+
+ test("all-day click honors the all_day_event_start_time setting", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "America/New_York" } },
+ siteSettings: { all_day_event_start_time: "08:30" },
+ info: { dateStr: "2026-05-22", allDay: true },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.strictEqual(params.start, "2026-05-22 08:30");
+ });
+
+ test("timegrid click preserves the clicked time", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "Europe/Berlin" } },
+ info: { dateStr: "2026-05-22T14:30:00", allDay: false },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.strictEqual(params.start, "2026-05-22 14:30");
+ assert.strictEqual(
+ params.end,
+ "2026-05-22 15:30",
+ "defaults to a 1h event"
+ );
+ assert.strictEqual(params.timezone, "Europe/Berlin");
+ assert.strictEqual(
+ params.allDay,
+ undefined,
+ "does not emit the allDay flag for a timed click"
+ );
+ });
+
+ test("drag selection in timegrid preserves the selected start and end times", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "Europe/Berlin" } },
+ info: {
+ startStr: "2026-05-22T14:00:00",
+ endStr: "2026-05-22T17:30:00",
+ allDay: false,
+ },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.strictEqual(params.start, "2026-05-22 14:00");
+ assert.strictEqual(
+ params.end,
+ "2026-05-22 17:30",
+ "uses the end of the selection rather than a 1h default"
+ );
+ assert.strictEqual(
+ params.allDay,
+ undefined,
+ "does not emit the allDay flag for a timed selection"
+ );
+ });
+
+ test("startStr takes precedence over dateStr when both are present", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "Europe/Berlin" } },
+ info: {
+ dateStr: "2026-05-22T09:00:00",
+ startStr: "2026-05-22T14:00:00",
+ endStr: "2026-05-22T15:00:00",
+ allDay: false,
+ },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.strictEqual(
+ params.start,
+ "2026-05-22 14:00",
+ "prefers the selection start over the clicked date"
+ );
+ });
+
+ test("all-day drag selection emits the allDay flag and spans the selection", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "America/New_York" } },
+ siteSettings: { all_day_event_start_time: "" },
+ info: {
+ startStr: "2026-05-22",
+ endStr: "2026-05-25",
+ allDay: true,
+ },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.strictEqual(
+ params.start,
+ "2026-05-22 09:00",
+ "applies the all-day start time to the selection start"
+ );
+ assert.strictEqual(
+ params.end,
+ "2026-05-25 00:00",
+ "uses the exclusive end of the all-day selection"
+ );
+ assert.strictEqual(params.allDay, "true", "emits the allDay flag");
+ });
+
+ test("all-day drag selection honors the all_day_event_start_time setting", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "America/New_York" } },
+ siteSettings: { all_day_event_start_time: "08:30" },
+ info: {
+ startStr: "2026-05-22",
+ endStr: "2026-05-23",
+ allDay: true,
+ },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.strictEqual(params.start, "2026-05-22 08:30");
+ assert.strictEqual(params.allDay, "true", "emits the allDay flag");
+ });
+
+ test("forwards category to composer.openNewTopic", async function (assert) {
+ const category = { id: 42, canCreateTopic: true };
+
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "UTC" } },
+ info: { dateStr: "2026-05-22", allDay: true },
+ category,
+ });
+
+ assert.strictEqual(this.calls[0].category, category);
+ });
+
+ test("passes null category through (upcoming-events case)", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: { timezone: "UTC" } },
+ info: { dateStr: "2026-05-22", allDay: true },
+ category: null,
+ });
+
+ assert.strictEqual(this.calls[0].category, null);
+ });
+
+ test("falls back when user has no timezone preference", async function (assert) {
+ await openEventComposer({
+ composer: this.composer,
+ currentUser: { user_option: {} },
+ info: { dateStr: "2026-05-22", allDay: true },
+ category: null,
+ });
+
+ const params = parseBbcode(this.calls[0].body);
+ assert.notStrictEqual(
+ params.timezone,
+ undefined,
+ "emits some timezone (guessed or UTC)"
+ );
+ assert.notStrictEqual(params.timezone, "", "timezone is not empty");
+ });
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 43a1a6e38c0..d8d84ed5748 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -239,6 +239,9 @@ importers:
'@fullcalendar/daygrid':
specifier: ^6.1.20
version: 6.1.20(@fullcalendar/[email protected])
+ '@fullcalendar/interaction':
+ specifier: ^6.1.20
+ version: 6.1.20(@fullcalendar/[email protected])
'@fullcalendar/list':
specifier: ^6.1.20
version: 6.1.20(@fullcalendar/[email protected])
@@ -2244,6 +2247,11 @@ packages:
peerDependencies:
'@fullcalendar/core': ~6.1.20
+ '@fullcalendar/[email protected]':
+ resolution: {integrity: sha512-p6txmc5txL0bMiPaJxe2ip6o0T384TyoD2KGdsU6UjZ5yoBlaY+dg7kxfnYKpYMzEJLG58n+URrHr2PgNL2fyA==}
+ peerDependencies:
+ '@fullcalendar/core': ~6.1.20
+
'@fullcalendar/[email protected]':
resolution: {integrity: sha512-7Hzkbb7uuSqrXwTyD0Ld/7SwWNxPD6SlU548vtkIpH55rZ4qquwtwYdMPgorHos5OynHA4OUrZNcH51CjrCf2g==}
peerDependencies:
@@ -10836,6 +10844,10 @@ snapshots:
dependencies:
'@fullcalendar/core': 6.1.20
+ '@fullcalendar/[email protected](@fullcalendar/[email protected])':
+ dependencies:
+ '@fullcalendar/core': 6.1.20
+
'@fullcalendar/[email protected](@fullcalendar/[email protected])':
dependencies:
'@fullcalendar/core': 6.1.20