UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

1,174 lines • 85.6 kB
/** * DevExtreme (esm/ui/scheduler/ui.scheduler.js) * Version: 21.2.4 * Build date: Mon Dec 06 2021 * * Copyright (c) 2012 - 2021 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import _extends from "@babel/runtime/helpers/esm/extends"; import registerComponent from "../../core/component_registrator"; import config from "../../core/config"; import devices from "../../core/devices"; import $ from "../../core/renderer"; import { BindableTemplate } from "../../core/templates/bindable_template"; import { EmptyTemplate } from "../../core/templates/empty_template"; import { inArray } from "../../core/utils/array"; import Callbacks from "../../core/utils/callbacks"; import { noop } from "../../core/utils/common"; import { compileGetter } from "../../core/utils/data"; import { getBoundingRect } from "../../core/utils/position"; import dateUtils from "../../core/utils/date"; import dateSerialization from "../../core/utils/date_serialization"; import { Deferred, when, fromPromise } from "../../core/utils/deferred"; import { extend } from "../../core/utils/extend"; import { each } from "../../core/utils/iterator"; import { isDefined, isString, isObject, isFunction, isEmptyObject, isDeferred, isPromise } from "../../core/utils/type"; import { hasWindow } from "../../core/utils/window"; import DataHelperMixin from "../../data_helper"; import { triggerResizeEvent } from "../../events/visibility_change"; import dateLocalization from "../../localization/date"; import messageLocalization from "../../localization/message"; import { custom as customDialog } from "../dialog"; import { isMaterial } from "../themes"; import errors from "../widget/ui.errors"; import Widget from "../widget/ui.widget"; import { AppointmentPopup, ACTION_TO_APPOINTMENT } from "./appointmentPopup/popup"; import { AppointmentForm } from "./appointmentPopup/form"; import { CompactAppointmentsHelper } from "./compactAppointmentsHelper"; import { DesktopTooltipStrategy } from "./tooltip_strategies/desktopTooltipStrategy"; import { MobileTooltipStrategy } from "./tooltip_strategies/mobileTooltipStrategy"; import { hide as hideLoading, show as showLoading } from "./loading"; import AppointmentCollection from "./appointments/appointmentCollection"; import AppointmentLayoutManager from "./appointments.layout_manager"; import { SchedulerHeader } from "./header/header"; import subscribes from "./subscribes"; import { getRecurrenceProcessor } from "./recurrence"; import timeZoneUtils from "./utils.timeZone"; import SchedulerAgenda from "./workspaces/ui.scheduler.agenda"; import SchedulerTimelineDay from "./workspaces/ui.scheduler.timeline_day"; import SchedulerTimelineMonth from "./workspaces/ui.scheduler.timeline_month"; import SchedulerTimelineWeek from "./workspaces/ui.scheduler.timeline_week"; import SchedulerTimelineWorkWeek from "./workspaces/ui.scheduler.timeline_work_week"; import SchedulerWorkSpaceDay from "./workspaces/ui.scheduler.work_space_day"; import SchedulerWorkSpaceMonth from "./workspaces/ui.scheduler.work_space_month"; import SchedulerWorkSpaceWeek from "./workspaces/ui.scheduler.work_space_week"; import SchedulerWorkSpaceWorkWeek from "./workspaces/ui.scheduler.work_space_work_week"; import { createAppointmentAdapter } from "./appointmentAdapter"; import { AppointmentTooltipInfo } from "./dataStructures"; import { utils } from "./utils"; import { createFactoryInstances, disposeFactoryInstances, getTimeZoneCalculator as _getTimeZoneCalculator, getModelProvider, createModelProvider, generateKey } from "./instanceFactory"; import { createExpressions, createResourceEditorModel as _createResourceEditorModel, getAppointmentColor, getCellGroups, getResourcesFromItem as _getResourcesFromItem, loadResources, setResourceToAppointment } from "./resources/utils"; import { ExpressionUtils } from "./expressionUtils"; import { validateDayHours } from "../../renovation/ui/scheduler/view_model/to_test/views/utils/base"; import { renderAppointments } from "./appointments/render"; import { AgendaResourceProcessor } from "./resources/agendaResourceProcessor"; import { AppointmentDataProvider } from "./appointments/dataProvider/appointmentDataProvider"; import { getAppointmentTakesAllDay } from "./appointments/dataProvider/utils"; var MINUTES_IN_HOUR = 60; var WIDGET_CLASS = "dx-scheduler"; var WIDGET_SMALL_CLASS = "".concat(WIDGET_CLASS, "-small"); var WIDGET_ADAPTIVE_CLASS = "".concat(WIDGET_CLASS, "-adaptive"); var WIDGET_READONLY_CLASS = "".concat(WIDGET_CLASS, "-readonly"); var WIDGET_SMALL_WIDTH = 400; var FULL_DATE_FORMAT = "yyyyMMddTHHmmss"; var UTC_FULL_DATE_FORMAT = FULL_DATE_FORMAT + "Z"; var DEFAULT_AGENDA_DURATION = 7; var DEFAULT_APPOINTMENT_TEMPLATE_NAME = "item"; var DEFAULT_APPOINTMENT_COLLECTOR_TEMPLATE_NAME = "appointmentCollector"; var DEFAULT_DROP_DOWN_APPOINTMENT_TEMPLATE_NAME = "dropDownAppointment"; var VIEWS_CONFIG = { day: { workSpace: SchedulerWorkSpaceDay, renderingStrategy: "vertical" }, week: { workSpace: SchedulerWorkSpaceWeek, renderingStrategy: "vertical" }, workWeek: { workSpace: SchedulerWorkSpaceWorkWeek, renderingStrategy: "vertical" }, month: { workSpace: SchedulerWorkSpaceMonth, renderingStrategy: "horizontalMonth" }, timelineDay: { workSpace: SchedulerTimelineDay, renderingStrategy: "horizontal" }, timelineWeek: { workSpace: SchedulerTimelineWeek, renderingStrategy: "horizontal" }, timelineWorkWeek: { workSpace: SchedulerTimelineWorkWeek, renderingStrategy: "horizontal" }, timelineMonth: { workSpace: SchedulerTimelineMonth, renderingStrategy: "horizontalMonthLine" }, agenda: { workSpace: SchedulerAgenda, renderingStrategy: "agenda" } }; var StoreEventNames = { ADDING: "onAppointmentAdding", ADDED: "onAppointmentAdded", DELETING: "onAppointmentDeleting", DELETED: "onAppointmentDeleted", UPDATING: "onAppointmentUpdating", UPDATED: "onAppointmentUpdated" }; var RECURRENCE_EDITING_MODE = { SERIES: "editSeries", OCCURENCE: "editOccurence", CANCEL: "cancel" }; class Scheduler extends Widget { _getDefaultOptions() { var defaultOptions = extend(super._getDefaultOptions(), { views: ["day", "week"], currentView: "day", currentDate: dateUtils.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: DEFAULT_APPOINTMENT_TEMPLATE_NAME, dropDownAppointmentTemplate: DEFAULT_DROP_DOWN_APPOINTMENT_TEMPLATE_NAME, appointmentCollectorTemplate: DEFAULT_APPOINTMENT_COLLECTOR_TEMPLATE_NAME, dataCellTemplate: null, timeCellTemplate: null, resourceCellTemplate: null, dateCellTemplate: null, startDayHour: 0, endDayHour: 24, 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, 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: messageLocalization.format("dxCollectionWidget-noDataText"), adaptivityEnabled: false, allowMultipleCellSelection: true, scrolling: { mode: "standard" }, renovateRender: true, _draggingMode: "outlook", _appointmentTooltipOffset: { x: 0, y: 0 }, _appointmentTooltipButtonsPosition: "bottom", _appointmentTooltipOpenButtonText: messageLocalization.format("dxScheduler-openAppointment"), _dropDownButtonIcon: "overflow", _appointmentCountPerCell: 2, _collectorOffset: 0, _appointmentOffset: 26, toolbar: [{ location: "before", defaultElement: "dateNavigator" }, { location: "after", defaultElement: "viewSwitcher" }] }); return extend(true, defaultOptions, { integrationOptions: { useDeferUpdateForTemplates: false } }) } get filteredItems() { if (!this._filteredItems) { this._filteredItems = [] } return this._filteredItems } set filteredItems(value) { this._filteredItems = value } _setDeprecatedOptions() { super._setDeprecatedOptions(); extend(this._deprecatedOptions, { dropDownAppointmentTemplate: { since: "19.2", message: "appointmentTooltipTemplate" } }) } _defaultOptionsRules() { return super._defaultOptionsRules().concat([{ device: function() { return "desktop" === devices.real().deviceType && !devices.isSimulator() }, options: { focusStateEnabled: true } }, { device: function() { return !devices.current().generic }, options: { useDropDownViewSwitcher: true, editing: { allowDragging: false, allowResizing: false } } }, { device: function() { return isMaterial() }, options: { useDropDownViewSwitcher: true, dateCellTemplate: function(data, index, element) { var text = data.text; text.split(" ").forEach((function(text, index) { var span = $("<span>").text(text).addClass("dx-scheduler-header-panel-cell-date"); $(element).append(span); if (!index) { $(element).append(" ") } })) }, _appointmentTooltipOffset: { x: 0, y: 11 }, _appointmentTooltipButtonsPosition: "top", _appointmentTooltipOpenButtonText: null, _dropDownButtonIcon: "chevrondown", _appointmentCountPerCell: 1, _collectorOffset: 20, _appointmentOffset: 30 } }]) } _postponeDataSourceLoading(promise) { this.postponedOperations.add("_reloadDataSource", this._reloadDataSource.bind(this), promise) } _postponeResourceLoading() { var whenLoaded = this.postponedOperations.add("loadResources", () => { var groups = this._getCurrentViewOption("groups"); return loadResources(groups, this.option("resources"), this.option("resourceLoaderMap")) }); var resolveCallbacks = new 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; var value = args.value; var name = args.name; 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 = dateUtils.trimTime(new Date(value)); this.option("selectedCellData", []); this._workSpace.option(name, new Date(value)); null === (_this$_header = this._header) || void 0 === _this$_header ? void 0 : _this$_header.option(name, new Date(value)); null === (_this$_header2 = this._header) || void 0 === _this$_header2 ? void 0 : _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(resources => { 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": this.modelProvider.updateCurrentView(); if (this._getCurrentViewOptions()) { this.repaint() } else { var _this$_header3; null === (_this$_header3 = this._header) || void 0 === _this$_header3 ? void 0 : _this$_header3.option(name, value) } break; case "useDropDownViewSwitcher": null === (_this$_header4 = this._header) || void 0 === _this$_header4 ? void 0 : _this$_header4.option(name, value); break; case "currentView": this.modelProvider.updateCurrentView(); this._validateDayHours(); this._validateCellDuration(); this._appointments.option({ items: [], allowDrag: this._allowDragging(), allowResize: this._allowResizing(), itemTemplate: this._getAppointmentTemplate("appointmentTemplate") }); this._postponeResourceLoading().done(resources => { this._refreshWorkSpace(resources); this._updateHeader(); this._filterAppointmentsByDate(); this._appointments.option("allowAllDayResize", "day" !== value) }); 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 = createExpressions(this.option("resources")); this.agendaResourceProcessor.initializeState(value); this.updateFactoryInstances(); this._postponeResourceLoading().done(resources => { this._appointments.option("items", []); this._refreshWorkSpace(resources); this._filterAppointmentsByDate() }); break; case "startDayHour": case "endDayHour": this._validateDayHours(); this.updateFactoryInstances(); this._appointments.option("items", []); this._updateOption("workSpace", name, 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": 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)); 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._validateCellDuration(); 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(); break; case "height": super._optionChanged(args); this._dimensionChanged(); this._updateOption("workSpace", "schedulerHeight", value); break; case "editing": this._initEditing(); var editing = this._editing; this._bringEditingModeToAppointments(editing); this.hideAppointmentTooltip(); this._cleanPopup(); break; case "showAllDayPanel": this.updateFactoryInstances(); this._postponeResourceLoading().done(resources => { this._filterAppointmentsByDate(); this._updateOption("workSpace", "allDayExpanded", value); this._updateOption("workSpace", name, value) }); 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.updateFactoryInstances(); this.repaint(); break; case "dropDownAppointmentTemplate": case "appointmentCollectorTemplate": case "_appointmentTooltipOffset": case "_appointmentTooltipButtonsPosition": case "_appointmentTooltipOpenButtonText": case "_dropDownButtonIcon": 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 "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) } } _updateHeader() { var _this$_header5; null === (_this$_header5 = this._header) || void 0 === _this$_header5 ? void 0 : _this$_header5.option({ intervalCount: this._getViewCountConfig().intervalCount, startViewDate: this.getStartViewDate(), min: this._dateOption("min"), max: this._dateOption("max"), currentDate: this._dateOption("currentDate"), firstDayOfWeek: this.getFirstDayOfWeek(), currentView: this.modelProvider.currentView }) } _dateOption(optionName) { var optionValue = this._getCurrentViewOption(optionName); return dateSerialization.deserializeDate(optionValue) } _getSerializationFormat(optionName) { var value = this._getCurrentViewOption(optionName); if ("number" === typeof value) { return "number" } if (!isString(value)) { return } return dateSerialization.getDateSerializationFormat(value) } _bringEditingModeToAppointments(editing) { var 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 this.modelProvider.supportAllDayResizing() } _isAllDayExpanded(items) { return this.option("showAllDayPanel") && this.appointmentDataProvider.hasAllDayAppointments(items) } _getTimezoneOffsetByOption(date) { return timeZoneUtils.calculateTimezoneByValue(this.option("timeZone"), date) } _filterAppointmentsByDate() { var dateRange = this._workSpace.getDateRange(); var timeZoneCalculator = _getTimeZoneCalculator(this.key); var startDate = timeZoneCalculator.createDate(dateRange[0], { path: "fromGrid" }); var endDate = timeZoneCalculator.createDate(dateRange[1], { path: "fromGrid" }); this.appointmentDataProvider.filterByDate(startDate, endDate, this.option("remoteFiltering"), this.option("dateSerializationFormat")) } _reloadDataSource() { var result = new Deferred; if (this._dataSource) { this._dataSource.load().done(function() { hideLoading(); this._fireContentReadyAction(result) }.bind(this)).fail((function() { hideLoading(); result.reject() })); this._dataSource.isLoading() && showLoading({ container: this.$element(), position: { of: this.$element() } }) } else { this._fireContentReadyAction(result) } return result.promise() } _fireContentReadyAction(result) { var contentReadyBase = super._fireContentReadyAction.bind(this); var fireContentReady = () => { contentReadyBase(); null === result || void 0 === result ? void 0 : result.resolve() }; if (this._workSpaceRecalculation) { var _this$_workSpaceRecal; null === (_this$_workSpaceRecal = this._workSpaceRecalculation) || void 0 === _this$_workSpaceRecal ? void 0 : _this$_workSpaceRecal.done(() => { fireContentReady() }) } else { fireContentReady() } } _dimensionChanged() { this._toggleSmallClass(); if (!this._isAgenda() && this.filteredItems && this._isVisible()) { this._workSpace.option("allDayExpanded", this._isAllDayExpanded(this.filteredItems)); this._workSpace._dimensionChanged(); var 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() { var width = getBoundingRect(this.$element().get(0)).width; this.$element().toggleClass(WIDGET_SMALL_CLASS, width < WIDGET_SMALL_WIDTH) } _toggleAdaptiveClass() { this.$element().toggleClass(WIDGET_ADAPTIVE_CLASS, this.option("adaptivityEnabled")) } _visibilityChanged(visible) { visible && this._dimensionChanged() } _dataSourceOptions() { return { paginate: 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._initDataSource(); this.$element().addClass(WIDGET_CLASS); this._initEditing(); this.updateFactoryInstances(); this._initActions(); this._compactAppointmentsHelper = new CompactAppointmentsHelper(this); this._asyncTemplatesTimers = []; this._dataSourceLoadedCallback = Callbacks(); this._subscribes = subscribes; this.agendaResourceProcessor = new AgendaResourceProcessor(this.option("resources")) } get modelProvider() { return getModelProvider(this.key) } createAppointmentDataProvider() { this.appointmentDataProvider = new AppointmentDataProvider({ dataSource: this._dataSource, dataAccessors: this._dataAccessors, timeZoneCalculator: _getTimeZoneCalculator(this.key), dateSerializationFormat: this.option("dateSerializationFormat"), resources: this.option("resources"), startDayHour: this._getCurrentViewOption("startDayHour"), endDayHour: this._getCurrentViewOption("endDayHour"), appointmentDuration: this._getCurrentViewOption("cellDuration"), 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 }) } updateFactoryInstances() { var model = this._options._optionManager._options; if (!isDefined(this.key)) { this.key = generateKey(); createModelProvider(this.key, model) } if (this.getWorkSpace()) { this.createAppointmentDataProvider() } createFactoryInstances({ key: this.key, model: model, timeZone: this.option("timeZone") }) } _initTemplates() { this._initAppointmentTemplate(); this._templateManager.addDefaultTemplates({ appointmentTooltip: new EmptyTemplate, dropDownAppointment: new EmptyTemplate }); super._initTemplates() } _initAppointmentTemplate() { var { expr: expr } = this._dataAccessors; var createGetter = property => compileGetter("appointmentData.".concat(property)); var getDate = getter => data => { var value = getter(data); if (value instanceof Date) { return value.valueOf() } return value }; this._templateManager.addDefaultTemplates({ item: new 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() } _dataSourceChangedHandler(result) { if (this._readyToRenderAppointments) { this._workSpaceRecalculation.done(function() { this._renderAppointments(); this.getWorkSpace().onDataSourceChanged(this.filteredItems) }.bind(this)) } } isVirtualScrolling() { var _currentViewOptions$s; var workspace = this.getWorkSpace(); if (workspace) { return workspace.isVirtualScrolling() } var currentViewOptions = this._getCurrentViewOptions(); var scrolling = this.option("scrolling"); return "virtual" === (null === scrolling || void 0 === scrolling ? void 0 : scrolling.mode) || "virtual" === (null === currentViewOptions || void 0 === currentViewOptions ? void 0 : null === (_currentViewOptions$s = currentViewOptions.scrolling) || void 0 === _currentViewOptions$s ? void 0 : _currentViewOptions$s.mode) } _filterAppointments() { this.filteredItems = this.appointmentDataProvider.filter() } _renderAppointments() { var workspace = this.getWorkSpace(); this._filterAppointments(); workspace.option("allDayExpanded", this._isAllDayExpanded(this.filteredItems)); var viewModel = []; if (this._isVisible()) { viewModel = this._getAppointmentsToRepaint() } if (this.modelProvider.isRenovatedAppointments) { renderAppointments({ instance: this, $dateTable: this.getWorkSpace()._getDateTable(), viewModel: viewModel }) } else { this._appointments.option("items", viewModel) } this.appointmentDataProvider.cleanState() } _getAppointmentsToRepaint() { var layoutManager = this.getLayoutManager(); var appointmentsMap = layoutManager.createAppointmentsMap(this.filteredItems); if (this.modelProvider.isRenovatedAppointments) { var appointmentTemplate = this.option("appointmentTemplate") !== DEFAULT_APPOINTMENT_TEMPLATE_NAME ? this.option("appointmentTemplate") : void 0; return { appointments: appointmentsMap, appointmentTemplate: appointmentTemplate } } return layoutManager.getRepaintedAppointments(appointmentsMap, this.getAppointmentsInstance().option("items")) } _initExpressions(fields) { this._dataAccessors = utils.dataAccessors.create(fields, this._dataAccessors, config().forceIsoDateParsing, this.option("dateSerializationFormat")); this._dataAccessors.resources = createExpressions(this.option("resources")) } _updateExpression(name, value) { var exprObj = {}; exprObj[name.replace("Expr", "")] = value; this._initExpressions(exprObj) } getResourceDataAccessors() { return this._dataAccessors.resources } _initEditing() { var editing = this.option("editing"); this._editing = { allowAdding: !!editing, allowUpdating: !!editing, allowDeleting: !!editing, allowResizing: !!editing, allowDragging: !!editing }; if (isObject(editing)) { this._editing = 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() { var result = true; var editing = this._editing; for (var 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 ? void 0 : _this$_recurrenceDial.hide(RECURRENCE_EDITING_MODE.CANCEL); this.hideAppointmentPopup(); this.hideAppointmentTooltip(); this._asyncTemplatesTimers.forEach(clearTimeout); this._asyncTemplatesTimers = []; super._dispose(); disposeFactoryInstances(this.key) } _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") } } _getAppointmentRenderedAction() { return this._createActionByOption("onAppointmentRendered", { excludeValidators: ["disabled", "readOnly"] }) } _renderFocusTarget() { return noop() } _initMarkup() { super._initMarkup(); this._validateDayHours(); this._validateCellDuration(); this.modelProvider.updateCurrentView(); this._renderMainContainer(); this._renderHeader(); this._layoutManager = new AppointmentLayoutManager(this); this._appointments = this._createComponent("<div>", AppointmentCollection, this._appointmentsConfig()); this._appointments.option("itemTemplate", this._getAppointmentTemplate("appointmentTemplate")); this._appointmentTooltip = new(this.option("adaptivityEnabled") ? MobileTooltipStrategy : DesktopTooltipStrategy)(this._getAppointmentTooltipOptions()); this._appointmentForm = this.createAppointmentForm(); this._appointmentPopup = this.createAppointmentPopup(this._appointmentForm); if (this._isDataSourceLoaded() || this._isDataSourceLoading()) { this._initMarkupCore(this.option("loadedResources")); this._dataSourceChangedHandler(this._dataSource.items()); this._fireContentReadyAction() } else { var groups = this._getCurrentViewOption("groups"); loadResources(groups, this.option("resources"), this.option("resourceLoaderMap")).done(resources => { this.option("loadedResources", resources); this._initMarkupCore(resources); this._reloadDataSource() }) } } _renderMainContainer() { this._mainContainer = $("<div>").addClass("dx-scheduler-container"); this.$element().append(this._mainContainer) } createAppointmentForm() { var scheduler = { createResourceEditorModel: () => _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) }; return new AppointmentForm(scheduler) } createAppointmentPopup(form) { var scheduler = { getKey: () => this.key, getElement: () => this.$element(), createComponent: (element, component, options) => this._createComponent(element, component, options), focus: () => this.focus(), getResourcesFromItem: rawAppointment => _getResourcesFromItem(this.option("resources"), this.getResourceDataAccessors(), rawAppointment, true), getEditingConfig: () => this._editing, getTimeZoneCalculator: () => _getTimeZoneCalculator(this.key), 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 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 => createAppointmentAdapter(appointment, this._dataAccessors, _getTimeZoneCalculator(this.key)).disabled } } checkAndDeleteAppointment(appointment, targetedAppointment) { var targetedAdapter = createAppointmentAdapter(targetedAppointment, this._dataAccessors, _getTimeZoneCalculator(this.key)); this._checkRecurringAppointment(appointment, targetedAppointment, targetedAdapter.startDate, () => { this.deleteAppointment(appointment) }, true) } _getExtraAppointmentTooltipOptions() { return { rtlEnabled: this.option("rtlEnabled"), focusStateEnabled: this.option("focusStateEnabled"), editing: this.option("editing"), offset: this.option("_appointmentTooltipOffset") } } isAppointmentInAllDayPanel(appointmentData) { var workSpace = this._workSpace; var itTakesAllDay = this.appointmentTakesAllDay(appointmentData); return itTakesAllDay && workSpace.supportAllDayRow() && workSpace.option("showAllDayPanel") } _initMarkupCore(resources) { this._readyToRenderAppointments = hasWindow(); this._workSpace && this._cleanWorkspace(); this._renderWorkSpace(resources); this._appointments.option({ fixedContainer: this._workSpace.getFixedContainer(), allDayContainer: this._workSpace.getAllDayContainer() }); this._waitAsyncTemplate(() => { var _this$_workSpaceRecal2; return null === (_this$_workSpaceRecal2 = this._workSpaceRecalculation) || void 0 === _this$_workSpaceRecal2 ? void 0 : _this$_workSpaceRecal2.resolve() }); this.createAppointmentDataProvider(); this._filterAppointmentsByDate() } _isDataSourceLoaded() { return this._dataSource && this._dataSource.isLoaded() } _render() { var _this$getWorkSpace; this._toggleSmallClass(); this._toggleAdaptiveClass(); null === (_this$getWorkSpace = this.getWorkSpace()) || void 0 === _this$getWorkSpace ? void 0 : _this$getWorkSpace.updateHeaderEmptyCellWidth(); super._render() } _renderHeader() { if (0 !== this.option("toolbar").length) { var $header = $("<div>").appendTo(this._mainContainer); this._header = this._createComponent($header, SchedulerHeader, this._headerConfig()) } } _headerConfig() { var currentViewOptions = this._getCurrentViewOptions(); var countConfig = this._getViewCountConfig(); var result = extend({ firstDayOfWeek: this.getFirstDayOfWeek(), currentView: this.modelProvider.currentView, isAdaptive: this.modelProvider.adaptivityEnabled, tabIndex: this.option("tabIndex"), focusStateEnabled: this.option("focusStateEnabled"), rtlEnabled: this.modelProvider.rtlEnabled, useDropDownViewSwitcher: this.option("useDropDownViewSwitcher"), customizeDateNavigatorText: this.option("customizeDateNavigatorText"), agendaDuration: this.option("agendaDuration") || DEFAULT_AGENDA_DURATION }, currentViewOptions); result.intervalCount = countConfig.intervalCount; result.views = this.option("views"); result.min = new Date(this._dateOption("min")); result.max = new Date(this._dateOption("max")); result.currentDate = dateUtils.trimTime(new Date(this._dateOption("currentDate"))); result.onCurrentViewChange = name => this.option("currentView", name); result.onCurrentDateChange = date => this.option("currentDate", date); result.items = this.option("toolbar"); result.todayDate = () => { var result = _getTimeZoneCalculator(this.key).createDate(new Date, { path: "toGrid" }); return result }; return result } _appointmentsConfig() { var config = { getResources: () => this.option("resources"), getResourceDataAccessors: this.getResourceDataAccessors.bind(this), getAgendaResourceProcessor: () => this.agendaResourceProcessor, getAppointmentColor: this.createGe