Skip to content

Commit 09cc24b

Browse files
committed
fix
1 parent 9b5be94 commit 09cc24b

4 files changed

Lines changed: 79 additions & 22 deletions

File tree

packages/devextreme/js/__internal/scheduler/view_model/generate_view_model/add_collector.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export const addCollector = (
8282
...item,
8383
info: {
8484
sourceAppointment: item.info.sourceAppointment,
85-
appointment: item.info.appointment,
85+
appointment: {
86+
...item.info.appointment,
87+
startDate: item.info.appointment.savedBeforeSplit.startDate,
88+
endDate: item.info.appointment.savedBeforeSplit.endDate,
89+
},
8690
},
8791
})).forEach((item) => {
8892
switch (true) {

packages/devextreme/js/__internal/scheduler/view_model/generate_view_model/m_settings_generator.ts

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,48 @@ export class DateGeneratorBaseStrategy {
7979
const { isRecurrent } = appointmentAdapter;
8080

8181
const itemGroupIndices = this._getGroupIndices(this.rawAppointment);
82+
let dateSettings;
8283

83-
let sourceList = this._createAppointments(appointmentAdapter, itemGroupIndices);
84-
sourceList = this.excludeLocalDST(sourceList, appointmentAdapter);
85-
sourceList = this._getProcessedByAppointmentTimeZone(sourceList, appointmentAdapter); // T983264
84+
if (appointmentAdapter.isRecurrent && appointmentAdapter.startDateTimeZone) {
85+
let sourceList = this._createAppointments(appointmentAdapter, itemGroupIndices);
86+
sourceList = this.excludeLocalDST(sourceList, appointmentAdapter);
87+
sourceList = this._getProcessedByAppointmentTimeZone(sourceList, appointmentAdapter); // T983264
8688

87-
if (appointmentAdapter.isRecurrent && appointmentAdapter.recurrenceException) {
88-
const exceptions = new Set(appointmentAdapter.recurrenceException?.split(','));
89-
sourceList = sourceList
90-
.filter((item) => !exceptions.has(getAsciiStringByDate(item.startDate)));
91-
}
89+
if (appointmentAdapter.isRecurrent && appointmentAdapter.recurrenceException) {
90+
const exceptions = new Set(appointmentAdapter.recurrenceException?.split(','));
91+
sourceList = sourceList
92+
.filter((item) => !exceptions.has(getAsciiStringByDate(item.startDate)));
93+
}
94+
95+
let appointmentList = sourceList;
96+
if (appointmentAdapter.isRecurrent && (
97+
!this.timeZone
98+
|| timeZoneUtils.isEqualLocalTimeZone(this.timeZone)
99+
)) {
100+
appointmentList = this._getProcessedNativeTimezoneDates(appointmentList, appointmentAdapter);
101+
}
102+
103+
dateSettings = this._createGridAppointmentList(appointmentList, sourceList, appointmentAdapter);
104+
} else {
105+
let appointmentList = this._createAppointments(appointmentAdapter, itemGroupIndices);
106+
107+
appointmentList = this._getProcessedByAppointmentTimeZone(appointmentList, appointmentAdapter); // T983264
92108

93-
let appointmentList = sourceList;
94-
if (appointmentAdapter.isRecurrent && (
95-
!this.timeZone
96-
|| timeZoneUtils.isEqualLocalTimeZone(this.timeZone)
97-
)) {
98-
appointmentList = this._getProcessedNativeTimezoneDates(appointmentList, appointmentAdapter);
109+
if (this._canProcessNotNativeTimezoneDates(appointmentAdapter)) {
110+
appointmentList = this._getProcessedNotNativeTimezoneDates(appointmentList, appointmentAdapter);
111+
}
112+
113+
appointmentList = this.excludeLocalDST(appointmentList, appointmentAdapter);
114+
dateSettings = this._createGridAppointmentList(appointmentList, appointmentList, appointmentAdapter);
99115
}
100116

101-
let dateSettings = this._createGridAppointmentList(appointmentList, sourceList, appointmentAdapter);
117+
dateSettings = dateSettings.map((item) => ({
118+
...item,
119+
savedBeforeSplit: {
120+
startDate: new Date(item.startDate),
121+
endDate: new Date(item.endDate),
122+
},
123+
}));
102124

103125
const firstViewDates = this._getAppointmentsFirstViewDate(dateSettings);
104126

@@ -161,6 +183,36 @@ export class DateGeneratorBaseStrategy {
161183
return appointmentList;
162184
}
163185

186+
_getProcessedNotNativeTimezoneDates(appointmentList, appointment) {
187+
return appointmentList.map((item) => {
188+
let diffStartDateOffset = this._getCommonOffset(appointment.startDate) - this._getCommonOffset(item.startDate);
189+
let diffEndDateOffset = this._getCommonOffset(appointment.endDate) - this._getCommonOffset(item.endDate);
190+
191+
if (diffStartDateOffset === 0 && diffEndDateOffset === 0) {
192+
return item;
193+
}
194+
195+
diffStartDateOffset = this._getProcessedNotNativeDateIfCrossDST(item.startDate, diffStartDateOffset);
196+
diffEndDateOffset = this._getProcessedNotNativeDateIfCrossDST(item.endDate, diffEndDateOffset);
197+
198+
const newStartDate = new Date(item.startDate.getTime() + diffStartDateOffset * toMs('hour'));
199+
let newEndDate = new Date(item.endDate.getTime() + diffEndDateOffset * toMs('hour'));
200+
201+
const testNewStartDate = this.timeZoneCalculator.createDate(newStartDate, 'toGrid');
202+
const testNewEndDate = this.timeZoneCalculator.createDate(newEndDate, 'toGrid');
203+
204+
if (appointment.duration > testNewEndDate.getTime() - testNewStartDate.getTime()) {
205+
newEndDate = new Date(newStartDate.getTime() + appointment.duration);
206+
}
207+
208+
return {
209+
...item,
210+
startDate: newStartDate,
211+
endDate: newEndDate,
212+
};
213+
});
214+
}
215+
164216
_createAppointments(appointment, groupIndices) {
165217
let appointments = this._createRecurrenceAppointments(appointment, groupIndices);
166218

packages/devextreme/js/__internal/scheduler/view_model/generate_view_model/m_view_model_generator.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ export class AppointmentViewModelGenerator {
108108
for (const model of viewModel) {
109109
// eslint-disable-next-line no-restricted-syntax
110110
for (const setting of model.settings ?? []) {
111-
const appointment = setting?.info?.appointment as {
112-
startDate: Date;
113-
endDate: Date;
114-
normalizedEndDate: Date;
115-
} | undefined;
111+
const appointment = setting?.info?.appointment as any | undefined;
116112

117113
if (appointment && !processedAppointments.has(appointment)) {
118114
appointment.startDate = dateUtilsTs

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export interface AppointmentViewModelSettingsInternal extends BaseViewModelSetti
3131
count: number;
3232
info: {
3333
sourceAppointment: SimpleAppointment;
34-
appointment: SimpleAppointment;
34+
appointment: SimpleAppointment & {
35+
savedBeforeSplit: {
36+
startDate: Date;
37+
endDate: Date;
38+
};
39+
};
3540
};
3641
positionByMap: {
3742
rowIndex: number;

0 commit comments

Comments
 (0)