Skip to content

Commit

Permalink
Scheduler: Revert of the T1167123 fix (#25851)
Browse files Browse the repository at this point in the history
Co-authored-by: Ilya Vinogradov <[email protected]>
  • Loading branch information
williamvinogradov and Ilya Vinogradov authored Oct 23, 2023
1 parent d80c71f commit b9fa71a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const APPOINTMENT_FORM_GROUP_NAMES = {

const getStylingModeFunc = (): string | undefined => (isFluent(current()) ? 'filled' : undefined);

const getDateWithStartHour = (date, startDayHour) => new Date(new Date(date).setHours(startDayHour));
const getStartDateWithStartHour = (startDate, startDayHour) => new Date(new Date(startDate).setHours(startDayHour));

const validateAppointmentFormDate = (editor, value, previousValue) => {
const isCurrentDateCorrect = value === null || !!value;
Expand Down Expand Up @@ -310,20 +310,17 @@ export class AppointmentForm {
const startDateEditor = this.form.getEditor(dataExprs.startDateExpr);
const endDateEditor = this.form.getEditor(dataExprs.endDateExpr);
const startDate = dateSerialization.deserializeDate(startDateEditor.option('value'));
const endDate = dateSerialization.deserializeDate(endDateEditor.option('value'));

if (this.semaphore.isFree() && startDate) {
if (value) {
const allDayStartDate = dateUtils.trimTime(startDate);
const allDayEndDate = dateUtils.trimTime(endDate);
startDateEditor.option('value', new Date(allDayStartDate));
endDateEditor.option('value', new Date(allDayEndDate));
endDateEditor.option('value', new Date(allDayStartDate));
} else {
const startDateWithStartHour = getDateWithStartHour(startDate, this.scheduler.getStartDayHour());
const endDateWithStartHour = getDateWithStartHour(endDate, this.scheduler.getStartDayHour());
const calculatedEndDate = this.scheduler.getCalculatedEndDate(endDateWithStartHour);
const startDateWithStartHour = getStartDateWithStartHour(startDate, this.scheduler.getStartDayHour());
const endDate = this.scheduler.getCalculatedEndDate(startDateWithStartHour);
startDateEditor.option('value', startDateWithStartHour);
endDateEditor.option('value', calculatedEndDate);
endDateEditor.option('value', endDate);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/scheduler/m_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ class Scheduler extends Widget<any> {

getFirstDayOfWeek: () => this.option('firstDayOfWeek'),
getStartDayHour: () => this.option('startDayHour'),
getCalculatedEndDate: (date) => this._workSpace.calculateEndDate(date),
getCalculatedEndDate: (startDateWithStartHour) => this._workSpace.calculateEndDate(startDateWithStartHour),
getTimeZoneCalculator: () => this.timeZoneCalculator,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ QUnit.module('Appointment Popup Content', moduleOptions, () => {
assert.equal(allDayEditor.option('value'), true, 'value is right');
});

QUnit.test('allDay changing should switch type, but not date in editors', function(assert) {
QUnit.test('allDay changing should switch date & type in editors', function(assert) {
const scheduler = createInstance({
startDayHour: 5,
});
Expand All @@ -1211,15 +1211,15 @@ QUnit.module('Appointment Popup Content', moduleOptions, () => {
assert.deepEqual(startDate.option('value'), new Date(2015, 1, 1), 'value is right');
assert.equal(startDate.option('type'), 'date', 'type is right');

assert.deepEqual(endDate.option('value'), new Date(2015, 1, 2), 'value is right');
assert.deepEqual(endDate.option('value'), new Date(2015, 1, 1), 'value is right');
assert.equal(endDate.option('type'), 'date', 'type is right');

allDayEditor.option('value', false);

assert.equal(startDate.option('type'), 'datetime', 'type is right after turning off allDay');
assert.equal(endDate.option('type'), 'datetime', 'type is right after turning off allDay');
assert.deepEqual(startDate.option('value'), new Date(2015, 1, 1, 5), 'startdate is OK');
assert.deepEqual(endDate.option('value'), new Date(2015, 1, 2, 5, 30), 'enddate is OK');
assert.deepEqual(endDate.option('value'), new Date(2015, 1, 1, 5, 30), 'enddate is OK');
});

QUnit.test('allDay changing should switch only type in editors, if startDate is undefined', function(assert) {
Expand Down

0 comments on commit b9fa71a

Please sign in to comment.