Skip to content

Commit 97450c8

Browse files
sjburweb-flow
andauthored
Scheduler: refactor workspaces module (TS): part 5 (DevExpress#33991)
Co-authored-by: Sergei Burkatskii <noreply@github.com>
1 parent 57c4009 commit 97450c8

24 files changed

Lines changed: 336 additions & 203 deletions

packages/devextreme/eslint-scheduler-allowlist.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const schedulerLegacyMembers = [
7878
// appointments/m_appointment_collection.ts
7979
'_renderAppointmentTemplate',
8080

81-
// workspaces/view_model/m_view_data_generator.ts
81+
// workspaces/view_model/view_data_generator.ts
8282
'_getIntervalDuration',
8383

8484
// workspaces/virtual_scrolling.ts

packages/devextreme/js/__internal/scheduler/r1/components/base/date_header.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export class DateHeader extends BaseInfernoComponent<DateHeaderProps> {
6262
{
6363
dateHeaderRow.map(({
6464
colSpan,
65-
endDate,
6665
groupIndex,
6766
groups: cellGroups,
6867
index,
@@ -77,7 +76,6 @@ export class DateHeader extends BaseInfernoComponent<DateHeaderProps> {
7776
key={key}
7877
viewContext={viewContext}
7978
startDate={startDate}
80-
endDate={endDate}
8179
groups={isHorizontalGrouping ? cellGroups : undefined}
8280
groupIndex={isHorizontalGrouping ? groupIndex : undefined}
8381
today={today ?? false}

packages/devextreme/js/__internal/scheduler/r1/components/base/date_header_cell.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { CellBaseProps } from './cell';
99
import { CellBaseDefaultProps } from './cell';
1010
import { DateHeaderText } from './date_header_text';
1111

12-
export interface DateHeaderCellProps extends CellBaseProps {
12+
export interface DateHeaderCellProps extends Omit<CellBaseProps, 'endDate'> {
1313
today: boolean;
1414
colSpan: number;
1515
isWeekDayCell: boolean;
@@ -20,8 +20,10 @@ export interface DateHeaderCellProps extends CellBaseProps {
2020
dateCellTemplate?: JSXTemplate<DateTimeCellTemplateProps>;
2121
}
2222

23+
const { endDate: _, ...cellBaseDefaultPropsWithoutEndDate } = CellBaseDefaultProps;
24+
2325
export const DateHeaderCellDefaultProps: DefaultProps<DateHeaderCellProps> = {
24-
...CellBaseDefaultProps,
26+
...cellBaseDefaultPropsWithoutEndDate,
2527
today: false,
2628
colSpan: 1,
2729
isWeekDayCell: false,

packages/devextreme/js/__internal/scheduler/r1/components/timeline/date_header_timeline.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export class TimelineDateHeaderLayout extends BaseInfernoComponent<DateHeaderPro
7373
{
7474
dateHeaderRow.map(({
7575
colSpan,
76-
endDate,
7776
groupIndex,
7877
groups: cellGroups,
7978
index,
@@ -88,7 +87,6 @@ export class TimelineDateHeaderLayout extends BaseInfernoComponent<DateHeaderPro
8887
key={key}
8988
viewContext={viewContext}
9089
startDate={startDate}
91-
endDate={endDate}
9290
groups={isHorizontalGrouping ? cellGroups : undefined}
9391
groupIndex={isHorizontalGrouping ? groupIndex : undefined}
9492
today={today ?? DateHeaderCellDefaultProps.today}

packages/devextreme/js/__internal/scheduler/r1/components/types.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,6 @@ export interface ViewCellData {
6262
highlighted?: boolean;
6363
}
6464

65-
export interface DateHeaderCellData extends ViewCellData {
66-
colSpan: number;
67-
}
68-
69-
export interface DateHeaderData {
70-
dataMap: DateHeaderCellData[][];
71-
leftVirtualCellWidth: number;
72-
rightVirtualCellWidth: number;
73-
leftVirtualCellCount: number;
74-
rightVirtualCellCount: number;
75-
weekDayLeftVirtualCellWidth?: number;
76-
weekDayRightVirtualCellWidth?: number;
77-
weekDayLeftVirtualCellCount?: number;
78-
weekDayRightVirtualCellCount?: number;
79-
isMonthDateHeader?: boolean;
80-
}
81-
8265
interface DataCellTemplateData extends BaseTemplateData {
8366
startDate: Date;
8467
endDate: Date;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export type TimePanelCellData = Omit<ViewCellData, 'endDate'>;
111111
export interface CountGenerationConfig {
112112
intervalCount: number;
113113
currentDate: Date;
114-
viewType: string;
114+
viewType: ViewType;
115115
hoursInterval: number;
116116
startDayHour: number;
117117
endDayHour: number;
@@ -202,7 +202,7 @@ export interface DOMMetaData {
202202
allDayPanelCellsMeta: CellRect[];
203203
}
204204

205-
export interface DateHeaderCellData extends ViewCellData {
205+
export interface DateHeaderCellData extends Omit<ViewCellData, 'endDate'> {
206206
colSpan: number;
207207
}
208208

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import dateUtils from '@js/core/utils/date';
99
import { extend } from '@js/core/utils/extend';
1010
import { each } from '@js/core/utils/iterator';
1111
import { setHeight, setOuterHeight } from '@js/core/utils/size';
12+
import type { ViewType } from '@js/ui/scheduler';
1213
import type { OptionChanged } from '@ts/core/widget/types';
1314
import { EMPTY_ACTIVE_STATE_UNIT } from '@ts/core/widget/widget';
1415

@@ -67,7 +68,7 @@ class SchedulerAgenda extends WorkSpace {
6768
return EMPTY_ACTIVE_STATE_UNIT;
6869
}
6970

70-
get type(): string { return VIEWS.AGENDA; }
71+
get type(): ViewType { return VIEWS.AGENDA; }
7172

7273
getStartViewDate(): Date {
7374
return this.startViewDate;

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ const { tableCreator } = tableCreatorModule;
135135
const DRAGGING_MOUSE_FAULT = 10;
136136

137137
// @ts-expect-error Widget exposes a static abstract() helper not typed in its d.ts
138-
const { abstract } = Widget;
138+
const { abstract: widgetAbstract } = Widget;
139+
const abstract = widgetAbstract as () => never;
139140
const toMs = dateUtils.dateToMilliseconds;
140141

141142
const COMPONENT_CLASS = 'dx-scheduler-work-space';
@@ -388,14 +389,13 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
388389
return CELL_SELECTOR;
389390
}
390391

391-
// eslint-disable-next-line @typescript-eslint/class-literal-property-style
392-
get type(): string {
393-
return '';
392+
get type(): ViewType {
393+
return abstract();
394394
}
395395

396396
get viewDataProvider(): ViewDataProvider {
397397
if (!this.viewDataProviderValue) {
398-
this.viewDataProviderValue = new ViewDataProvider(this.type as ViewType);
398+
this.viewDataProviderValue = new ViewDataProvider(this.type);
399399
}
400400
return this.viewDataProviderValue;
401401
}
@@ -1360,21 +1360,21 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
13601360
return {
13611361
startDayHour: this.option('startDayHour'),
13621362
endDayHour: this.option('endDayHour'),
1363+
hoursInterval: this.option('hoursInterval'),
13631364
interval: this.viewDataProvider.viewDataGenerator?.getInterval(this.option('hoursInterval')),
1365+
intervalCount: this.option('intervalCount'),
13641366
startViewDate: this.getStartViewDate(),
13651367
firstDayOfWeek: this.firstDayOfWeek(),
13661368
viewOffset: this.option('viewOffset'),
1367-
viewType: this.type as ViewType,
1368-
hoursInterval: this.option('hoursInterval'),
1369-
intervalCount: this.option('intervalCount'),
1369+
viewType: this.type,
13701370
};
13711371
}
13721372

13731373
// TODO: refactor current time indicator
13741374
protected getIntervalBetween(currentDate, allDay) {
13751375
const firstViewDate = this.getStartViewDate();
13761376

1377-
const startDayTime = (this.option('startDayHour') as any) * HOUR_MS;
1377+
const startDayTime = this.option('startDayHour') * HOUR_MS;
13781378
const timeZoneOffset = dateUtils.getTimezonesDifference(firstViewDate, currentDate);
13791379
const fullInterval = currentDate.getTime() - firstViewDate.getTime() - timeZoneOffset;
13801380
const days = this.getDaysOfInterval(fullInterval, startDayTime);
@@ -1983,7 +1983,7 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
19831983
protected getR1ComponentsViewContext(): ViewContext {
19841984
return {
19851985
view: {
1986-
type: this.type as ViewType,
1986+
type: this.type,
19871987
},
19881988
crossScrollingEnabled: Boolean(this.option('crossScrollingEnabled')),
19891989
};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import registerComponent from '@js/core/component_registrator';
2+
import type { ViewType } from '@js/ui/scheduler';
23

34
import { VIEWS } from '../utils/options/constants_view';
45
import SchedulerTimeline from './timeline';
56

67
const TIMELINE_CLASS = 'dx-scheduler-timeline-day';
78

89
class SchedulerTimelineDay extends SchedulerTimeline {
9-
get type(): string { return VIEWS.TIMELINE_DAY; }
10+
get type(): ViewType { return VIEWS.TIMELINE_DAY; }
1011

1112
protected override getElementClass(): string {
1213
return TIMELINE_CLASS;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import registerComponent from '@js/core/component_registrator';
22
import type { TemplateBase } from '@js/core/templates/template_base';
33
import dateUtils from '@js/core/utils/date';
4+
import type { ViewType } from '@js/ui/scheduler';
45
import { HeaderPanelComponent } from '@ts/scheduler/r1/components/index';
56
import { formatWeekdayAndDay, monthUtils } from '@ts/scheduler/r1/utils/index';
67

@@ -11,7 +12,7 @@ import type { ViewDataProviderOptions } from './view_model/types';
1112
const TIMELINE_CLASS = 'dx-scheduler-timeline-month';
1213

1314
class SchedulerTimelineMonth extends SchedulerTimeline {
14-
get type(): string { return VIEWS.TIMELINE_MONTH; }
15+
get type(): ViewType { return VIEWS.TIMELINE_MONTH; }
1516

1617
readonly viewDirection = 'horizontal';
1718

0 commit comments

Comments
 (0)