From 50139a5cf930067296eb689e416b306651c4e6ca Mon Sep 17 00:00:00 2001 From: Sergio Bur Date: Wed, 13 May 2026 15:38:07 +0200 Subject: [PATCH 1/4] refactor: rename widget_notify_scheduler --- .../js/__internal/scheduler/appointments/appointment/m_types.ts | 2 +- ...{m_widget_notify_scheduler.ts => widget_notify_scheduler.ts} | 1 + packages/devextreme/js/__internal/scheduler/m_scheduler.ts | 2 +- .../js/__internal/scheduler/workspaces/m_work_space.ts | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) rename packages/devextreme/js/__internal/scheduler/base/{m_widget_notify_scheduler.ts => widget_notify_scheduler.ts} (88%) diff --git a/packages/devextreme/js/__internal/scheduler/appointments/appointment/m_types.ts b/packages/devextreme/js/__internal/scheduler/appointments/appointment/m_types.ts index 4b0e3bd34090..890a589ca966 100644 --- a/packages/devextreme/js/__internal/scheduler/appointments/appointment/m_types.ts +++ b/packages/devextreme/js/__internal/scheduler/appointments/appointment/m_types.ts @@ -1,5 +1,5 @@ import type { Orientation } from '@js/common'; -import type NotifyScheduler from '@ts/scheduler/base/m_widget_notify_scheduler'; +import type NotifyScheduler from '@ts/scheduler/base/widget_notify_scheduler'; import type { TimeZoneCalculator } from '@ts/scheduler/r1/timezone_calculator/calculator'; import type { SafeAppointment } from '@ts/scheduler/types'; import type { AppointmentDataAccessor } from '@ts/scheduler/utils/data_accessor/appointment_data_accessor'; diff --git a/packages/devextreme/js/__internal/scheduler/base/m_widget_notify_scheduler.ts b/packages/devextreme/js/__internal/scheduler/base/widget_notify_scheduler.ts similarity index 88% rename from packages/devextreme/js/__internal/scheduler/base/m_widget_notify_scheduler.ts rename to packages/devextreme/js/__internal/scheduler/base/widget_notify_scheduler.ts index 8312f57b98ef..675435a957d0 100644 --- a/packages/devextreme/js/__internal/scheduler/base/m_widget_notify_scheduler.ts +++ b/packages/devextreme/js/__internal/scheduler/base/widget_notify_scheduler.ts @@ -12,6 +12,7 @@ class NotifyScheduler { funcName: Subject, ...args: Parameters ): ReturnType { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return this.scheduler.fire(funcName, ...args); } } diff --git a/packages/devextreme/js/__internal/scheduler/m_scheduler.ts b/packages/devextreme/js/__internal/scheduler/m_scheduler.ts index 1d18449f611f..dec7c5fd7e84 100644 --- a/packages/devextreme/js/__internal/scheduler/m_scheduler.ts +++ b/packages/devextreme/js/__internal/scheduler/m_scheduler.ts @@ -42,7 +42,7 @@ import { AppointmentPopup } from './appointment_popup/m_popup'; import AppointmentCollection from './appointments/m_appointment_collection'; import type { AppointmentsProperties } from './appointments_new/appointments'; import { Appointments } from './appointments_new/appointments'; -import NotifyScheduler from './base/m_widget_notify_scheduler'; +import NotifyScheduler from './base/widget_notify_scheduler'; import { SchedulerHeader } from './header/header'; import type { HeaderOptions } from './header/types'; import { CompactAppointmentsHelper } from './m_compact_appointments_helper'; diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts index d89814b209a0..ff34983428a9 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts @@ -52,7 +52,7 @@ import { import type { ViewType } from '@ts/scheduler/types'; import Scrollable from '@ts/ui/scroll_view/scrollable'; -import type NotifyScheduler from '../base/m_widget_notify_scheduler'; +import type NotifyScheduler from '../base/widget_notify_scheduler'; import { APPOINTMENT_SETTINGS_KEY } from '../constants'; import { Cache } from '../global_cache'; import AppointmentDragBehavior from '../m_appointment_drag_behavior'; From 00155d95eacc36560bd4fa110de60ea3d758e14f Mon Sep 17 00:00:00 2001 From: Sergio Bur Date: Wed, 13 May 2026 17:08:58 +0200 Subject: [PATCH 2/4] refactor: fix types --- .../view_model/m_appointment_data_source.ts | 80 ++++++++++++------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts b/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts index ff11cdf6b0f2..aeda9e8497bf 100644 --- a/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts +++ b/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts @@ -1,51 +1,61 @@ +import type { DataSource } from '@js/common/data'; +import type { DeferredObj } from '@js/core/utils/deferred'; import { Deferred } from '@js/core/utils/deferred'; +import type { StoreEventName } from '@js/data/store'; -const STORE_EVENTS = { +import type { SafeAppointment } from '../types'; + +const STORE_EVENTS: Record = { updating: 'updating', push: 'push', }; +interface UpdatedAppointmentKey { + key: string; + value: unknown; +} + export class AppointmentDataSource { - protected updatedAppointmentKeys: any[]; + protected updatedAppointmentKeys: UpdatedAppointmentKey[] = []; - protected dataSource: any; + protected dataSource: DataSource | null = null; - protected updatedAppointment: any; + protected updatedAppointment: SafeAppointment | null = null; - constructor(dataSource) { + constructor(dataSource: DataSource) { this.setDataSource(dataSource); this.updatedAppointmentKeys = []; } - get keyName() { - const store = this.dataSource.store(); - return store.key(); + get keyName(): string { + const store = this.dataSource?.store(); + return store?.key() as string; } - get isDataSourceInit() { + get isDataSourceInit(): boolean { return Boolean(this.dataSource); } - private getStoreKey(target) { - const store = this.dataSource.store(); + private getStoreKey(target: SafeAppointment): unknown { + const store = this.dataSource?.store(); - return store.keyOf(target); + return store?.keyOf(target); } - setDataSource(dataSource) { + setDataSource(dataSource: DataSource): void { this.dataSource = dataSource; this.cleanState(); this.initStoreChangeHandlers(); } - private initStoreChangeHandlers() { + private initStoreChangeHandlers(): void { const { dataSource } = this; const store = dataSource?.store(); if (store) { store.on(STORE_EVENTS.updating, (key) => { - const keyName = store.key(); + const keyName = store.key() as string; if (keyName) { this.updatedAppointmentKeys.push({ key: keyName, @@ -57,8 +67,8 @@ export class AppointmentDataSource { }); store.on(STORE_EVENTS.push, (pushItems) => { - const items = dataSource.items(); - const keyName = store.key(); + const items = dataSource?.items() ?? []; + const keyName = store.key() as string; pushItems.forEach((pushItem) => { const itemExists = items.filter((item) => item[keyName] === pushItem.key).length !== 0; @@ -70,39 +80,47 @@ export class AppointmentDataSource { }); } else { const { data } = pushItem; - data && items.push(data); + if (data) { + items.push(data); + } } }); - dataSource.load(); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + dataSource?.load(); }); } } - getUpdatedAppointment() { + getUpdatedAppointment(): SafeAppointment | null { return this.updatedAppointment; } - getUpdatedAppointmentKeys() { + getUpdatedAppointmentKeys(): UpdatedAppointmentKey[] { return this.updatedAppointmentKeys; } - cleanState() { + cleanState(): void { this.updatedAppointment = null; this.updatedAppointmentKeys = []; } - add(rawAppointment) { - return this.dataSource.store().insert(rawAppointment).done(() => this.dataSource.load()); + add(rawAppointment: SafeAppointment): DeferredObj { + // @eslint-disable-next-line + return this.dataSource?.store().insert(rawAppointment) + // @ts-expect-error + .done(() => this.dataSource.load()); } - update(target, data) { + update(target: SafeAppointment, data: SafeAppointment): DeferredObj { const key = this.getStoreKey(target); // @ts-expect-error const d = new Deferred(); - this.dataSource.store().update(key, data) - .done((result) => this.dataSource.load() + this.dataSource?.store().update(key, data) + // @ts-expect-error + .done((result) => this.dataSource?.load() + // @ts-expect-error .done(() => d.resolve(result)) .fail(d.reject)) .fail(d.reject); @@ -110,12 +128,14 @@ export class AppointmentDataSource { return d.promise(); } - remove(rawAppointment) { + remove(rawAppointment: SafeAppointment): DeferredObj { const key = this.getStoreKey(rawAppointment); - return this.dataSource.store().remove(key).done(() => this.dataSource.load()); + return this.dataSource?.store().remove(key) + // @ts-expect-error + .done(() => this.dataSource?.load()); } - destroy() { + destroy(): void { const store = this.dataSource?.store(); if (store) { From bb3ca5bb4c2f108ea7db0d1aef9ae092ae9f1685 Mon Sep 17 00:00:00 2001 From: Sergio Bur Date: Wed, 13 May 2026 21:58:10 +0200 Subject: [PATCH 3/4] fix: fix tests --- .../view_model/m_appointment_data_source.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts b/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts index aeda9e8497bf..ef2dd257c7e4 100644 --- a/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts +++ b/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts @@ -18,7 +18,7 @@ interface UpdatedAppointmentKey { export class AppointmentDataSource { protected updatedAppointmentKeys: UpdatedAppointmentKey[] = []; - protected dataSource: DataSource | null = null; + protected dataSource!: DataSource; protected updatedAppointment: SafeAppointment | null = null; @@ -28,7 +28,7 @@ export class AppointmentDataSource { } get keyName(): string { - const store = this.dataSource?.store(); + const store = this.dataSource.store(); return store?.key() as string; } @@ -37,7 +37,7 @@ export class AppointmentDataSource { } private getStoreKey(target: SafeAppointment): unknown { - const store = this.dataSource?.store(); + const store = this.dataSource.store(); return store?.keyOf(target); } @@ -51,7 +51,7 @@ export class AppointmentDataSource { private initStoreChangeHandlers(): void { const { dataSource } = this; - const store = dataSource?.store(); + const store = dataSource.store(); if (store) { store.on(STORE_EVENTS.updating, (key) => { @@ -67,7 +67,7 @@ export class AppointmentDataSource { }); store.on(STORE_EVENTS.push, (pushItems) => { - const items = dataSource?.items() ?? []; + const items = dataSource.items(); const keyName = store.key() as string; pushItems.forEach((pushItem) => { @@ -87,7 +87,7 @@ export class AppointmentDataSource { }); // eslint-disable-next-line @typescript-eslint/no-floating-promises - dataSource?.load(); + dataSource.load(); }); } } @@ -107,7 +107,7 @@ export class AppointmentDataSource { add(rawAppointment: SafeAppointment): DeferredObj { // @eslint-disable-next-line - return this.dataSource?.store().insert(rawAppointment) + return this.dataSource.store().insert(rawAppointment) // @ts-expect-error .done(() => this.dataSource.load()); } @@ -117,9 +117,9 @@ export class AppointmentDataSource { // @ts-expect-error const d = new Deferred(); - this.dataSource?.store().update(key, data) + this.dataSource.store().update(key, data) // @ts-expect-error - .done((result) => this.dataSource?.load() + .done((result) => this.dataSource.load() // @ts-expect-error .done(() => d.resolve(result)) .fail(d.reject)) @@ -130,13 +130,13 @@ export class AppointmentDataSource { remove(rawAppointment: SafeAppointment): DeferredObj { const key = this.getStoreKey(rawAppointment); - return this.dataSource?.store().remove(key) + return this.dataSource.store().remove(key) // @ts-expect-error - .done(() => this.dataSource?.load()); + .done(() => this.dataSource.load()); } destroy(): void { - const store = this.dataSource?.store(); + const store = this.dataSource.store(); if (store) { store.off(STORE_EVENTS.updating); From eb4729a5c960bb91118655f2c3f954967085a41c Mon Sep 17 00:00:00 2001 From: Sergio Bur Date: Thu, 14 May 2026 10:18:44 +0200 Subject: [PATCH 4/4] fix: fix tests --- .../view_model/m_appointment_data_source.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts b/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts index ef2dd257c7e4..456fcfb4fb36 100644 --- a/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts +++ b/packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts @@ -18,7 +18,7 @@ interface UpdatedAppointmentKey { export class AppointmentDataSource { protected updatedAppointmentKeys: UpdatedAppointmentKey[] = []; - protected dataSource!: DataSource; + protected dataSource?: DataSource; protected updatedAppointment: SafeAppointment | null = null; @@ -28,7 +28,7 @@ export class AppointmentDataSource { } get keyName(): string { - const store = this.dataSource.store(); + const store = this.dataSource?.store(); return store?.key() as string; } @@ -37,7 +37,7 @@ export class AppointmentDataSource { } private getStoreKey(target: SafeAppointment): unknown { - const store = this.dataSource.store(); + const store = this.dataSource?.store(); return store?.keyOf(target); } @@ -51,9 +51,9 @@ export class AppointmentDataSource { private initStoreChangeHandlers(): void { const { dataSource } = this; - const store = dataSource.store(); + const store = dataSource?.store(); - if (store) { + if (dataSource && store) { store.on(STORE_EVENTS.updating, (key) => { const keyName = store.key() as string; if (keyName) { @@ -107,7 +107,7 @@ export class AppointmentDataSource { add(rawAppointment: SafeAppointment): DeferredObj { // @eslint-disable-next-line - return this.dataSource.store().insert(rawAppointment) + return this.dataSource!.store().insert(rawAppointment) // @ts-expect-error .done(() => this.dataSource.load()); } @@ -117,7 +117,7 @@ export class AppointmentDataSource { // @ts-expect-error const d = new Deferred(); - this.dataSource.store().update(key, data) + this.dataSource!.store().update(key, data) // @ts-expect-error .done((result) => this.dataSource.load() // @ts-expect-error @@ -130,13 +130,13 @@ export class AppointmentDataSource { remove(rawAppointment: SafeAppointment): DeferredObj { const key = this.getStoreKey(rawAppointment); - return this.dataSource.store().remove(key) + return this.dataSource!.store().remove(key) // @ts-expect-error .done(() => this.dataSource.load()); } destroy(): void { - const store = this.dataSource.store(); + const store = this.dataSource?.store(); if (store) { store.off(STORE_EVENTS.updating);