Skip to content

Commit

Permalink
Refactoring - Remove extra viewStartDayHour, viewEndDayHour
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonSermyazhko committed Nov 25, 2021
1 parent af04ec7 commit 7c0aca3
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 0 additions & 2 deletions js/renovation/ui/scheduler/model/appointments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions js/renovation/ui/scheduler/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 2 additions & 4 deletions js/ui/scheduler/appointments.layout_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions js/ui/scheduler/appointments/cellPositionCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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() {
Expand Down
11 changes: 5 additions & 6 deletions js/ui/scheduler/appointments/settingsGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -400,7 +399,7 @@ export class DateGeneratorBaseStrategy {
}

_getViewStartDayHour() {
return this.viewStartDayHour;
return this.startDayHour;
}
_getAppointmentResultDate(options) {
const {
Expand Down
2 changes: 0 additions & 2 deletions js/ui/scheduler/workspaces/ui.scheduler.work_space.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 7c0aca3

Please sign in to comment.