Scheduler: refactor workspaces module (TS): part 1#33789
Closed
sjbur wants to merge 10 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Scheduler workspaces module to improve TypeScript type-safety and clarify workspace-specific option/config contracts as part of an incremental modernization of the internal Scheduler implementation.
Changes:
- Introduces explicit exported types for workspace options, scrollable configs, and date-generation options, and applies stronger typing to key methods.
- Tightens method signatures and return types across multiple workspaces (day/week/month/timeline/agenda) and the workspace indicator.
- Updates Scheduler
_optionChangedtyping to useOptionChanged<...>and aligns several call sites with the new typed contracts.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts | Adds exported option/config interfaces and strengthens typing for scrolling and option change handling. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_week.ts | Adds explicit return/param types for week workspace overrides. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_month.ts | Adds explicit return/param types and minor refactors for month workspace methods. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_indicator.ts | Adds stronger typing for indicator logic, DOM wrappers, and option change handling. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_day.ts | Adds explicit return types for day workspace overrides. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline.ts | Adds stronger typing for timeline workspace DOM/scrolling behavior and default options. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_week.ts | Adds explicit return types for timeline week overrides. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_month.ts | Adds types for templates/options and refines month timeline view start/date formatting logic. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_day.ts | Adds explicit return types for timeline day overrides. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts | Improves typing for agenda rendering and option handling; refactors some loops/conditions. |
| packages/devextreme/js/__internal/scheduler/m_scheduler.ts | Types _optionChanged with OptionChanged<...> and adjusts switch cases accordingly. |
Comment on lines
+739
to
+740
| const useKeyboardDisabled = !(component.option('useKeyboard') as unknown as boolean); | ||
| const useNativeEnabled = component.option('useNative') as unknown as boolean; |
| }, | ||
| onOptionChanged: ({ fullName, value, component }) => { | ||
| const useKeyboardDisabled = component.option('useKeyboard') === false; | ||
| const useKeyboardDisabled = !(component.option('useKeyboard') as unknown as boolean); |
Comment on lines
+529
to
536
| updateScrollPosition(date: Date): void { | ||
| const newDate = this.timeZoneCalculator.createDate(date, 'toGrid'); | ||
|
|
||
| const bounds = this.getVisibleBounds(); | ||
| const startDateHour = newDate.getHours(); | ||
| const startDateMinutes = newDate.getMinutes(); | ||
|
|
||
| if (this.needUpdateScrollPosition(startDateHour, startDateMinutes, bounds, newDate)) { | ||
| if (this.needUpdateScrollPosition(newDate, bounds)) { | ||
| this.scrollTo(newDate); | ||
| } |
Comment on lines
+548
to
552
| const bounds = this.getVisibleBounds(); | ||
| const hours = date.getHours(); | ||
| const minutes = date.getMinutes(); | ||
| let isUpdateNeeded = false; | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sergei Burkatskii <sergei.burkatskii@devexpress.com>
Comment on lines
532
to
536
| const bounds = this.getVisibleBounds(); | ||
| const startDateHour = newDate.getHours(); | ||
| const startDateMinutes = newDate.getMinutes(); | ||
|
|
||
| if (this.needUpdateScrollPosition(startDateHour, startDateMinutes, bounds, newDate)) { | ||
| if (this.needUpdateScrollPosition(newDate, bounds)) { | ||
| this.scrollTo(newDate); | ||
| } |
| @@ -530,22 +565,26 @@ class SchedulerAgenda extends WorkSpace { | |||
| return isUpdateNeeded; | |||
Comment on lines
73
to
76
| protected override getFormat(): string { | ||
| const format = getGlobalFormatByDataType('time'); | ||
| return typeof format === 'string' ? format : 'shorttime'; | ||
| } |
Comment on lines
42
to
45
| // @ts-expect-error | ||
| protected override getFormat(): (date: Date) => string { | ||
| return formatWeekdayAndDay; | ||
| } |
Comment on lines
+543
to
546
| // @ts-expect-error | ||
| case 'skippedDays': | ||
| break; | ||
| case 'indicatorTime': |
Comment on lines
+70
to
73
| protected override getFormat(): string | ((date: Date) => string) { | ||
| const format = getGlobalFormatByDataType('time'); | ||
| return typeof format === 'string' ? format : 'shorttime'; | ||
| } |
Comment on lines
+125
to
+144
| export interface WorkspaceDateTableScrollableConfig { | ||
| useKeyboard: boolean; | ||
| bounceEnabled: boolean; | ||
| updateManually: boolean; | ||
| onScroll: (event: ScrollEvent) => void; | ||
| onInitialized: (args: { component: Scrollable }) => void; | ||
| onOptionChanged: (args: { fullName: string; value: unknown; component: Scrollable }) => void; | ||
| direction?: 'both'; | ||
| onEnd?: () => void; | ||
| } | ||
|
|
||
| export interface WorkspaceHeaderScrollableConfig { | ||
| useKeyboard: boolean; | ||
| showScrollbar: 'never'; | ||
| direction: 'horizontal'; | ||
| useNative: false; | ||
| updateManually: true; | ||
| bounceEnabled: false; | ||
| onScroll: (event: ScrollEvent) => void; | ||
| } |
Comment on lines
+529
to
536
| updateScrollPosition(date: Date): void { | ||
| const newDate = this.timeZoneCalculator.createDate(date, 'toGrid'); | ||
|
|
||
| const bounds = this.getVisibleBounds(); | ||
| const startDateHour = newDate.getHours(); | ||
| const startDateMinutes = newDate.getMinutes(); | ||
|
|
||
| if (this.needUpdateScrollPosition(startDateHour, startDateMinutes, bounds, newDate)) { | ||
| if (this.needUpdateScrollPosition(newDate, bounds)) { | ||
| this.scrollTo(newDate); | ||
| } |
Comment on lines
+539
to
+547
| needUpdateScrollPosition( | ||
| date: Date, | ||
| appointmentGroupValues?: unknown, | ||
| inAllDayRow?: boolean, | ||
| ): boolean { | ||
| if (appointmentGroupValues || inAllDayRow) { | ||
| noop(); | ||
| } | ||
|
|
| onScroll: (event: ScrollEvent) => void; | ||
| onInitialized: (args: { component: Scrollable }) => void; | ||
| onOptionChanged: (args: { fullName: string; value: unknown; component: Scrollable }) => void; | ||
| direction?: 'both'; |
Comment on lines
+406
to
+414
| protected override renderIndicator( | ||
| height: number, | ||
| rtlOffset: number, | ||
| $container: dxElementWrapper, | ||
| groupCount: number, | ||
| ): void { | ||
| if (height !== undefined) { | ||
| noop(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.