-
Notifications
You must be signed in to change notification settings - Fork 664
Scheduler: add new scroll api method #32190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 26_1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { | ||
| describe, expect, it, jest, | ||
| } from '@jest/globals'; | ||
| import { logger } from '@ts/core/utils/m_console'; | ||
|
|
||
| import { createScheduler } from './__mock__/create_scheduler'; | ||
| import { setupSchedulerTestEnvironment } from './__mock__/m_mock_scheduler'; | ||
|
|
||
| describe('Scheduler scrollTo deprecation', () => { | ||
| it('should log deprecation warning when using old scrollTo API', async () => { | ||
| setupSchedulerTestEnvironment(); | ||
| const loggerWarnSpy = jest.spyOn(logger, 'warn'); | ||
|
|
||
| const { scheduler } = await createScheduler({ | ||
| dataSource: [{ | ||
| text: 'Meeting', | ||
| startDate: new Date(2025, 0, 15, 9, 0), | ||
| endDate: new Date(2025, 0, 15, 10, 0), | ||
| }], | ||
| views: ['week'], | ||
| currentView: 'week', | ||
| currentDate: new Date(2025, 0, 15), | ||
| startDayHour: 8, | ||
| endDayHour: 18, | ||
| }); | ||
| loggerWarnSpy.mockReset(); | ||
|
|
||
| const testDate = new Date(2025, 0, 16, 14, 0); | ||
|
|
||
| scheduler.scrollTo(testDate, undefined, false); | ||
|
|
||
| expect(loggerWarnSpy).toHaveBeenCalledTimes(1); | ||
| expect(loggerWarnSpy).toHaveBeenCalledWith( | ||
| expect.stringContaining('W0002'), | ||
| ); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,7 +64,7 @@ import { MobileTooltipStrategy } from './tooltip_strategies/m_mobile_tooltip_str | |||||||
| import type { | ||||||||
| AppointmentTooltipItem, | ||||||||
| SafeAppointment, | ||||||||
| TargetedAppointment, | ||||||||
| ScrollToGroupValuesOrOptions, ScrollToOptions, TargetedAppointment, | ||||||||
| } from './types'; | ||||||||
| import { AppointmentAdapter } from './utils/appointment_adapter/appointment_adapter'; | ||||||||
| import { AppointmentDataAccessor } from './utils/data_accessor/appointment_data_accessor'; | ||||||||
|
|
@@ -2022,8 +2022,31 @@ class Scheduler extends SchedulerOptionsBaseWidget { | |||||||
| this._appointmentTooltip?.hide(); | ||||||||
| } | ||||||||
|
|
||||||||
| scrollTo(date, groupValues, allDay) { | ||||||||
| this._workSpace.scrollTo(date, groupValues, allDay); | ||||||||
| scrollTo( | ||||||||
| date: Date, | ||||||||
| groupValuesOrOptions?: ScrollToGroupValuesOrOptions, | ||||||||
| allDay?: boolean | undefined, | ||||||||
| ) { | ||||||||
| let groupValues; | ||||||||
| let allDayValue; | ||||||||
| let align: 'start' | 'center' = 'center'; | ||||||||
|
|
||||||||
| if (this._isScrollOptionsObject(groupValuesOrOptions)) { | ||||||||
| groupValues = groupValuesOrOptions.group; | ||||||||
| allDayValue = groupValuesOrOptions.allDay; | ||||||||
| align = groupValuesOrOptions.align ?? 'center'; | ||||||||
| } else { | ||||||||
| errors.log('W0002', 'dxScheduler', 'scrollTo', '26.1', 'Use an object with "group", "allDay", and "align" properties instead of separate parameters.'); | ||||||||
| groupValues = groupValuesOrOptions; | ||||||||
| allDayValue = allDay; | ||||||||
Tucchhaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| } | ||||||||
|
|
||||||||
| this._workSpace.scrollTo(date, groupValues, allDayValue, true, align); | ||||||||
| } | ||||||||
|
|
||||||||
| private _isScrollOptionsObject(options?: ScrollToGroupValuesOrOptions): options is ScrollToOptions { | ||||||||
| return Boolean(options) && typeof options === 'object' | ||||||||
| && ('align' in options || 'allDay' in options || 'group' in options); | ||||||||
aleksei-semikozov marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+2048
to
+2049
|
||||||||
| return Boolean(options) && typeof options === 'object' | |
| && ('align' in options || 'allDay' in options || 'group' in options); | |
| return Boolean(options) && typeof options === 'object' && 'align' in options; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,14 +106,16 @@ module('ScrollTo', { | |
| scheduler.instance.scrollTo(new Date(2020, 8, 5)); | ||
| await waitAsync(0); | ||
|
|
||
| assert.equal(errors.log.callCount, 1, 'warning has been called once'); | ||
| assert.equal(errors.log.getCall(0).args[0], 'W1008', 'warning has correct error id'); | ||
| assert.equal(errors.log.callCount, 2, 'warnings have been called twice'); | ||
| assert.equal(errors.log.getCall(0).args[0], 'W0002', 'first warning is deprecation warning'); | ||
| assert.equal(errors.log.getCall(1).args[0], 'W1008', 'second warning has correct error id'); | ||
|
|
||
| scheduler.instance.scrollTo(new Date(2020, 8, 14)); | ||
| await waitAsync(0); | ||
|
|
||
| assert.equal(errors.log.callCount, 2, 'warning has been called once'); | ||
| assert.equal(errors.log.getCall(1).args[0], 'W1008', 'warning has correct error id'); | ||
| assert.equal(errors.log.callCount, 4, 'warnings have been called four times total'); | ||
| assert.equal(errors.log.getCall(2).args[0], 'W0002', 'third warning is deprecation warning'); | ||
| assert.equal(errors.log.getCall(3).args[0], 'W1008', 'fourth warning has correct error id'); | ||
| }); | ||
|
|
||
| test(`A warning should not be thrown when scrolling to a valid date when ${scrolling.text} is used`, async function(assert) { | ||
|
|
@@ -122,7 +124,8 @@ module('ScrollTo', { | |
| scheduler.instance.scrollTo(new Date(2020, 8, 7)); | ||
| await waitAsync(0); | ||
|
|
||
| assert.equal(errors.log.callCount, 0, 'warning has been called once'); | ||
| assert.equal(errors.log.callCount, 1, 'deprecation warning has been called once'); | ||
|
||
| assert.equal(errors.log.getCall(0).args[0], 'W0002', 'warning is deprecation warning for old API'); | ||
| }); | ||
|
|
||
| [{ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.