Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const setupSchedulerTestEnvironment = ({
}: SetupSchedulerTestEnvironmentOptions = {}): void => {
jest.spyOn(logger, 'warn').mockImplementation(() => {});
DOMComponent.prototype._isVisible = jest.fn((): boolean => true);
SchedulerWorkSpace.prototype._createCrossScrollingConfig = (): {
(SchedulerWorkSpace.prototype as any).createCrossScrollingConfig = (): {
direction: string;
onScroll: jest.Mock;
onEnd: jest.Mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ describe('scheduler workspace', () => {
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
});

it(`should clear cache on _cleanView call, view: ${currentView}`, () => {
it(`should clear cache on cleanView call, view: ${currentView}`, () => {
const workspace = createWorkspace(WorkSpace, currentView);
jest.spyOn(workspace.cache, 'clear');

workspace.cache.memo('test', () => 'value');
workspace._cleanView();
(workspace as any).cleanView();

expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
expect(workspace.cache.size).toBe(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export class AppointmentPopup {
this.state.excludeInfo = config.excludeInfo;

if (!this.popup) {
const popupConfig = this._createPopupConfig();
this.popup = this._createPopup(popupConfig);
const popupConfig = this.createPopupConfig();
this.popup = this.createPopup(popupConfig);
}

this.popup.option(
'toolbarItems',
getPopupToolbarItems(
config.isToolbarVisible,
(e) => this._doneButtonClickHandler(e),
(e) => this.doneButtonClickHandler(e),
),
);

Expand All @@ -102,26 +102,26 @@ export class AppointmentPopup {
this.popup?.$element().remove();
}

_createPopup(options) {
private createPopup(options) {
const popupElement = $('<div>')
.addClass(APPOINTMENT_POPUP_CLASS)
.appendTo(this.scheduler.getElement());

return this.scheduler.createComponent(popupElement, Popup, options);
}

_createPopupConfig() {
private createPopupConfig() {
return {
...POPUP_CONFIG,
onHiding: () => this.scheduler.focus(),
contentTemplate: () => this._createPopupContent(),
onShowing: (e) => this._onShowing(e),
contentTemplate: () => this.createPopupContent(),
onShowing: (e) => this.onShowing(e),
wrapperAttr: { class: APPOINTMENT_POPUP_CLASS },
};
}

_onShowing(e) {
this._updateForm();
private onShowing(e) {
this.updateForm();

e.component.$overlayContent().attr(
'aria-label',
Expand All @@ -145,13 +145,13 @@ export class AppointmentPopup {
});
}

_createPopupContent() {
this._createForm();
private createPopupContent() {
this.createForm();
return this.form.dxForm.$element(); // TODO
}

_createFormData(rawAppointment) {
const appointment = this._createAppointmentAdapter(rawAppointment);
private createFormData(rawAppointment) {
const appointment = this.createAppointmentAdapter(rawAppointment);
const resourceManager = this.scheduler.getResourceManager();
const rawAppointmentGroupValues = getRawAppointmentGroupValues(
rawAppointment,
Expand All @@ -165,15 +165,15 @@ export class AppointmentPopup {
};
}

_createForm() {
private createForm() {
const rawAppointment = this.state.appointment.data;
const formData = this._createFormData(rawAppointment);
const formData = this.createFormData(rawAppointment);

this.form.create(this.triggerResize.bind(this), this.changeSize.bind(this), formData); // TODO
}

_isReadOnly(rawAppointment) {
const appointment = this._createAppointmentAdapter(rawAppointment);
private isReadOnly(rawAppointment) {
const appointment = this.createAppointmentAdapter(rawAppointment);

if (rawAppointment && appointment.disabled) {
return true;
Expand All @@ -186,22 +186,22 @@ export class AppointmentPopup {
return !this.scheduler.getEditingConfig().allowUpdating;
}

_createAppointmentAdapter(rawAppointment) {
private createAppointmentAdapter(rawAppointment) {
return new AppointmentAdapter(
rawAppointment,
this.scheduler.getDataAccessors(),
);
}

_updateForm() {
private updateForm() {
const { data } = this.state.appointment;
const appointment = this._createFormData(data);
const formData = this._createAppointmentAdapter(appointment)
const appointment = this.createFormData(data);
const formData = this.createAppointmentAdapter(appointment)
.clone()
.calculateDates(this.scheduler.getTimeZoneCalculator(), 'toAppointment')
.source;

this.form.readOnly = this._isReadOnly(formData);
this.form.readOnly = this.isReadOnly(formData);
this.form.updateFormData(formData);
}

Expand Down Expand Up @@ -237,7 +237,7 @@ export class AppointmentPopup {
const deferred = new Deferred();
const validation = this.form.dxForm.validate();

isShowLoadPanel && this._showLoadPanel();
isShowLoadPanel && this.showLoadPanel();

when(validation?.complete || validation).done((validation) => {
if (validation && !validation.isValid) {
Expand All @@ -247,13 +247,13 @@ export class AppointmentPopup {
}

const { repeat } = this.form.formData;
const adapter = this._createAppointmentAdapter(this.form.formData);
const adapter = this.createAppointmentAdapter(this.form.formData);
const clonedAdapter = adapter
.clone()
.calculateDates(this.scheduler.getTimeZoneCalculator(), 'fromAppointment');
const shouldClearRecurrenceRule = !repeat && Boolean(clonedAdapter.recurrenceRule);

this._addMissingDSTTime(adapter, clonedAdapter);
this.addMissingDSTTime(adapter, clonedAdapter);

if (shouldClearRecurrenceRule) {
clonedAdapter.recurrenceRule = '';
Expand Down Expand Up @@ -286,7 +286,7 @@ export class AppointmentPopup {
return deferred.promise();
}

_doneButtonClickHandler(e) {
private doneButtonClickHandler(e) {
e.cancel = true;
this.saveEditDataAsync();
}
Expand All @@ -295,10 +295,10 @@ export class AppointmentPopup {
// @ts-expect-error
const deferred = new Deferred();

if (this._tryLockSaveChanges()) {
if (this.tryLockSaveChanges()) {
when(this.saveChangesAsync(true)).done(() => {
if (this.state.lastEditData) { // TODO
const adapter = this._createAppointmentAdapter(this.state.lastEditData);
const adapter = this.createAppointmentAdapter(this.state.lastEditData);

const { startDate, endDate, allDay } = adapter;

Expand All @@ -316,7 +316,7 @@ export class AppointmentPopup {
this.state.lastEditData = null;
}

this._unlockSaveChanges();
this.unlockSaveChanges();

deferred.resolve();
});
Expand All @@ -325,7 +325,7 @@ export class AppointmentPopup {
return deferred.promise();
}

_showLoadPanel() {
private showLoadPanel() {
const container = this.popup.$overlayContent();

showLoading({
Expand All @@ -336,38 +336,38 @@ export class AppointmentPopup {
});
}

_tryLockSaveChanges() {
private tryLockSaveChanges() {
if (this.state.saveChangesLocker === false) {
this.state.saveChangesLocker = true;
return true;
}
return false;
}

_unlockSaveChanges() {
private unlockSaveChanges() {
this.state.saveChangesLocker = false;
}

// NOTE: Fix ticket T1102713
_addMissingDSTTime(formAppointmentAdapter, clonedAppointmentAdapter) {
private addMissingDSTTime(formAppointmentAdapter, clonedAppointmentAdapter) {
const timeZoneCalculator = this.scheduler.getTimeZoneCalculator();

clonedAppointmentAdapter.startDate = this._addMissingDSTShiftToDate(
clonedAppointmentAdapter.startDate = this.addMissingDSTShiftToDate(
timeZoneCalculator,
formAppointmentAdapter.startDate,
clonedAppointmentAdapter.startDate,
);

if (clonedAppointmentAdapter.endDate) {
clonedAppointmentAdapter.endDate = this._addMissingDSTShiftToDate(
clonedAppointmentAdapter.endDate = this.addMissingDSTShiftToDate(
timeZoneCalculator,
formAppointmentAdapter.endDate,
clonedAppointmentAdapter.endDate,
);
}
}

_addMissingDSTShiftToDate(timeZoneCalculator, originFormDate, clonedDate) {
private addMissingDSTShiftToDate(timeZoneCalculator, originFormDate, clonedDate) {
const originTimezoneShift = timeZoneCalculator.getOffsets(originFormDate)?.common;
const clonedTimezoneShift = timeZoneCalculator.getOffsets(clonedDate)?.common;
const shiftDifference = originTimezoneShift - clonedTimezoneShift;
Expand Down
22 changes: 11 additions & 11 deletions packages/devextreme/js/__internal/scheduler/header/m_calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ const CALENDAR_CLASS = 'dx-scheduler-navigator-calendar';
const CALENDAR_POPOVER_CLASS = 'dx-scheduler-navigator-calendar-popover';

export default class SchedulerCalendar extends Widget<HeaderCalendarOptions> {
_overlay?: Popup | Popover;
private overlay?: Popup | Popover;

_calendar?: Calendar;
private calendar?: Calendar;

public async show(target: HTMLElement): Promise<void> {
if (!SchedulerCalendar._isMobileLayout()) {
this._overlay?.option('target', target);
this.overlay?.option('target', target);
}

await this._overlay?.show();
await this.overlay?.show();
}

public async hide(): Promise<void> {
await this._overlay?.hide();
await this.overlay?.hide();
}

public _keyboardHandler(opts: KeyboardKeyDownEvent): boolean {
return this._calendar?._keyboardHandler(opts) ?? false;
return this.calendar?._keyboardHandler(opts) ?? false;
}

public _init(): void {
Expand All @@ -55,7 +55,7 @@ export default class SchedulerCalendar extends Widget<HeaderCalendarOptions> {
const overlayConfig = {
contentTemplate: (): dxElementWrapper => this._createOverlayContent(),
onShown: (): void => {
this._calendar?.focus();
this.calendar?.focus();
},
defaultOptionsRules: [
{
Expand All @@ -73,15 +73,15 @@ export default class SchedulerCalendar extends Widget<HeaderCalendarOptions> {
};

if (isMobileLayout) {
this._overlay = this._createComponent(this.$element(), Popup, overlayConfig);
this.overlay = this._createComponent(this.$element(), Popup, overlayConfig);
} else {
this._overlay = this._createComponent(this.$element(), Popover, overlayConfig);
this.overlay = this._createComponent(this.$element(), Popover, overlayConfig);
}
}

private _createOverlayContent(): dxElementWrapper {
const result = $('<div>').addClass(CALENDAR_CLASS);
this._calendar = this._createComponent(result, Calendar, this._getCalendarOptions());
this.calendar = this._createComponent(result, Calendar, this._getCalendarOptions());

if (SchedulerCalendar._isMobileLayout()) {
const scrollable = this._createScrollable(result);
Expand All @@ -108,7 +108,7 @@ export default class SchedulerCalendar extends Widget<HeaderCalendarOptions> {

switch (name) {
case 'value':
this._calendar?.option('value', value);
this.calendar?.option('value', value);
break;
default:
break;
Expand Down
Loading
Loading