From 7c0aca3c5edfcdf8db21fdf67d3b1f97e7662464 Mon Sep 17 00:00:00 2001 From: Anton Sermyazhko Date: Thu, 25 Nov 2021 17:28:54 +0300 Subject: [PATCH] Refactoring - Remove extra viewStartDayHour, viewEndDayHour --- .../ui/scheduler/model/__tests__/appointments.test.ts | 2 -- js/renovation/ui/scheduler/model/appointments.ts | 2 -- js/renovation/ui/scheduler/model/types.ts | 2 -- js/ui/scheduler/appointments.layout_manager.js | 6 ++---- .../scheduler/appointments/cellPositionCalculator.js | 8 ++++---- .../rendering_strategies/strategy.base.js | 4 +--- js/ui/scheduler/appointments/settingsGenerator.js | 11 +++++------ js/ui/scheduler/workspaces/ui.scheduler.work_space.js | 2 -- 8 files changed, 12 insertions(+), 25 deletions(-) diff --git a/js/renovation/ui/scheduler/model/__tests__/appointments.test.ts b/js/renovation/ui/scheduler/model/__tests__/appointments.test.ts index 4543c2bfd9a8..80c890802b5b 100644 --- a/js/renovation/ui/scheduler/model/__tests__/appointments.test.ts +++ b/js/renovation/ui/scheduler/model/__tests__/appointments.test.ts @@ -112,9 +112,7 @@ describe('Appointments model', () => { adaptivityEnabled: false, rtlEnabled: undefined, startDayHour: 0, - viewStartDayHour: 0, // TODO remove endDayHour: 24, - viewEndDayHour: 24, // TODO remove resources: [], maxAppointmentsPerCell: 'auto', currentDate: new Date('2021-09-22T00:00:00'), diff --git a/js/renovation/ui/scheduler/model/appointments.ts b/js/renovation/ui/scheduler/model/appointments.ts index bdcaa323db30..4546fc50e8ee 100644 --- a/js/renovation/ui/scheduler/model/appointments.ts +++ b/js/renovation/ui/scheduler/model/appointments.ts @@ -100,9 +100,7 @@ export const getAppointmentsConfig = ( timeZone: schedulerConfig.timeZone, groups: schedulerConfig.groups, startDayHour: viewConfig.startDayHour, - viewStartDayHour: viewConfig.startDayHour, // TODO remove endDayHour: viewConfig.endDayHour, - viewEndDayHour: viewConfig.endDayHour, // TODO remove currentDate: viewConfig.currentDate, isVirtualScrolling: viewConfig.scrolling.mode === 'virtual', intervalCount: viewConfig.intervalCount, diff --git a/js/renovation/ui/scheduler/model/types.ts b/js/renovation/ui/scheduler/model/types.ts index 228412751eb1..8b22a9151500 100644 --- a/js/renovation/ui/scheduler/model/types.ts +++ b/js/renovation/ui/scheduler/model/types.ts @@ -7,9 +7,7 @@ export interface AppointmentsConfigType { adaptivityEnabled: boolean; rtlEnabled?: boolean; startDayHour: number; - viewStartDayHour: number; endDayHour: number; - viewEndDayHour: number; currentDate: Date; resources: ResourceProps[]; maxAppointmentsPerCell: number | 'auto' | 'unlimited'; diff --git a/js/ui/scheduler/appointments.layout_manager.js b/js/ui/scheduler/appointments.layout_manager.js index 8bbcdd4db894..68a207dcf9a2 100644 --- a/js/ui/scheduler/appointments.layout_manager.js +++ b/js/ui/scheduler/appointments.layout_manager.js @@ -69,8 +69,8 @@ class AppointmentLayoutManager { appointmentRenderingStrategyName: this.appointmentRenderingStrategyName, adaptivityEnabled: this.modelProvider.adaptivityEnabled, rtlEnabled: this.modelProvider.rtlEnabled, - startDayHour: this.modelProvider.startDayHour, - endDayHour: this.modelProvider.endDayHour, + startDayHour: workspace.option('startDayHour'), + endDayHour: workspace.option('endDayHour'), maxAppointmentsPerCell: this.modelProvider.maxAppointmentsPerCell, currentDate: this.modelProvider.currentDate, isVirtualScrolling: this.instance.isVirtualScrolling(), @@ -98,8 +98,6 @@ class AppointmentLayoutManager { timeZoneCalculator: getTimeZoneCalculator(key), timeZone: this.modelProvider.timeZone, firstDayOfWeek: this.instance.getFirstDayOfWeek(), - viewStartDayHour: this.modelProvider.getCurrentViewOption('startDayHour'), - viewEndDayHour: this.modelProvider.getCurrentViewOption('endDayHour'), viewType: workspace.type, endViewDate: workspace.getEndViewDate(), positionHelper, diff --git a/js/ui/scheduler/appointments/cellPositionCalculator.js b/js/ui/scheduler/appointments/cellPositionCalculator.js index 7b628c2abcd5..f91ce7d38b0a 100644 --- a/js/ui/scheduler/appointments/cellPositionCalculator.js +++ b/js/ui/scheduler/appointments/cellPositionCalculator.js @@ -11,8 +11,8 @@ class BaseStrategy { get viewDataProvider() { return this.options.viewDataProvider; } get positionHelper() { return this.options.positionHelper; } get startViewDate() { return this.options.startViewDate; } - get viewStartDayHour() { return this.options.viewStartDayHour; } - get viewEndDayHour() { return this.options.viewEndDayHour; } + get startDayHour() { return this.options.startDayHour; } + get endDayHour() { return this.options.endDayHour; } get cellDuration() { return this.options.cellDuration; } get getPositionShift() { return this.options.getPositionShiftCallback; } get groupCount() { return this.options.groupCount; } @@ -171,10 +171,10 @@ class BaseStrategy { getTimeShift(date) { const currentDayStart = new Date(date); - const currentDayEndHour = new Date(new Date(date).setHours(this.viewEndDayHour, 0, 0)); + const currentDayEndHour = new Date(new Date(date).setHours(this.endDayHour, 0, 0)); if(date.getTime() <= currentDayEndHour.getTime()) { - currentDayStart.setHours(this.viewStartDayHour, 0, 0, 0); + currentDayStart.setHours(this.startDayHour, 0, 0, 0); } const timeZoneDifference = dateUtils.getTimezonesDifference(date, currentDayStart); diff --git a/js/ui/scheduler/appointments/rendering_strategies/strategy.base.js b/js/ui/scheduler/appointments/rendering_strategies/strategy.base.js index e8639a2e21fe..dba01417ebc1 100644 --- a/js/ui/scheduler/appointments/rendering_strategies/strategy.base.js +++ b/js/ui/scheduler/appointments/rendering_strategies/strategy.base.js @@ -40,8 +40,6 @@ class BaseRenderingStrategy { get resizableStep() { return this.options.resizableStep; } get isGroupedByDate() { return this.options.isGroupedByDate; } get visibleDayDuration() { return this.options.visibleDayDuration; } - get viewStartDayHour() { return this.options.viewStartDayHour; } - get viewEndDayHour() { return this.options.viewEndDayHour; } get cellDuration() { return this.options.cellDuration; } get cellDurationInMinutes() { return this.options.cellDurationInMinutes; } get leftVirtualCellCount() { return this.options.leftVirtualCellCount; } @@ -245,7 +243,7 @@ class BaseRenderingStrategy { isAppointmentTakesAllDay(rawAppointment) { const adapter = createAppointmentAdapter(rawAppointment, this.dataAccessors, this.timeZoneCalculator); - return getAppointmentTakesAllDay(adapter, this.viewStartDayHour, this.viewEndDayHour); + return getAppointmentTakesAllDay(adapter, this.startDayHour, this.endDayHour); } _getAppointmentParts() { diff --git a/js/ui/scheduler/appointments/settingsGenerator.js b/js/ui/scheduler/appointments/settingsGenerator.js index f7dbab6de265..d2872d9bcdb1 100644 --- a/js/ui/scheduler/appointments/settingsGenerator.js +++ b/js/ui/scheduler/appointments/settingsGenerator.js @@ -28,8 +28,8 @@ export class DateGeneratorBaseStrategy { get timeZone() { return this.options.timeZone; } get dateRange() { return this.options.dateRange; } get firstDayOfWeek() { return this.options.firstDayOfWeek; } - get viewStartDayHour() { return this.options.viewStartDayHour; } - get viewEndDayHour() { return this.options.viewEndDayHour; } + get startDayHour() { return this.options.startDayHour; } + get endDayHour() { return this.options.endDayHour; } get endViewDate() { return this.options.endViewDate; } get viewType() { return this.options.viewType; } get isGroupedByDate() { return this.options.isGroupedByDate; } @@ -224,11 +224,10 @@ export class DateGeneratorBaseStrategy { } } - const endDayHour = this.viewEndDayHour; const allDay = ExpressionUtils.getField(this.dataAccessors, 'allDay', rawAppointment); - const currentViewEndTime = new Date(new Date(endDate.getTime()).setHours(endDayHour, 0, 0, 0)); + const currentViewEndTime = new Date(new Date(endDate.getTime()).setHours(this.endDayHour, 0, 0, 0)); - if(result.getTime() > currentViewEndTime.getTime() || (allDay && result.getHours() < endDayHour)) { + if(result.getTime() > currentViewEndTime.getTime() || (allDay && result.getHours() < this.endDayHour)) { result = currentViewEndTime; } @@ -400,7 +399,7 @@ export class DateGeneratorBaseStrategy { } _getViewStartDayHour() { - return this.viewStartDayHour; + return this.startDayHour; } _getAppointmentResultDate(options) { const { diff --git a/js/ui/scheduler/workspaces/ui.scheduler.work_space.js b/js/ui/scheduler/workspaces/ui.scheduler.work_space.js index ddd72bf35026..4e054be0dcac 100644 --- a/js/ui/scheduler/workspaces/ui.scheduler.work_space.js +++ b/js/ui/scheduler/workspaces/ui.scheduler.work_space.js @@ -2229,8 +2229,6 @@ class SchedulerWorkSpace extends WidgetObserver { this.positionHelper = new PositionHelper({ key: this.option('key'), viewDataProvider: this.viewDataProvider, - viewStartDayHour: this.option('startDayHour'), - viewEndDayHour: this.option('endDayHour'), cellDuration: this.getCellDuration(), groupedStrategy: this._groupedStrategy, isGroupedByDate: this.isGroupedByDate(),