UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

1,091 lines (1,089 loc) • 95.4 kB
/** * DevExtreme (cjs/__internal/scheduler/m_scheduler.js) * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _visibility_change = require("../../common/core/events/visibility_change"); var _date = _interopRequireDefault(require("../../common/core/localization/date")); var _message = _interopRequireDefault(require("../../common/core/localization/message")); var _component_registrator = _interopRequireDefault(require("../../core/component_registrator")); var _config = _interopRequireDefault(require("../../core/config")); var _devices = _interopRequireDefault(require("../../core/devices")); var _element = require("../../core/element"); var _renderer = _interopRequireDefault(require("../../core/renderer")); var _bindable_template = require("../../core/templates/bindable_template"); var _empty_template = require("../../core/templates/empty_template"); var _callbacks = _interopRequireDefault(require("../../core/utils/callbacks")); var _common = require("../../core/utils/common"); var _data = require("../../core/utils/data"); var _date2 = _interopRequireDefault(require("../../core/utils/date")); var _date_serialization = _interopRequireDefault(require("../../core/utils/date_serialization")); var _deferred = require("../../core/utils/deferred"); var _extend = require("../../core/utils/extend"); var _iterator = require("../../core/utils/iterator"); var _position = require("../../core/utils/position"); var _type = require("../../core/utils/type"); var _window = require("../../core/utils/window"); var _data_helper = _interopRequireDefault(require("../../data_helper")); var _dialog = require("../../ui/dialog"); var _themes = require("../../ui/themes"); var _ui = _interopRequireDefault(require("../../ui/widget/ui.errors")); var _ui2 = _interopRequireDefault(require("../../ui/widget/ui.widget")); var _date3 = require("../core/utils/date"); var _index = require("../scheduler/r1/timezone_calculator/index"); var _index2 = require("../scheduler/r1/utils/index"); var _index3 = require("../scheduler/utils/index"); var _m_form = require("./appointment_popup/m_form"); var _m_popup = require("./appointment_popup/m_popup"); var _m_appointment_data_provider = require("./appointments/data_provider/m_appointment_data_provider"); var _m_appointment_collection = _interopRequireDefault(require("./appointments/m_appointment_collection")); var _m_header = require("./header/m_header"); var _m_appointment_adapter = require("./m_appointment_adapter"); var _m_appointments_layout_manager = _interopRequireDefault(require("./m_appointments_layout_manager")); var _m_compact_appointments_helper = require("./m_compact_appointments_helper"); var _m_constants = require("./m_constants"); var _m_data_structures = require("./m_data_structures"); var _m_expression_utils = require("./m_expression_utils"); var _m_loading = require("./m_loading"); var _m_recurrence = require("./m_recurrence"); var _m_subscribes = _interopRequireDefault(require("./m_subscribes")); var _m_utils = require("./m_utils"); var _m_utils_time_zone = _interopRequireDefault(require("./m_utils_time_zone")); var _index4 = require("./options_validator/index"); var _m_agenda_resource_processor = require("./resources/m_agenda_resource_processor"); var _m_utils2 = require("./resources/m_utils"); var _m_desktop_tooltip_strategy = require("./tooltip_strategies/m_desktop_tooltip_strategy"); var _m_mobile_tooltip_strategy = require("./tooltip_strategies/m_mobile_tooltip_strategy"); var _m_agenda = _interopRequireDefault(require("./workspaces/m_agenda")); var _m_timeline_day = _interopRequireDefault(require("./workspaces/m_timeline_day")); var _m_timeline_month = _interopRequireDefault(require("./workspaces/m_timeline_month")); var _m_timeline_week = _interopRequireDefault(require("./workspaces/m_timeline_week")); var _m_timeline_work_week = _interopRequireDefault(require("./workspaces/m_timeline_work_week")); var _m_work_space_day = _interopRequireDefault(require("./workspaces/m_work_space_day")); var _m_work_space_month = _interopRequireDefault(require("./workspaces/m_work_space_month")); var _m_work_space_week = _interopRequireDefault(require("./workspaces/m_work_space_week")); var _m_work_space_work_week = _interopRequireDefault(require("./workspaces/m_work_space_work_week")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } function _extends() { return _extends = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]) } } return n }, _extends.apply(null, arguments) } const toMs = _date2.default.dateToMilliseconds; const DEFAULT_AGENDA_DURATION = 7; const WIDGET_CLASS = "dx-scheduler"; const WIDGET_SMALL_CLASS = `${WIDGET_CLASS}-small`; const WIDGET_ADAPTIVE_CLASS = `${WIDGET_CLASS}-adaptive`; const WIDGET_READONLY_CLASS = `${WIDGET_CLASS}-readonly`; const WIDGET_SMALL_WIDTH = 400; const FULL_DATE_FORMAT = "yyyyMMddTHHmmss"; const UTC_FULL_DATE_FORMAT = `${FULL_DATE_FORMAT}Z`; const DEFAULT_APPOINTMENT_TEMPLATE_NAME = "item"; const DEFAULT_APPOINTMENT_COLLECTOR_TEMPLATE_NAME = "appointmentCollector"; const DEFAULT_DROP_DOWN_APPOINTMENT_TEMPLATE_NAME = "dropDownAppointment"; const VIEWS_CONFIG = { day: { workSpace: _m_work_space_day.default, renderingStrategy: "vertical" }, week: { workSpace: _m_work_space_week.default, renderingStrategy: "vertical" }, workWeek: { workSpace: _m_work_space_work_week.default, renderingStrategy: "vertical" }, month: { workSpace: _m_work_space_month.default, renderingStrategy: "horizontalMonth" }, timelineDay: { workSpace: _m_timeline_day.default, renderingStrategy: "horizontal" }, timelineWeek: { workSpace: _m_timeline_week.default, renderingStrategy: "horizontal" }, timelineWorkWeek: { workSpace: _m_timeline_work_week.default, renderingStrategy: "horizontal" }, timelineMonth: { workSpace: _m_timeline_month.default, renderingStrategy: "horizontalMonthLine" }, agenda: { workSpace: _m_agenda.default, renderingStrategy: "agenda" } }; const StoreEventNames = { ADDING: "onAppointmentAdding", ADDED: "onAppointmentAdded", DELETING: "onAppointmentDeleting", DELETED: "onAppointmentDeleted", UPDATING: "onAppointmentUpdating", UPDATED: "onAppointmentUpdated" }; const RECURRENCE_EDITING_MODE = { SERIES: "editSeries", OCCURENCE: "editOccurence", CANCEL: "cancel" }; class Scheduler extends _ui2.default { _getDefaultOptions() { const defaultOptions = (0, _extend.extend)(super._getDefaultOptions(), { views: ["day", "week"], currentView: "day", currentDate: _date2.default.trimTime(new Date), min: void 0, max: void 0, dateSerializationFormat: void 0, firstDayOfWeek: void 0, groups: [], resources: [], loadedResources: [], resourceLoaderMap: new Map, dataSource: null, customizeDateNavigatorText: void 0, appointmentTemplate: "item", dropDownAppointmentTemplate: "dropDownAppointment", appointmentCollectorTemplate: "appointmentCollector", dataCellTemplate: null, timeCellTemplate: null, resourceCellTemplate: null, dateCellTemplate: null, startDayHour: 0, endDayHour: 24, offset: 0, editing: { allowAdding: true, allowDeleting: true, allowDragging: true, allowResizing: true, allowUpdating: true, allowTimeZoneEditing: false }, showAllDayPanel: true, showCurrentTimeIndicator: true, shadeUntilCurrentTime: false, indicatorUpdateInterval: 3e5, indicatorTime: void 0, recurrenceEditMode: "dialog", cellDuration: 30, maxAppointmentsPerCell: "auto", selectedCellData: [], groupByDate: false, onAppointmentRendered: null, onAppointmentClick: null, onAppointmentDblClick: null, onAppointmentContextMenu: null, onCellClick: null, onCellContextMenu: null, onAppointmentAdding: null, onAppointmentAdded: null, onAppointmentUpdating: null, onAppointmentUpdated: null, onAppointmentDeleting: null, onAppointmentDeleted: null, onAppointmentFormOpening: null, onAppointmentTooltipShowing: null, appointmentTooltipTemplate: "appointmentTooltip", appointmentPopupTemplate: "appointmentPopup", crossScrollingEnabled: false, useDropDownViewSwitcher: false, startDateExpr: "startDate", endDateExpr: "endDate", textExpr: "text", descriptionExpr: "description", allDayExpr: "allDay", recurrenceRuleExpr: "recurrenceRule", recurrenceExceptionExpr: "recurrenceException", disabledExpr: "disabled", remoteFiltering: false, timeZone: "", startDateTimeZoneExpr: "startDateTimeZone", endDateTimeZoneExpr: "endDateTimeZone", noDataText: _message.default.format("dxCollectionWidget-noDataText"), adaptivityEnabled: false, allowMultipleCellSelection: true, scrolling: { mode: "standard" }, allDayPanelMode: "all", renovateRender: true, _draggingMode: "outlook", _appointmentTooltipOffset: { x: 0, y: 0 }, _appointmentTooltipButtonsPosition: "bottom", _appointmentTooltipOpenButtonText: _message.default.format("dxScheduler-openAppointment"), _appointmentCountPerCell: 2, _collectorOffset: 0, _appointmentOffset: 26, toolbar: [{ location: "before", defaultElement: "dateNavigator" }, { location: "after", defaultElement: "viewSwitcher" }] }); return (0, _extend.extend)(true, defaultOptions, { integrationOptions: { useDeferUpdateForTemplates: false } }) } get filteredItems() { if (!this._filteredItems) { this._filteredItems = [] } return this._filteredItems } set filteredItems(value) { this._filteredItems = value } get preparedItems() { if (!this._preparedItems) { this._preparedItems = [] } return this._preparedItems } set preparedItems(value) { this._preparedItems = value } get currentView() { return _index2.viewsUtils.getCurrentView(this.option("currentView"), this.option("views")) } get currentViewType() { return (0, _type.isObject)(this.currentView) ? this.currentView.type : this.currentView } get timeZoneCalculator() { if (!this._timeZoneCalculator) { this._timeZoneCalculator = (0, _index.createTimeZoneCalculator)(this.option("timeZone")) } return this._timeZoneCalculator } _setDeprecatedOptions() { super._setDeprecatedOptions(); (0, _extend.extend)(this._deprecatedOptions, { dropDownAppointmentTemplate: { since: "19.2", message: "appointmentTooltipTemplate" } }) } _defaultOptionsRules() { return super._defaultOptionsRules().concat([{ device: () => "desktop" === _devices.default.real().deviceType && !_devices.default.isSimulator(), options: { focusStateEnabled: true } }, { device: () => !_devices.default.current().generic, options: { useDropDownViewSwitcher: true, editing: { allowDragging: false, allowResizing: false } } }, { device: () => (0, _themes.isMaterialBased)(), options: { useDropDownViewSwitcher: true, dateCellTemplate(data, index, element) { const { text: text } = data; text.split(" ").forEach(((text, index) => { const span = (0, _renderer.default)("<span>").text(text).addClass("dx-scheduler-header-panel-cell-date"); (0, _renderer.default)(element).append(span); if (!index) { (0, _renderer.default)(element).append(" ") } })) }, _appointmentTooltipButtonsPosition: "top", _appointmentTooltipOpenButtonText: null, _appointmentCountPerCell: 1, _collectorOffset: 20, _appointmentOffset: 30 } }, { device: () => (0, _themes.isMaterial)(), options: { _appointmentTooltipOffset: { x: 0, y: 11 } } }]) } _postponeDataSourceLoading(promise) { this.postponedOperations.add("_reloadDataSource", this._reloadDataSource.bind(this), promise) } _postponeResourceLoading() { const whenLoaded = this.postponedOperations.add("loadResources", (() => { const groups = this._getCurrentViewOption("groups"); return (0, _m_utils2.loadResources)(groups, this.option("resources"), this.option("resourceLoaderMap")) })); const resolveCallbacks = new _deferred.Deferred; whenLoaded.done((resources => { this.option("loadedResources", resources); resolveCallbacks.resolve(resources) })); this._postponeDataSourceLoading(whenLoaded); return resolveCallbacks.promise() } _optionChanged(args) { var _this$_header, _this$_header2, _this$_header4; this.validateOptions(); let { value: value } = args; const { name: name } = args; switch (args.name) { case "customizeDateNavigatorText": this._updateOption("header", name, value); break; case "firstDayOfWeek": this._updateOption("workSpace", name, value); this._updateOption("header", name, value); break; case "currentDate": value = this._dateOption(name); value = _date2.default.trimTime(new Date(value)); this.option("selectedCellData", []); this._workSpace.option(name, new Date(value)); null === (_this$_header = this._header) || void 0 === _this$_header || _this$_header.option(name, new Date(value)); null === (_this$_header2 = this._header) || void 0 === _this$_header2 || _this$_header2.option("startViewDate", this.getStartViewDate()); this._appointments.option("items", []); this._filterAppointmentsByDate(); this._postponeDataSourceLoading(); break; case "dataSource": this._initDataSource(); this.appointmentDataProvider.setDataSource(this._dataSource); this._postponeResourceLoading().done((() => { this._filterAppointmentsByDate(); this._updateOption("workSpace", "showAllDayPanel", this.option("showAllDayPanel")) })); break; case "min": case "max": value = this._dateOption(name); this._updateOption("header", name, new Date(value)); this._updateOption("workSpace", name, new Date(value)); break; case "views": if (this._getCurrentViewOptions()) { this.repaint() } else { var _this$_header3; null === (_this$_header3 = this._header) || void 0 === _this$_header3 || _this$_header3.option(name, value) } break; case "useDropDownViewSwitcher": null === (_this$_header4 = this._header) || void 0 === _this$_header4 || _this$_header4.option(name, value); break; case "currentView": this._renderAriaAttributes(); this._appointments.option({ items: [], allowDrag: this._allowDragging(), allowResize: this._allowResizing(), itemTemplate: this._getAppointmentTemplate("appointmentTemplate") }); this._postponeResourceLoading().done((resources => { var _this$_header5; this._refreshWorkSpace(resources); null === (_this$_header5 = this._header) || void 0 === _this$_header5 || _this$_header5.option(this._headerConfig()); this._filterAppointmentsByDate(); this._appointments.option("allowAllDayResize", "day" !== value) })); this.postponedOperations.callPostponedOperations(); break; case "appointmentTemplate": this._appointments.option("itemTemplate", value); break; case "dateCellTemplate": case "resourceCellTemplate": case "dataCellTemplate": case "timeCellTemplate": this.repaint(); break; case "groups": this._postponeResourceLoading().done((resources => { this._refreshWorkSpace(resources); this._filterAppointmentsByDate() })); break; case "resources": this._dataAccessors.resources = (0, _m_utils2.createExpressions)(this.option("resources")); this.agendaResourceProcessor.initializeState(this.option("resources")); this.updateInstances(); this.option("resourceLoaderMap").clear(); this._postponeResourceLoading().done((resources => { this._appointments.option("items", []); this._refreshWorkSpace(resources); this._filterAppointmentsByDate(); this._createAppointmentPopupForm() })); break; case "startDayHour": case "endDayHour": this.updateInstances(); this._appointments.option("items", []); this._updateOption("workSpace", name, value); this._appointments.repaint(); this._filterAppointmentsByDate(); this._postponeDataSourceLoading(); break; case "offset": this.updateInstances(); this._appointments.option("items", []); this._updateOption("workSpace", "viewOffset", this.normalizeViewOffsetValue(value)); this._appointments.repaint(); this._filterAppointmentsByDate(); this._postponeDataSourceLoading(); break; case StoreEventNames.ADDING: case StoreEventNames.ADDED: case StoreEventNames.UPDATING: case StoreEventNames.UPDATED: case StoreEventNames.DELETING: case StoreEventNames.DELETED: case "onAppointmentFormOpening": case "onAppointmentTooltipShowing": this._actions[name] = this._createActionByOption(name); break; case "onAppointmentRendered": this._appointments.option("onItemRendered", this._getAppointmentRenderedAction()); break; case "onAppointmentClick": this._appointments.option("onItemClick", this._createActionByOption(name)); break; case "onAppointmentDblClick": this._appointments.option(name, this._createActionByOption(name)); break; case "onAppointmentContextMenu": this._appointments.option("onItemContextMenu", this._createActionByOption(name)); this._appointmentTooltip._options.onItemContextMenu = this._createActionByOption(name); break; case "noDataText": case "allowMultipleCellSelection": case "selectedCellData": case "accessKey": case "onCellClick": case "onCellContextMenu": this._workSpace.option(name, value); break; case "crossScrollingEnabled": this._postponeResourceLoading().done((resources => { this._appointments.option("items", []); this._refreshWorkSpace(resources); if (this._readyToRenderAppointments) { this._appointments.option("items", this._getAppointmentsToRepaint()) } })); break; case "cellDuration": this._updateOption("workSpace", name, value); this._appointments.option("items", []); if (this._readyToRenderAppointments) { this._updateOption("workSpace", "hoursInterval", value / 60); this._appointments.option("items", this._getAppointmentsToRepaint()) } break; case "tabIndex": case "focusStateEnabled": this._updateOption("header", name, value); this._updateOption("workSpace", name, value); this._appointments.option(name, value); super._optionChanged(args); break; case "width": this._updateOption("header", name, value); if (this.option("crossScrollingEnabled")) { this._updateOption("workSpace", "width", value) } this._updateOption("workSpace", "schedulerWidth", value); super._optionChanged(args); this._dimensionChanged(null, true); break; case "height": super._optionChanged(args); this._dimensionChanged(null, true); this._updateOption("workSpace", "schedulerHeight", value); break; case "editing": { this._initEditing(); const editing = this._editing; this._bringEditingModeToAppointments(editing); this.hideAppointmentTooltip(); this._cleanPopup(); break } case "showAllDayPanel": this.updateInstances(); this.repaint(); break; case "showCurrentTimeIndicator": case "indicatorTime": case "indicatorUpdateInterval": case "shadeUntilCurrentTime": case "groupByDate": this._updateOption("workSpace", name, value); this.repaint(); break; case "appointmentDragging": case "appointmentTooltipTemplate": case "appointmentPopupTemplate": case "recurrenceEditMode": case "remoteFiltering": case "timeZone": this.updateInstances(); this.repaint(); break; case "dropDownAppointmentTemplate": case "appointmentCollectorTemplate": case "_appointmentTooltipOffset": case "_appointmentTooltipButtonsPosition": case "_appointmentTooltipOpenButtonText": case "_appointmentCountPerCell": case "_collectorOffset": case "_appointmentOffset": this.repaint(); break; case "dateSerializationFormat": case "maxAppointmentsPerCell": break; case "startDateExpr": case "endDateExpr": case "startDateTimeZoneExpr": case "endDateTimeZoneExpr": case "textExpr": case "descriptionExpr": case "allDayExpr": case "recurrenceRuleExpr": case "recurrenceExceptionExpr": case "disabledExpr": this._updateExpression(name, value); this.appointmentDataProvider.updateDataAccessors(this._dataAccessors); this._initAppointmentTemplate(); this.repaint(); break; case "adaptivityEnabled": this._toggleAdaptiveClass(); this.repaint(); break; case "scrolling": this.option("crossScrollingEnabled", this._isHorizontalVirtualScrolling() || this.option("crossScrollingEnabled")); this._updateOption("workSpace", args.fullName, value); break; case "allDayPanelMode": this.updateInstances(); this._updateOption("workSpace", args.fullName, value); break; case "renovateRender": this._updateOption("workSpace", name, value); break; case "_draggingMode": this._workSpace.option("draggingMode", value); break; case "toolbar": this._header ? this._header.option("items", value) : this.repaint(); break; case "loadedResources": case "resourceLoaderMap": break; default: super._optionChanged(args) } } _dateOption(optionName) { const optionValue = this._getCurrentViewOption(optionName); return _date_serialization.default.deserializeDate(optionValue) } _getSerializationFormat(optionName) { const value = this._getCurrentViewOption(optionName); if ("number" === typeof value) { return "number" } if (!(0, _type.isString)(value)) { return } return _date_serialization.default.getDateSerializationFormat(value) } _bringEditingModeToAppointments(editing) { const editingConfig = { allowDelete: editing.allowUpdating && editing.allowDeleting }; if (!this._isAgenda()) { editingConfig.allowDrag = editing.allowDragging; editingConfig.allowResize = editing.allowResizing; editingConfig.allowAllDayResize = editing.allowResizing && this._supportAllDayResizing() } this._appointments.option(editingConfig); this.repaint() } _isAgenda() { return "agenda" === this.getLayoutManager().appointmentRenderingStrategyName } _allowDragging() { return this._editing.allowDragging && !this._isAgenda() } _allowResizing() { return this._editing.allowResizing && !this._isAgenda() } _allowAllDayResizing() { return this._editing.allowResizing && this._supportAllDayResizing() } _supportAllDayResizing() { return "day" !== this.currentViewType || this.currentView.intervalCount > 1 } _isAllDayExpanded() { return this.option("showAllDayPanel") && this.appointmentDataProvider.hasAllDayAppointments(this.filteredItems, this.preparedItems) } _getTimezoneOffsetByOption(date) { return _m_utils_time_zone.default.calculateTimezoneByValue(this.option("timeZone"), date) } _filterAppointmentsByDate() { const dateRange = this._workSpace.getDateRange(); const startDate = this.timeZoneCalculator.createDate(dateRange[0], { path: "fromGrid" }); const endDate = this.timeZoneCalculator.createDate(dateRange[1], { path: "fromGrid" }); this.appointmentDataProvider.filterByDate(startDate, endDate, this.option("remoteFiltering"), this.option("dateSerializationFormat")) } _reloadDataSource() { const result = new _deferred.Deferred; if (this._dataSource) { this._dataSource.load().done((() => { (0, _m_loading.hide)(); this._fireContentReadyAction(result) })).fail((() => { (0, _m_loading.hide)(); result.reject() })); this._dataSource.isLoading() && (0, _m_loading.show)({ container: this.$element(), position: { of: this.$element() } }) } else { this._fireContentReadyAction(result) } return result.promise() } _fireContentReadyAction(result) { const contentReadyBase = super._fireContentReadyAction.bind(this); const fireContentReady = () => { contentReadyBase(); null === result || void 0 === result || result.resolve() }; if (this._workSpaceRecalculation) { var _this$_workSpaceRecal; null === (_this$_workSpaceRecal = this._workSpaceRecalculation) || void 0 === _this$_workSpaceRecal || _this$_workSpaceRecal.done((() => { fireContentReady() })) } else { fireContentReady() } } _dimensionChanged(value) { let isForce = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : false; const isFixedHeight = "number" === typeof this.option("height"); const isFixedWidth = "number" === typeof this.option("width"); if (!this._isVisible()) { return } this._toggleSmallClass(); const workspace = this.getWorkSpace(); if (!this._isAgenda() && this.filteredItems && workspace) { if (isForce || !isFixedHeight || !isFixedWidth) { workspace.option("allDayExpanded", this._isAllDayExpanded()); workspace._dimensionChanged(); const appointments = this.getLayoutManager().createAppointmentsMap(this.filteredItems); this._appointments.option("items", appointments) } } this.hideAppointmentTooltip(); this._appointmentPopup.triggerResize(); this._appointmentPopup.updatePopupFullScreenMode() } _clean() { this._cleanPopup(); super._clean() } _toggleSmallClass() { const { width: width } = (0, _position.getBoundingRect)(this.$element().get(0)); this.$element().toggleClass(WIDGET_SMALL_CLASS, width < 400) } _toggleAdaptiveClass() { this.$element().toggleClass(WIDGET_ADAPTIVE_CLASS, this.option("adaptivityEnabled")) } _visibilityChanged(visible) { visible && this._dimensionChanged(null, true) } _dataSourceOptions() { return { paginate: false } } _initAllDayPanel() { if ("hidden" === this.option("allDayPanelMode")) { this.option("showAllDayPanel", false) } } _init() { this._initExpressions({ startDate: this.option("startDateExpr"), endDate: this.option("endDateExpr"), startDateTimeZone: this.option("startDateTimeZoneExpr"), endDateTimeZone: this.option("endDateTimeZoneExpr"), allDay: this.option("allDayExpr"), text: this.option("textExpr"), description: this.option("descriptionExpr"), recurrenceRule: this.option("recurrenceRuleExpr"), recurrenceException: this.option("recurrenceExceptionExpr"), disabled: this.option("disabledExpr") }); super._init(); this._initAllDayPanel(); this._initDataSource(); this._customizeDataSourceLoadOptions(); this.$element().addClass(WIDGET_CLASS); this._initEditing(); this.updateInstances(); this._initActions(); this._compactAppointmentsHelper = new _m_compact_appointments_helper.CompactAppointmentsHelper(this); this._asyncTemplatesTimers = []; this._dataSourceLoadedCallback = (0, _callbacks.default)(); this._subscribes = _m_subscribes.default; this.agendaResourceProcessor = new _m_agenda_resource_processor.AgendaResourceProcessor(this.option("resources")); this._optionsValidator = new _index4.SchedulerOptionsValidator; this._optionsValidatorErrorHandler = new _index4.SchedulerOptionsValidatorErrorsHandler } createAppointmentDataProvider() { var _this$appointmentData; null === (_this$appointmentData = this.appointmentDataProvider) || void 0 === _this$appointmentData || _this$appointmentData.destroy(); this.appointmentDataProvider = new _m_appointment_data_provider.AppointmentDataProvider({ dataSource: this._dataSource, dataAccessors: this._dataAccessors, timeZoneCalculator: this.timeZoneCalculator, dateSerializationFormat: this.option("dateSerializationFormat"), resources: this.option("resources"), startDayHour: this._getCurrentViewOption("startDayHour"), endDayHour: this._getCurrentViewOption("endDayHour"), viewOffset: this.getViewOffsetMs(), appointmentDuration: this._getCurrentViewOption("cellDuration"), allDayPanelMode: this._getCurrentViewOption("allDayPanelMode"), showAllDayPanel: this.option("showAllDayPanel"), getLoadedResources: () => this.option("loadedResources"), getIsVirtualScrolling: () => this.isVirtualScrolling(), getSupportAllDayRow: () => this._workSpace.supportAllDayRow(), getViewType: () => this._workSpace.type, getViewDirection: () => this._workSpace.viewDirection, getDateRange: () => this._workSpace.getDateRange(), getGroupCount: () => this._workSpace._getGroupCount(), getViewDataProvider: () => this._workSpace.viewDataProvider }) } updateInstances() { this._timeZoneCalculator = null; if (this.getWorkSpace()) { this.createAppointmentDataProvider() } } _customizeDataSourceLoadOptions() { var _this$_dataSource; null === (_this$_dataSource = this._dataSource) || void 0 === _this$_dataSource || _this$_dataSource.on("customizeStoreLoadOptions", (_ref => { let { storeLoadOptions: storeLoadOptions } = _ref; storeLoadOptions.startDate = this.getStartViewDate(); storeLoadOptions.endDate = this.getEndViewDate() })) } _initTemplates() { this._initAppointmentTemplate(); this._templateManager.addDefaultTemplates({ appointmentTooltip: new _empty_template.EmptyTemplate, dropDownAppointment: new _empty_template.EmptyTemplate }); super._initTemplates() } _initAppointmentTemplate() { const { expr: expr } = this._dataAccessors; const createGetter = property => (0, _data.compileGetter)(`appointmentData.${property}`); const getDate = getter => data => { const value = getter(data); if (value instanceof Date) { return value.valueOf() } return value }; this._templateManager.addDefaultTemplates({ item: new _bindable_template.BindableTemplate((($container, data, model) => this.getAppointmentsInstance()._renderAppointmentTemplate($container, data, model)), ["html", "text", "startDate", "endDate", "allDay", "description", "recurrenceRule", "recurrenceException", "startDateTimeZone", "endDateTimeZone"], this.option("integrationOptions.watchMethod"), { text: createGetter(expr.textExpr), startDate: getDate(createGetter(expr.startDateExpr)), endDate: getDate(createGetter(expr.endDateExpr)), startDateTimeZone: createGetter(expr.startDateTimeZoneExpr), endDateTimeZone: createGetter(expr.endDateTimeZoneExpr), allDay: createGetter(expr.allDayExpr), recurrenceRule: createGetter(expr.recurrenceRuleExpr) }) }) } _renderContent() { this._renderContentImpl() } _updatePreparedItems(items) { this.preparedItems = (0, _index2.getPreparedDataItems)(items, this._dataAccessors, this._getCurrentViewOption("cellDuration"), this.timeZoneCalculator) } _dataSourceChangedHandler(result) { if (this._readyToRenderAppointments) { this._workSpaceRecalculation.done((() => { this._updatePreparedItems(result); this._renderAppointments(); this.getWorkSpace().onDataSourceChanged(this.filteredItems) })) } } isVirtualScrolling() { var _currentViewOptions$s; const workspace = this.getWorkSpace(); if (workspace) { return workspace.isVirtualScrolling() } const currentViewOptions = this._getCurrentViewOptions(); const scrolling = this.option("scrolling"); return "virtual" === (null === scrolling || void 0 === scrolling ? void 0 : scrolling.mode) || "virtual" === (null === currentViewOptions || void 0 === currentViewOptions || null === (_currentViewOptions$s = currentViewOptions.scrolling) || void 0 === _currentViewOptions$s ? void 0 : _currentViewOptions$s.mode) } _filterAppointments() { this.filteredItems = this.appointmentDataProvider.filter(this.preparedItems) } _renderAppointments() { const workspace = this.getWorkSpace(); this._filterAppointments(); workspace.option("allDayExpanded", this._isAllDayExpanded()); let viewModel = []; if (this._isVisible()) { viewModel = this._getAppointmentsToRepaint() } this._appointments.option("items", viewModel); this.appointmentDataProvider.cleanState() } _getAppointmentsToRepaint() { const layoutManager = this.getLayoutManager(); const appointmentsMap = layoutManager.createAppointmentsMap(this.filteredItems); return layoutManager.getRepaintedAppointments(appointmentsMap, this.getAppointmentsInstance().option("items")) } _initExpressions(fields) { this._dataAccessors = _m_utils.utils.dataAccessors.create(fields, this._dataAccessors, (0, _config.default)().forceIsoDateParsing, this.option("dateSerializationFormat")); this._dataAccessors.resources = (0, _m_utils2.createExpressions)(this.option("resources")) } _updateExpression(name, value) { const exprObj = {}; exprObj[name.replace("Expr", "")] = value; this._initExpressions(exprObj) } getResourceDataAccessors() { return this._dataAccessors.resources } _initEditing() { const editing = this.option("editing"); this._editing = { allowAdding: !!editing, allowUpdating: !!editing, allowDeleting: !!editing, allowResizing: !!editing, allowDragging: !!editing }; if ((0, _type.isObject)(editing)) { this._editing = (0, _extend.extend)(this._editing, editing) } this._editing.allowDragging = this._editing.allowDragging && this._editing.allowUpdating; this._editing.allowResizing = this._editing.allowResizing && this._editing.allowUpdating; this.$element().toggleClass(WIDGET_READONLY_CLASS, this._isReadOnly()) } _isReadOnly() { let result = true; const editing = this._editing; for (const prop in editing) { if (Object.prototype.hasOwnProperty.call(editing, prop)) { result = result && !editing[prop] } } return result } _dispose() { var _this$_recurrenceDial; this._appointmentTooltip && this._appointmentTooltip.dispose(); null === (_this$_recurrenceDial = this._recurrenceDialog) || void 0 === _this$_recurrenceDial || _this$_recurrenceDial.hide(RECURRENCE_EDITING_MODE.CANCEL); this.hideAppointmentPopup(); this.hideAppointmentTooltip(); this._asyncTemplatesTimers.forEach(clearTimeout); this._asyncTemplatesTimers = []; _index3.macroTaskArray.dispose(); super._dispose() } _initActions() { this._actions = { onAppointmentAdding: this._createActionByOption(StoreEventNames.ADDING), onAppointmentAdded: this._createActionByOption(StoreEventNames.ADDED), onAppointmentUpdating: this._createActionByOption(StoreEventNames.UPDATING), onAppointmentUpdated: this._createActionByOption(StoreEventNames.UPDATED), onAppointmentDeleting: this._createActionByOption(StoreEventNames.DELETING), onAppointmentDeleted: this._createActionByOption(StoreEventNames.DELETED), onAppointmentFormOpening: this._createActionByOption("onAppointmentFormOpening"), onAppointmentTooltipShowing: this._createActionByOption("onAppointmentTooltipShowing") } } _getAppointmentRenderedAction() { return this._createActionByOption("onAppointmentRendered", { excludeValidators: ["disabled", "readOnly"] }) } _renderFocusTarget() { return (0, _common.noop)() } _renderAriaAttributes() { const viewTypeLabel = _message.default.format({ agenda: "dxScheduler-switcherAgenda", day: "dxScheduler-switcherDay", month: "dxScheduler-switcherMonth", week: "dxScheduler-switcherWeek", workWeek: "dxScheduler-switcherWorkWeek", timelineDay: "dxScheduler-switcherTimelineDay", timelineMonth: "dxScheduler-switcherTimelineMonth", timelineWeek: "dxScheduler-switcherTimelineWeek", timelineWorkWeek: "dxScheduler-switcherTimelineWorkWeek" } [this.currentViewType]); const label = _message.default.format("dxScheduler-ariaLabel", viewTypeLabel); this.setAria({ label: label, role: "group" }) } _initMarkup() { super._initMarkup(); this._renderMainContainer(); this._renderAriaAttributes(); this._renderHeader(); this._layoutManager = new _m_appointments_layout_manager.default(this); this._appointments = this._createComponent("<div>", _m_appointment_collection.default, this._appointmentsConfig()); this._appointments.option("itemTemplate", this._getAppointmentTemplate("appointmentTemplate")); this._appointmentTooltip = new(this.option("adaptivityEnabled") ? _m_mobile_tooltip_strategy.MobileTooltipStrategy : _m_desktop_tooltip_strategy.DesktopTooltipStrategy)(this._getAppointmentTooltipOptions()); this._createAppointmentPopupForm(); if (this._isDataSourceLoaded() || this._isDataSourceLoading()) { this._initMarkupCore(this.option("loadedResources")); this._dataSourceChangedHandler(this._dataSource.items()); this._fireContentReadyAction() } else { const groups = this._getCurrentViewOption("groups"); (0, _m_utils2.loadResources)(groups, this.option("resources"), this.option("resourceLoaderMap")).done((resources => { this.option("loadedResources", resources); this._initMarkupCore(resources); this._reloadDataSource() })) } } _createAppointmentPopupForm() { var _this$_appointmentPop; if (this._appointmentForm) { var _this$_appointmentFor; null === (_this$_appointmentFor = this._appointmentForm.form) || void 0 === _this$_appointmentFor || _this$_appointmentFor.dispose() } this._appointmentForm = this.createAppointmentForm(); null === (_this$_appointmentPop = this._appointmentPopup) || void 0 === _this$_appointmentPop || _this$_appointmentPop.dispose(); this._appointmentPopup = this.createAppointmentPopup(this._appointmentForm) } _renderMainContainer() { this._mainContainer = (0, _renderer.default)("<div>").addClass("dx-scheduler-container"); this.$element().append(this._mainContainer) } createAppointmentForm() { const scheduler = { createResourceEditorModel: () => (0, _m_utils2.createResourceEditorModel)(this.option("resources"), this.option("loadedResources")), getDataAccessors: () => this._dataAccessors, createComponent: (element, component, options) => this._createComponent(element, component, options), getEditingConfig: () => this._editing, getFirstDayOfWeek: () => this.option("firstDayOfWeek"), getStartDayHour: () => this.option("startDayHour"), getCalculatedEndDate: startDateWithStartHour => this._workSpace.calculateEndDate(startDateWithStartHour), getTimeZoneCalculator: () => this.timeZoneCalculator }; return new _m_form.AppointmentForm(scheduler) } createAppointmentPopup(form) { const scheduler = { getElement: () => this.$element(), createComponent: (element, component, options) => this._createComponent(element, component, options), focus: () => this.focus(), getResources: () => this.option("resources"), getEditingConfig: () => this._editing, getTimeZoneCalculator: () => this.timeZoneCalculator, getDataAccessors: () => this._dataAccessors, getAppointmentFormOpening: () => this._actions.onAppointmentFormOpening, processActionResult: (arg, canceled) => this._processActionResult(arg, canceled), addAppointment: appointment => this.addAppointment(appointment), updateAppointment: (sourceAppointment, updatedAppointment) => this.updateAppointment(sourceAppointment, updatedAppointment), updateScrollPosition: (startDate, resourceItem, inAllDayRow) => { this._workSpace.updateScrollPosition(startDate, resourceItem, inAllDayRow) } }; return new _m_popup.AppointmentPopup(scheduler, form) } _getAppointmentTooltipOptions() { return { createComponent: this._createComponent.bind(this), container: this.$element(), getScrollableContainer: this.getWorkSpaceScrollableContainer.bind(this), addDefaultTemplates: this._templateManager.addDefaultTemplates.bind(this._templateManager), getAppointmentTemplate: this._getAppointmentTemplate.bind(this), showAppointmentPopup: this.showAppointmentPopup.bind(this), checkAndDeleteAppointment: this.checkAndDeleteAppointment.bind(this), isAppointmentInAllDayPanel: this.isAppointmentInAllDayPanel.bind(this), createFormattedDateText: (appointment, targetedAppointment, format) => this.fire("getTextAndFormatDate", appointment, targetedAppointment, format), getAppointmentDisabled: appointment => (0, _m_appointment_adapter.createAppointmentAdapter)(appointment, this._dataAccessors, this.timeZoneCalculator).disabled, onItemContextMenu: this._createActionByOption("onAppointmentContextMenu"), createEventArgs: this._createEventArgs.bind(this) } } _createEventArgs(e) { const config = { itemData: e.it