Skip to content

Commit b8a24e4

Browse files
authored
Scheduler: refactor core files (TS) - Part 1 (DevExpress#33826)
1 parent 17ca6d5 commit b8a24e4

17 files changed

Lines changed: 74 additions & 71 deletions

File tree

packages/devextreme/js/__internal/scheduler/appointment_popup/popup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type { Properties as SchedulerProperties } from '@js/ui/scheduler';
1919
import { current, isFluent } from '@js/ui/themes';
2020
import errors from '@js/ui/widget/ui.errors';
2121

22-
import { hide as hideLoading, show as showLoading } from '../m_loading';
22+
import { hide as hideLoading, show as showLoading } from '../loading';
2323
import type { TimeZoneCalculator } from '../r1/timezone_calculator/calculator';
2424
import type { SafeAppointment } from '../types';
2525
import { AppointmentAdapter } from '../utils/appointment_adapter/appointment_adapter';
@@ -338,7 +338,7 @@ export class AppointmentPopup {
338338

339339
return this.config.onSave(appointment);
340340
})
341-
.then(() => { hideLoading(); })
341+
.then(() => { hideLoading().catch(noop); })
342342
.catch(noop);
343343
}
344344

@@ -357,14 +357,14 @@ export class AppointmentPopup {
357357
}
358358

359359
private showLoadPanel(): void {
360-
const container = this.popupInstance?.$overlayContent();
360+
const container = this.popupInstance?.$overlayContent().get(0);
361361

362362
showLoading({
363363
container,
364364
position: {
365365
of: container,
366366
},
367-
});
367+
}).catch(noop);
368368
}
369369

370370
private tryLockSaveChanges(): boolean {

packages/devextreme/js/__internal/scheduler/appointments/appointment/agenda_appointment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import $ from '@js/core/renderer';
33

44
import {
55
APPOINTMENT_CONTENT_CLASSES,
6-
} from '../../m_classes';
6+
} from '../../classes';
77
import { Appointment } from './m_appointment';
88

99
export class AgendaAppointment extends Appointment {

packages/devextreme/js/__internal/scheduler/appointments/appointment/m_appointment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
REDUCED_APPOINTMENT_CLASS,
2323
REDUCED_APPOINTMENT_ICON,
2424
REDUCED_APPOINTMENT_PARTS_CLASSES,
25-
} from '../../m_classes';
25+
} from '../../classes';
2626
import type { SubscribeKey, SubscribeMethods } from '../../m_subscribes';
2727
import { validateRRule } from '../../recurrence/validate_rule';
2828
import type { AppointmentDataAccessor } from '../../utils/data_accessor/appointment_data_accessor';

packages/devextreme/js/__internal/scheduler/appointments/m_appointment_collection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import { dateUtilsTs } from '@ts/core/utils/date';
2020
import type { SupportedKeys } from '@ts/core/widget/widget';
2121
import CollectionWidget from '@ts/ui/collection/collection_widget.edit';
2222

23-
import { APPOINTMENT_SETTINGS_KEY } from '../constants';
2423
import {
2524
AGENDA_LAST_IN_DATE_APPOINTMENT_CLASS,
2625
APPOINTMENT_CONTENT_CLASSES,
2726
APPOINTMENT_DRAG_SOURCE_CLASS,
2827
APPOINTMENT_ITEM_CLASS,
29-
} from '../m_classes';
28+
} from '../classes';
29+
import { APPOINTMENT_SETTINGS_KEY } from '../constants';
3030
import timeZoneUtils from '../m_utils_time_zone';
3131
import type { CompactAppointmentOptions } from '../types';
3232
import { AppointmentAdapter } from '../utils/appointment_adapter/appointment_adapter';

packages/devextreme/js/__internal/scheduler/appointments/m_appointment_layout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import messageLocalization from '@js/common/core/localization/message';
22
import domAdapter from '@js/core/dom_adapter';
33
import $ from '@js/core/renderer';
44

5-
import { APPOINTMENT_CONTENT_CLASSES } from '../m_classes';
5+
import { APPOINTMENT_CONTENT_CLASSES } from '../classes';
66

77
const allDayText = ` ${messageLocalization.format('dxScheduler-allDay')}: `;
88
const recurringText = messageLocalization.format('dxScheduler-appointmentAriaLabel-recurring');

packages/devextreme/js/__internal/scheduler/m_classes.ts renamed to packages/devextreme/js/__internal/scheduler/classes.ts

File renamed without changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import $ from '@js/core/renderer';
2+
import { value as viewPort } from '@js/core/utils/view_port';
3+
import type { Properties as LoadPanelProperties } from '@js/ui/load_panel';
4+
import LoadPanel from '@js/ui/load_panel';
5+
6+
type LoadPanelInstance = InstanceType<typeof LoadPanel>;
7+
8+
let loading: LoadPanelInstance | null = null;
9+
10+
const createLoadPanel = (options?: LoadPanelProperties): LoadPanelInstance => {
11+
const $container = $('<div>').appendTo(options?.container ?? viewPort());
12+
return new LoadPanel($container.get(0), options);
13+
};
14+
15+
const removeLoadPanel = (): void => {
16+
if (!loading) {
17+
return;
18+
}
19+
20+
loading.$element().remove();
21+
loading = null;
22+
};
23+
24+
export function show(options?: LoadPanelProperties): Promise<boolean> {
25+
removeLoadPanel();
26+
loading = createLoadPanel(options);
27+
return loading.show();
28+
}
29+
30+
export function hide(): Promise<boolean | undefined> {
31+
if (!loading) {
32+
return Promise.resolve(undefined);
33+
}
34+
35+
const instance = loading;
36+
return instance.hide().then((result) => {
37+
if (loading === instance) {
38+
removeLoadPanel();
39+
}
40+
return result;
41+
});
42+
}

packages/devextreme/js/__internal/scheduler/m_loading.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/devextreme/js/__internal/scheduler/m_scheduler.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ import { Appointments } from './appointments_new/appointments';
4747
import NotifyScheduler from './base/widget_notify_scheduler';
4848
import { SchedulerHeader } from './header/header';
4949
import type { HeaderOptions } from './header/types';
50+
import { hide as hideLoading, show as showLoading } from './loading';
5051
import { CompactAppointmentsHelper } from './m_compact_appointments_helper';
51-
import { hide as hideLoading, show as showLoading } from './m_loading';
5252
import type { SubscribeKey, SubscribeMethods } from './m_subscribes';
5353
import subscribes from './m_subscribes';
5454
import { utils } from './m_utils';
@@ -689,20 +689,22 @@ class Scheduler extends SchedulerOptionsBaseWidget {
689689

690690
if (this._dataSource) {
691691
this._dataSource.load().done(() => {
692-
hideLoading();
692+
hideLoading().catch(noop);
693693

694694
this._fireContentReadyAction(result);
695695
}).fail(() => {
696-
hideLoading();
696+
hideLoading().catch(noop);
697697
result.reject();
698698
});
699699

700-
this._dataSource.isLoading() && showLoading({
701-
container: this.$element(),
702-
position: {
703-
of: this.$element(),
704-
},
705-
});
700+
if (this._dataSource.isLoading()) {
701+
showLoading({
702+
container: this.$element().get(0),
703+
position: {
704+
of: this.$element() as any,
705+
},
706+
}).catch(noop);
707+
}
706708
} else {
707709
this._fireContentReadyAction(result);
708710
}

packages/devextreme/js/__internal/scheduler/r1/utils/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import dateUtils from '@js/core/utils/date';
33
import { isDefined, isObject } from '@js/core/utils/type';
44
import { dateUtilsTs } from '@ts/core/utils/date';
55

6+
import { VERTICAL_GROUP_COUNT_CLASSES } from '../../classes';
67
import {
78
HORIZONTAL_GROUP_ORIENTATION, VERTICAL_GROUP_ORIENTATION,
89
} from '../../constants';
9-
import { VERTICAL_GROUP_COUNT_CLASSES } from '../../m_classes';
1010
import timeZoneUtils from '../../m_utils_time_zone';
1111
import type {
1212
AllDayPanelModeType,

0 commit comments

Comments
 (0)