Skip to content

Commit 9294cea

Browse files
Merge branch '26_1' into chore/migrate-devextreme-to-nx-part-9
2 parents 1bad8e1 + 0c8f94d commit 9294cea

5 files changed

Lines changed: 52 additions & 31 deletions

File tree

packages/devextreme/js/__internal/scheduler/appointments/appointment/m_types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Orientation } from '@js/common';
2-
import type NotifyScheduler from '@ts/scheduler/base/m_widget_notify_scheduler';
2+
import type NotifyScheduler from '@ts/scheduler/base/widget_notify_scheduler';
33
import type { TimeZoneCalculator } from '@ts/scheduler/r1/timezone_calculator/calculator';
44
import type { SafeAppointment } from '@ts/scheduler/types';
55
import type { AppointmentDataAccessor } from '@ts/scheduler/utils/data_accessor/appointment_data_accessor';

packages/devextreme/js/__internal/scheduler/base/m_widget_notify_scheduler.ts renamed to packages/devextreme/js/__internal/scheduler/base/widget_notify_scheduler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class NotifyScheduler {
1212
funcName: Subject,
1313
...args: Parameters<SubscribeMethods[Subject]>
1414
): ReturnType<SubscribeMethods[Subject]> {
15+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
1516
return this.scheduler.fire(funcName, ...args);
1617
}
1718
}

packages/devextreme/js/__internal/scheduler/m_scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { AppointmentPopup } from './appointment_popup/m_popup';
4242
import AppointmentCollection from './appointments/m_appointment_collection';
4343
import type { AppointmentsProperties } from './appointments_new/appointments';
4444
import { Appointments } from './appointments_new/appointments';
45-
import NotifyScheduler from './base/m_widget_notify_scheduler';
45+
import NotifyScheduler from './base/widget_notify_scheduler';
4646
import { SchedulerHeader } from './header/header';
4747
import type { HeaderOptions } from './header/types';
4848
import { CompactAppointmentsHelper } from './m_compact_appointments_helper';

packages/devextreme/js/__internal/scheduler/view_model/m_appointment_data_source.ts

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,61 @@
1+
import type { DataSource } from '@js/common/data';
2+
import type { DeferredObj } from '@js/core/utils/deferred';
13
import { Deferred } from '@js/core/utils/deferred';
4+
import type { StoreEventName } from '@js/data/store';
25

3-
const STORE_EVENTS = {
6+
import type { SafeAppointment } from '../types';
7+
8+
const STORE_EVENTS: Record<string, StoreEventName> = {
49
updating: 'updating',
510
push: 'push',
611
};
712

13+
interface UpdatedAppointmentKey {
14+
key: string;
15+
value: unknown;
16+
}
17+
818
export class AppointmentDataSource {
9-
protected updatedAppointmentKeys: any[];
19+
protected updatedAppointmentKeys: UpdatedAppointmentKey[] = [];
1020

11-
protected dataSource: any;
21+
protected dataSource?: DataSource;
1222

13-
protected updatedAppointment: any;
23+
protected updatedAppointment: SafeAppointment | null = null;
1424

15-
constructor(dataSource) {
25+
constructor(dataSource: DataSource) {
1626
this.setDataSource(dataSource);
1727
this.updatedAppointmentKeys = [];
1828
}
1929

20-
get keyName() {
21-
const store = this.dataSource.store();
22-
return store.key();
30+
get keyName(): string {
31+
const store = this.dataSource?.store();
32+
return store?.key() as string;
2333
}
2434

25-
get isDataSourceInit() {
35+
get isDataSourceInit(): boolean {
2636
return Boolean(this.dataSource);
2737
}
2838

29-
private getStoreKey(target) {
30-
const store = this.dataSource.store();
39+
private getStoreKey(target: SafeAppointment): unknown {
40+
const store = this.dataSource?.store();
3141

32-
return store.keyOf(target);
42+
return store?.keyOf(target);
3343
}
3444

35-
setDataSource(dataSource) {
45+
setDataSource(dataSource: DataSource): void {
3646
this.dataSource = dataSource;
3747

3848
this.cleanState();
3949
this.initStoreChangeHandlers();
4050
}
4151

42-
private initStoreChangeHandlers() {
52+
private initStoreChangeHandlers(): void {
4353
const { dataSource } = this;
4454
const store = dataSource?.store();
4555

46-
if (store) {
56+
if (dataSource && store) {
4757
store.on(STORE_EVENTS.updating, (key) => {
48-
const keyName = store.key();
58+
const keyName = store.key() as string;
4959
if (keyName) {
5060
this.updatedAppointmentKeys.push({
5161
key: keyName,
@@ -58,7 +68,7 @@ export class AppointmentDataSource {
5868

5969
store.on(STORE_EVENTS.push, (pushItems) => {
6070
const items = dataSource.items();
61-
const keyName = store.key();
71+
const keyName = store.key() as string;
6272

6373
pushItems.forEach((pushItem) => {
6474
const itemExists = items.filter((item) => item[keyName] === pushItem.key).length !== 0;
@@ -70,52 +80,62 @@ export class AppointmentDataSource {
7080
});
7181
} else {
7282
const { data } = pushItem;
73-
data && items.push(data);
83+
if (data) {
84+
items.push(data);
85+
}
7486
}
7587
});
7688

89+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
7790
dataSource.load();
7891
});
7992
}
8093
}
8194

82-
getUpdatedAppointment() {
95+
getUpdatedAppointment(): SafeAppointment | null {
8396
return this.updatedAppointment;
8497
}
8598

86-
getUpdatedAppointmentKeys() {
99+
getUpdatedAppointmentKeys(): UpdatedAppointmentKey[] {
87100
return this.updatedAppointmentKeys;
88101
}
89102

90-
cleanState() {
103+
cleanState(): void {
91104
this.updatedAppointment = null;
92105
this.updatedAppointmentKeys = [];
93106
}
94107

95-
add(rawAppointment) {
96-
return this.dataSource.store().insert(rawAppointment).done(() => this.dataSource.load());
108+
add(rawAppointment: SafeAppointment): DeferredObj<SafeAppointment> {
109+
// @eslint-disable-next-line
110+
return this.dataSource!.store().insert(rawAppointment)
111+
// @ts-expect-error
112+
.done(() => this.dataSource.load());
97113
}
98114

99-
update(target, data) {
115+
update(target: SafeAppointment, data: SafeAppointment): DeferredObj<SafeAppointment | undefined> {
100116
const key = this.getStoreKey(target);
101117
// @ts-expect-error
102118
const d = new Deferred();
103119

104-
this.dataSource.store().update(key, data)
120+
this.dataSource!.store().update(key, data)
121+
// @ts-expect-error
105122
.done((result) => this.dataSource.load()
123+
// @ts-expect-error
106124
.done(() => d.resolve(result))
107125
.fail(d.reject))
108126
.fail(d.reject);
109127

110128
return d.promise();
111129
}
112130

113-
remove(rawAppointment) {
131+
remove(rawAppointment: SafeAppointment): DeferredObj<SafeAppointment | undefined> {
114132
const key = this.getStoreKey(rawAppointment);
115-
return this.dataSource.store().remove(key).done(() => this.dataSource.load());
133+
return this.dataSource!.store().remove(key)
134+
// @ts-expect-error
135+
.done(() => this.dataSource.load());
116136
}
117137

118-
destroy() {
138+
destroy(): void {
119139
const store = this.dataSource?.store();
120140

121141
if (store) {

packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {
5252
import type { ViewType } from '@ts/scheduler/types';
5353
import Scrollable from '@ts/ui/scroll_view/scrollable';
5454

55-
import type NotifyScheduler from '../base/m_widget_notify_scheduler';
55+
import type NotifyScheduler from '../base/widget_notify_scheduler';
5656
import { APPOINTMENT_SETTINGS_KEY } from '../constants';
5757
import { Cache } from '../global_cache';
5858
import AppointmentDragBehavior from '../m_appointment_drag_behavior';

0 commit comments

Comments
 (0)