100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Fix scheduler start date not applying to period events (#3229)
Koen04dfeea791fa
diff --git a/ui/component/or-scheduler/src/index.ts b/ui/component/or-scheduler/src/index.tsindex ce9f4805d..e59044ef6 100644--- a/ui/component/or-scheduler/src/index.ts+++ b/ui/component/or-scheduler/src/index.ts@@ -321,12 +321,14 @@ export class OrScheduler extends translate(i18next)(OrElement) {} else {origOptions![key as RRulePartKeys] = value;}- } else if (key === "start" && origOptions) {+ } else if (key === "start") {const [year, month, date] = value.split("-").map(Number);- origOptions.dtstart = moment(calendarEvent.start)- .set({ year, month: month - 1, date })- .toDate();- calendarEvent.start = origOptions.dtstart.getTime();+ const start = moment(calendarEvent.start).set({ year, month: month - 1, date });+ if (origOptions) {+ // A period event has no recurrence rule to keep in sync+ origOptions.dtstart = start.toDate();+ }+ calendarEvent.start = start.valueOf();} else if (key === "end") {const [year, month, date] = value.split("-").map(Number);calendarEvent.end = moment(calendarEvent.end)diff --git a/ui/component/or-scheduler/test/or-scheduler.test.ts b/ui/component/or-scheduler/test/or-scheduler.test.tsindex c6020da1c..efa152e37 100644--- a/ui/component/or-scheduler/test/or-scheduler.test.ts+++ b/ui/component/or-scheduler/test/or-scheduler.test.ts@@ -156,6 +156,29 @@ ct.describe("Period event type should", () => {await expect(component.getByRole("button", { name: "Active " + timeLabel })).toBeVisible();});+ ct("return period with a changed start date", async ({ mount, shared, vaadinDialog, vaadinInput }) => {+ const [promise, handler] = shared.promiseEventDispatch<OrSchedulerChangedEvent>();+ const component = await mount(OrScheduler, {+ props: { header: "Test Calendar Event Component" },+ on: { "or-scheduler-changed": handler },+ });++ await component.click();+ const dialog = vaadinDialog.getDialog();+ await selectEventType("Plan an occurrence", dialog, vaadinInput);++ await dialog.locator("or-vaadin-date-picker [slot=input]").first().fill("1/2/2020"); // M/D/YYYY+ await dialog.locator("or-vaadin-date-picker [slot=input]").first().press("Enter");+ await dialog.getByRole("button", { name: "Save schedule" }).click();++ const actual = (await promise).value;+ const { end } = getPeriodValues();++ // Without a recurrence rule the start date was discarded, leaving the start on the current day+ expect(actual).toStrictEqual({ end, start: new Date(2020, 0, 2).getTime(), recurrence: undefined });+ await expect(component.getByRole("button", { name: /Active from 02-01-2020/ })).toBeVisible();+ });+ct("return period with time component", async ({ mount, shared, vaadinDialog, vaadinInput }) => {const [promise, handler] = shared.promiseEventDispatch<OrSchedulerChangedEvent>();const component = await mount(OrScheduler, {