UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

1,069 lines (1,060 loc) • 123 kB
/** * DevExtreme (cjs/__internal/scheduler/workspaces/m_work_space.js) * Version: 23.2.6 * Build date: Wed May 01 2024 * * Copyright (c) 2012 - 2024 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 _translator = require("../../../animation/translator"); var _dom_adapter = _interopRequireDefault(require("../../../core/dom_adapter")); var _element = require("../../../core/element"); var _renderer = _interopRequireDefault(require("../../../core/renderer")); var _common = require("../../../core/utils/common"); var _data = require("../../../core/utils/data"); var _date = _interopRequireDefault(require("../../../core/utils/date")); var _extend = require("../../../core/utils/extend"); var _position = require("../../../core/utils/position"); var _size = require("../../../core/utils/size"); var _type = require("../../../core/utils/type"); var _window = require("../../../core/utils/window"); var _click = require("../../../events/click"); var _contextmenu = require("../../../events/contextmenu"); var _events_engine = _interopRequireDefault(require("../../../events/core/events_engine")); var _drag = require("../../../events/drag"); var _pointer = _interopRequireDefault(require("../../../events/pointer")); var _index = require("../../../events/utils/index"); var _message = _interopRequireDefault(require("../../../localization/message")); var _ui = _interopRequireDefault(require("../../../ui/scroll_view/ui.scrollable")); var _ui2 = _interopRequireDefault(require("../../../ui/widget/ui.errors")); var _scroll = require("../../core/utils/scroll"); var _index2 = require("../../scheduler/r1/components/index"); var _index3 = require("../../scheduler/r1/utils/index"); var _m_widget_observer = _interopRequireDefault(require("../base/m_widget_observer")); var _m_appointment_drag_behavior = _interopRequireDefault(require("../m_appointment_drag_behavior")); var _m_classes = require("../m_classes"); var _m_constants = require("../m_constants"); var _m_table_creator = _interopRequireDefault(require("../m_table_creator")); var _m_utils = require("../m_utils"); var _m_utils2 = require("../resources/m_utils"); var _m_current_time_shader_vertical = _interopRequireDefault(require("../shaders/m_current_time_shader_vertical")); var _m_position_helper = require("./helpers/m_position_helper"); var _m_cache = require("./m_cache"); var _m_cells_selection_controller = require("./m_cells_selection_controller"); var _m_cells_selection_state = _interopRequireDefault(require("./m_cells_selection_state")); var _m_virtual_scrolling = require("./m_virtual_scrolling"); var _m_work_space_grouped_strategy_horizontal = _interopRequireDefault(require("./m_work_space_grouped_strategy_horizontal")); var _m_work_space_grouped_strategy_vertical = _interopRequireDefault(require("./m_work_space_grouped_strategy_vertical")); var _m_view_data_provider = _interopRequireDefault(require("./view_model/m_view_data_provider")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj } } function _extends() { _extends = Object.assign ? Object.assign.bind() : function(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key] } } } return target }; return _extends.apply(this, arguments) } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true } Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor) } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) { _defineProperties(Constructor.prototype, protoProps) } if (staticProps) { _defineProperties(Constructor, staticProps) } Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return "symbol" === typeof key ? key : String(key) } function _toPrimitive(input, hint) { if ("object" !== typeof input || null === input) { return input } var prim = input[Symbol.toPrimitive]; if (void 0 !== prim) { var res = prim.call(input, hint || "default"); if ("object" !== typeof res) { return res } throw new TypeError("@@toPrimitive must return a primitive value.") } return ("string" === hint ? String : Number)(input) } function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass) } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) { o.__proto__ = p; return o }; return _setPrototypeOf(o, p) } const { tableCreator: tableCreator } = _m_table_creator.default; const DRAGGING_MOUSE_FAULT = 10; const { abstract: abstract } = _m_widget_observer.default; const toMs = _date.default.dateToMilliseconds; const COMPONENT_CLASS = "dx-scheduler-work-space"; const GROUPED_WORKSPACE_CLASS = "dx-scheduler-work-space-grouped"; const VERTICAL_GROUPED_WORKSPACE_CLASS = "dx-scheduler-work-space-vertical-grouped"; const WORKSPACE_VERTICAL_GROUP_TABLE_CLASS = "dx-scheduler-work-space-vertical-group-table"; const WORKSPACE_WITH_BOTH_SCROLLS_CLASS = "dx-scheduler-work-space-both-scrollbar"; const WORKSPACE_WITH_COUNT_CLASS = "dx-scheduler-work-space-count"; const WORKSPACE_WITH_GROUP_BY_DATE_CLASS = "dx-scheduler-work-space-group-by-date"; const WORKSPACE_WITH_ODD_CELLS_CLASS = "dx-scheduler-work-space-odd-cells"; const TIME_PANEL_CELL_CLASS = "dx-scheduler-time-panel-cell"; const TIME_PANEL_ROW_CLASS = "dx-scheduler-time-panel-row"; const ALL_DAY_PANEL_CLASS = "dx-scheduler-all-day-panel"; const ALL_DAY_TABLE_CLASS = "dx-scheduler-all-day-table"; const ALL_DAY_CONTAINER_CLASS = "dx-scheduler-all-day-appointments"; const ALL_DAY_TITLE_CLASS = "dx-scheduler-all-day-title"; const ALL_DAY_TABLE_CELL_CLASS = "dx-scheduler-all-day-table-cell"; const ALL_DAY_TABLE_ROW_CLASS = "dx-scheduler-all-day-table-row"; const WORKSPACE_WITH_ALL_DAY_CLASS = "dx-scheduler-work-space-all-day"; const WORKSPACE_WITH_COLLAPSED_ALL_DAY_CLASS = "dx-scheduler-work-space-all-day-collapsed"; const WORKSPACE_WITH_MOUSE_SELECTION_CLASS = "dx-scheduler-work-space-mouse-selection"; const HORIZONTAL_SIZES_CLASS = "dx-scheduler-cell-sizes-horizontal"; const VERTICAL_SIZES_CLASS = "dx-scheduler-cell-sizes-vertical"; const HEADER_PANEL_CLASS = "dx-scheduler-header-panel"; const HEADER_PANEL_CELL_CLASS = "dx-scheduler-header-panel-cell"; const HEADER_ROW_CLASS = "dx-scheduler-header-row"; const GROUP_HEADER_CLASS = "dx-scheduler-group-header"; const DATE_TABLE_CELL_CLASS = "dx-scheduler-date-table-cell"; const DATE_TABLE_FOCUSED_CELL_CLASS = "dx-scheduler-focused-cell"; const VIRTUAL_ROW_CLASS = "dx-scheduler-virtual-row"; const DATE_TABLE_DROPPABLE_CELL_CLASS = "dx-scheduler-date-table-droppable-cell"; const SCHEDULER_HEADER_SCROLLABLE_CLASS = "dx-scheduler-header-scrollable"; const SCHEDULER_SIDEBAR_SCROLLABLE_CLASS = "dx-scheduler-sidebar-scrollable"; const SCHEDULER_DATE_TABLE_SCROLLABLE_CLASS = "dx-scheduler-date-table-scrollable"; const SCHEDULER_WORKSPACE_DXPOINTERDOWN_EVENT_NAME = (0, _index.addNamespace)(_pointer.default.down, "dxSchedulerWorkSpace"); const DragEventNames = { ENTER: (0, _index.addNamespace)(_drag.enter, "dxSchedulerDateTable"), DROP: (0, _index.addNamespace)(_drag.drop, "dxSchedulerDateTable"), LEAVE: (0, _index.addNamespace)(_drag.leave, "dxSchedulerDateTable") }; const SCHEDULER_CELL_DXCLICK_EVENT_NAME = (0, _index.addNamespace)(_click.name, "dxSchedulerDateTable"); const SCHEDULER_CELL_DXPOINTERDOWN_EVENT_NAME = (0, _index.addNamespace)(_pointer.default.down, "dxSchedulerDateTable"); const SCHEDULER_CELL_DXPOINTERUP_EVENT_NAME = (0, _index.addNamespace)(_pointer.default.up, "dxSchedulerDateTable"); const SCHEDULER_CELL_DXPOINTERMOVE_EVENT_NAME = (0, _index.addNamespace)(_pointer.default.move, "dxSchedulerDateTable"); const CELL_DATA = "dxCellData"; const DATE_TABLE_MIN_CELL_WIDTH = 75; const DAY_MS = toMs("day"); const HOUR_MS = toMs("hour"); const DRAG_AND_DROP_SELECTOR = ".".concat(_m_classes.DATE_TABLE_CLASS, " td, .").concat(ALL_DAY_TABLE_CLASS, " td"); const CELL_SELECTOR = ".".concat(DATE_TABLE_CELL_CLASS, ", .").concat(ALL_DAY_TABLE_CELL_CLASS); const CELL_INDEX_CALCULATION_EPSILON = .05; const DEFAULT_WORKSPACE_RENDER_OPTIONS = { renderComponents: { header: true, timePanel: true, dateTable: true, allDayPanel: true }, generateNewData: true }; let SchedulerWorkSpace = function(_WidgetObserver) { _inheritsLoose(SchedulerWorkSpace, _WidgetObserver); function SchedulerWorkSpace() { var _this; _this = _WidgetObserver.apply(this, arguments) || this; _this.viewDirection = "vertical"; return _this } var _proto = SchedulerWorkSpace.prototype; _proto._supportedKeys = function() { const clickHandler = function(e) { e.preventDefault(); e.stopPropagation(); const selectedCells = this.cellsSelectionState.getSelectedCells(); if (null === selectedCells || void 0 === selectedCells ? void 0 : selectedCells.length) { const selectedCellsElement = selectedCells.map(cellData => this._getCellByData(cellData)).filter(cell => !!cell); e.target = selectedCellsElement; this._showPopup = true; this._cellClickAction({ event: e, cellElement: (0, _renderer.default)(selectedCellsElement), cellData: selectedCells[0] }) } }; const onArrowPressed = (e, key) => { var _a; e.preventDefault(); e.stopPropagation(); const focusedCellData = null === (_a = this.cellsSelectionState.focusedCell) || void 0 === _a ? void 0 : _a.cellData; if (focusedCellData) { const isAllDayPanelCell = focusedCellData.allDay && !this._isVerticalGroupedWorkSpace(); const isMultiSelection = e.shiftKey; const isMultiSelectionAllowed = this.option("allowMultipleCellSelection"); const isRTL = this._isRTL(); const groupCount = this._getGroupCount(); const isGroupedByDate = this.isGroupedByDate(); const isHorizontalGrouping = this._isHorizontalGroupedWorkSpace(); const focusedCellPosition = this.viewDataProvider.findCellPositionInMap(_extends(_extends({}, focusedCellData), { isAllDay: focusedCellData.allDay })); const edgeIndices = isHorizontalGrouping && isMultiSelection && !isGroupedByDate ? this.viewDataProvider.getGroupEdgeIndices(focusedCellData.groupIndex, isAllDayPanelCell) : this.viewDataProvider.getViewEdgeIndices(isAllDayPanelCell); const nextCellData = this.cellsSelectionController.handleArrowClick({ focusedCellPosition: focusedCellPosition, edgeIndices: edgeIndices, isRTL: isRTL, isGroupedByDate: isGroupedByDate, groupCount: groupCount, isMultiSelection: isMultiSelection, isMultiSelectionAllowed: isMultiSelectionAllowed, viewType: this.type, key: key, getCellDataByPosition: this.viewDataProvider.getCellData.bind(this.viewDataProvider), isAllDayPanelCell: isAllDayPanelCell, focusedCellData: focusedCellData }); this._processNextSelectedCell(nextCellData, focusedCellData, isMultiSelection && isMultiSelectionAllowed) } }; return (0, _extend.extend)(_WidgetObserver.prototype._supportedKeys.call(this), { enter: clickHandler, space: clickHandler, downArrow: e => { onArrowPressed(e, "down") }, upArrow: e => { onArrowPressed(e, "up") }, rightArrow: e => { onArrowPressed(e, "right") }, leftArrow: e => { onArrowPressed(e, "left") } }) }; _proto._isRTL = function() { return this.option("rtlEnabled") }; _proto._moveToCell = function($cell, isMultiSelection) { if (!(0, _type.isDefined)($cell) || !$cell.length) { return } const isMultiSelectionAllowed = this.option("allowMultipleCellSelection"); const currentCellData = this._getFullCellData($cell); const focusedCellData = this.cellsSelectionState.focusedCell.cellData; const nextFocusedCellData = this.cellsSelectionController.moveToCell({ isMultiSelection: isMultiSelection, isMultiSelectionAllowed: isMultiSelectionAllowed, currentCellData: currentCellData, focusedCellData: focusedCellData, isVirtualCell: $cell.hasClass(_m_classes.VIRTUAL_CELL_CLASS) }); this._processNextSelectedCell(nextFocusedCellData, focusedCellData, isMultiSelectionAllowed && isMultiSelection) }; _proto._processNextSelectedCell = function(nextCellData, focusedCellData, isMultiSelection) { const nextCellPosition = this.viewDataProvider.findCellPositionInMap({ startDate: nextCellData.startDate, groupIndex: nextCellData.groupIndex, isAllDay: nextCellData.allDay, index: nextCellData.index }); if (!this.viewDataProvider.isSameCell(focusedCellData, nextCellData)) { const $cell = nextCellData.allDay && !this._isVerticalGroupedWorkSpace() ? this._dom_getAllDayPanelCell(nextCellPosition.columnIndex) : this._dom_getDateCell(nextCellPosition); const isNextCellAllDay = nextCellData.allDay; this._setSelectedCellsStateAndUpdateSelection(isNextCellAllDay, nextCellPosition, isMultiSelection, $cell); this._dateTableScrollable.scrollToElement($cell) } }; _proto._setSelectedCellsStateAndUpdateSelection = function(isAllDay, cellPosition, isMultiSelection, $nextFocusedCell) { const nextCellCoordinates = { rowIndex: cellPosition.rowIndex, columnIndex: cellPosition.columnIndex, allDay: isAllDay }; this.cellsSelectionState.setFocusedCell(nextCellCoordinates.rowIndex, nextCellCoordinates.columnIndex, isAllDay); if (isMultiSelection) { this.cellsSelectionState.setSelectedCells(nextCellCoordinates) } else { this.cellsSelectionState.setSelectedCells(nextCellCoordinates, nextCellCoordinates) } this.updateCellsSelection(); this._updateSelectedCellDataOption(this.cellsSelectionState.getSelectedCells(), $nextFocusedCell) }; _proto._hasAllDayClass = function($cell) { return $cell.hasClass(ALL_DAY_TABLE_CELL_CLASS) }; _proto._focusInHandler = function(e) { if ((0, _renderer.default)(e.target).is(this._focusTarget()) && false !== this._isCellClick) { delete this._isCellClick; delete this._contextMenuHandled; _WidgetObserver.prototype._focusInHandler.apply(this, arguments); this.cellsSelectionState.restoreSelectedAndFocusedCells(); if (!this.cellsSelectionState.focusedCell) { const cellCoordinates = { columnIndex: 0, rowIndex: 0, allDay: this._isVerticalGroupedWorkSpace() && this.isAllDayPanelVisible }; this.cellsSelectionState.setFocusedCell(cellCoordinates.rowIndex, cellCoordinates.columnIndex, cellCoordinates.allDay); this.cellsSelectionState.setSelectedCells(cellCoordinates, cellCoordinates) } this.updateCellsSelection(); this._updateSelectedCellDataOption(this.cellsSelectionState.getSelectedCells()) } }; _proto._focusOutHandler = function() { _WidgetObserver.prototype._focusOutHandler.apply(this, arguments); if (!this._contextMenuHandled && !this._disposed) { this.cellsSelectionState.releaseSelectedAndFocusedCells(); this.viewDataProvider.updateViewData(this.generateRenderOptions()); this.updateCellsSelection() } }; _proto._focusTarget = function() { return this.$element() }; _proto._isVerticalGroupedWorkSpace = function() { var _a; return !!(null === (_a = this.option("groups")) || void 0 === _a ? void 0 : _a.length) && "vertical" === this.option("groupOrientation") }; _proto._isHorizontalGroupedWorkSpace = function() { var _a; return !!(null === (_a = this.option("groups")) || void 0 === _a ? void 0 : _a.length) && "horizontal" === this.option("groupOrientation") }; _proto._isWorkSpaceWithCount = function() { return this.option("intervalCount") > 1 }; _proto._isWorkspaceWithOddCells = function() { return .5 === this.option("hoursInterval") && !this.isVirtualScrolling() }; _proto._getRealGroupOrientation = function() { return this._isVerticalGroupedWorkSpace() ? "vertical" : "horizontal" }; _proto.createRAllDayPanelElements = function() { this._$allDayPanel = (0, _renderer.default)("<div>").addClass(ALL_DAY_PANEL_CLASS); this._$allDayTitle = (0, _renderer.default)("<div>").appendTo(this._$headerPanelEmptyCell) }; _proto._dateTableScrollableConfig = function() { let config = { useKeyboard: false, bounceEnabled: false, updateManually: true, onScroll: () => { var _a; null === (_a = this._groupedStrategy.cache) || void 0 === _a ? void 0 : _a.clear() } }; if (this._needCreateCrossScrolling()) { config = (0, _extend.extend)(config, this._createCrossScrollingConfig(config)) } if (this.isVirtualScrolling() && (this.virtualScrollingDispatcher.horizontalScrollingAllowed || this.virtualScrollingDispatcher.height)) { const currentOnScroll = config.onScroll; config = _extends(_extends({}, config), { onScroll: e => { null === currentOnScroll || void 0 === currentOnScroll ? void 0 : currentOnScroll(e); this.virtualScrollingDispatcher.handleOnScrollEvent(null === e || void 0 === e ? void 0 : e.scrollOffset) } }) } return config }; _proto._createCrossScrollingConfig = function(_ref) { let { onScroll: onScroll } = _ref; return { direction: "both", onScroll: event => { null === onScroll || void 0 === onScroll ? void 0 : onScroll(); this._scrollSync.sidebar({ top: event.scrollOffset.top }); this._scrollSync.header({ left: event.scrollOffset.left }) }, onEnd: () => { this.option("onScrollEnd")() } } }; _proto._headerScrollableConfig = function() { return { useKeyboard: false, showScrollbar: "never", direction: "horizontal", useNative: false, updateManually: true, bounceEnabled: false, onScroll: event => { this._scrollSync.dateTable({ left: event.scrollOffset.left }) } } }; _proto._visibilityChanged = function(visible) { this.cache.clear(); if (visible) { this._updateGroupTableHeight() } if (visible && this._needCreateCrossScrolling()) { this._setTableSizes() } }; _proto._setTableSizes = function() { this.cache.clear(); this._attachTableClasses(); let cellWidth = this.getCellWidth(); if (cellWidth < this.getCellMinWidth()) { cellWidth = this.getCellMinWidth() } const minWidth = this.getWorkSpaceMinWidth(); const groupCount = this._getGroupCount(); const totalCellCount = this._getTotalCellCount(groupCount); let width = cellWidth * totalCellCount; if (width < minWidth) { width = minWidth }(0, _size.setWidth)(this._$headerPanel, width); (0, _size.setWidth)(this._$dateTable, width); if (this._$allDayTable) { (0, _size.setWidth)(this._$allDayTable, width) } this._attachHeaderTableClasses(); this._updateGroupTableHeight(); this._updateScrollable() }; _proto.getWorkSpaceMinWidth = function() { return this._groupedStrategy.getWorkSpaceMinWidth() }; _proto._dimensionChanged = function() { if (!this._isVisible()) { return } if (this.option("crossScrollingEnabled")) { this._setTableSizes() } this.updateHeaderEmptyCellWidth(); this._updateScrollable(); this.cache.clear() }; _proto._needCreateCrossScrolling = function() { return this.option("crossScrollingEnabled") }; _proto._getElementClass = function() { return (0, _common.noop)() }; _proto._getRowCount = function() { return this.viewDataProvider.getRowCount({ intervalCount: this.option("intervalCount"), currentDate: this.option("currentDate"), viewType: this.type, hoursInterval: this.option("hoursInterval"), startDayHour: this.option("startDayHour"), endDayHour: this.option("endDayHour") }) }; _proto._getCellCount = function() { return this.viewDataProvider.getCellCount({ intervalCount: this.option("intervalCount"), currentDate: this.option("currentDate"), viewType: this.type, hoursInterval: this.option("hoursInterval"), startDayHour: this.option("startDayHour"), endDayHour: this.option("endDayHour") }) }; _proto.isRenovatedRender = function() { return this.renovatedRenderSupported() && this.option("renovateRender") }; _proto._isVirtualModeOn = function() { return "virtual" === this.option("scrolling.mode") }; _proto.isVirtualScrolling = function() { return this.isRenovatedRender() && this._isVirtualModeOn() }; _proto._initVirtualScrolling = function() { if (this.virtualScrollingDispatcher) { this.virtualScrollingDispatcher.dispose(); this.virtualScrollingDispatcher = null } this.virtualScrollingDispatcher = new _m_virtual_scrolling.VirtualScrollingDispatcher(this._getVirtualScrollingDispatcherOptions()); this.virtualScrollingDispatcher.attachScrollableEvents(); this.renderer = new _m_virtual_scrolling.VirtualScrollingRenderer(this) }; _proto.onDataSourceChanged = function(argument) {}; _proto.isGroupedAllDayPanel = function() { return (0, _index3.calculateIsGroupedAllDayPanel)(this.option("groups"), this.option("groupOrientation"), this.isAllDayPanelVisible) }; _proto.generateRenderOptions = function(isProvideVirtualCellsWidth) { var _a; const groupCount = this._getGroupCount(); const groupOrientation = groupCount > 0 ? this.option("groupOrientation") : this._getDefaultGroupStrategy(); const options = _extends({ groupByDate: this.option("groupByDate"), startRowIndex: 0, startCellIndex: 0, groupOrientation: groupOrientation, today: null === (_a = this._getToday) || void 0 === _a ? void 0 : _a.call(this), groups: this.option("groups"), isProvideVirtualCellsWidth: isProvideVirtualCellsWidth, isAllDayPanelVisible: this.isAllDayPanelVisible, selectedCells: this.cellsSelectionState.getSelectedCells(), focusedCell: this.cellsSelectionState.focusedCell, headerCellTextFormat: this._getFormat(), getDateForHeaderText: (_, date) => date, viewOffset: this.option("viewOffset"), startDayHour: this.option("startDayHour"), endDayHour: this.option("endDayHour"), cellDuration: this.getCellDuration(), viewType: this.type, intervalCount: this.option("intervalCount"), hoursInterval: this.option("hoursInterval"), currentDate: this.option("currentDate"), startDate: this.option("startDate"), firstDayOfWeek: this.option("firstDayOfWeek"), showCurrentTimeIndicator: this.option("showCurrentTimeIndicator") }, this.virtualScrollingDispatcher.getRenderState()); return options }; _proto.renovatedRenderSupported = function() { return true }; _proto._updateGroupTableHeight = function() { if (this._isVerticalGroupedWorkSpace() && (0, _window.hasWindow)()) { this._setHorizontalGroupHeaderCellsHeight() } }; _proto.updateHeaderEmptyCellWidth = function() { if ((0, _window.hasWindow)() && this._isRenderHeaderPanelEmptyCell()) { const timePanelWidth = this.getTimePanelWidth(); const groupPanelWidth = this.getGroupTableWidth(); this._$headerPanelEmptyCell.css("width", timePanelWidth + groupPanelWidth) } }; _proto._isGroupsSpecified = function(resources) { var _a; return (null === (_a = this.option("groups")) || void 0 === _a ? void 0 : _a.length) && resources }; _proto._getGroupIndexByResourceId = function(id) { const groups = this.option("groups"); const resourceTree = (0, _m_utils2.createResourcesTree)(groups); if (!resourceTree.length) { return 0 } return this._getGroupIndexRecursively(resourceTree, id) }; _proto._getGroupIndexRecursively = function(resourceTree, id) { const currentKey = resourceTree[0].name; const currentValue = id[currentKey]; return resourceTree.reduce((prevIndex, _ref2) => { let { leafIndex: leafIndex, value: value, children: children } = _ref2; const areValuesEqual = currentValue === value; if (areValuesEqual && void 0 !== leafIndex) { return leafIndex } if (areValuesEqual) { return this._getGroupIndexRecursively(children, id) } return prevIndex }, 0) }; _proto._getViewStartByOptions = function() { return (0, _index3.getViewStartByOptions)(this.option("startDate"), this.option("currentDate"), this._getIntervalDuration(), this.option("startDate") ? this._calculateViewStartDate() : void 0) }; _proto._getIntervalDuration = function() { return this.viewDataProvider.getIntervalDuration(this.option("intervalCount")) }; _proto._getHeaderDate = function() { return this.getStartViewDate() }; _proto._calculateViewStartDate = function() { return (0, _index3.calculateViewStartDate)(this.option("startDate")) }; _proto._firstDayOfWeek = function() { return this.viewDataProvider.getFirstDayOfWeek(this.option("firstDayOfWeek")) }; _proto._attachEvents = function() { this._createSelectionChangedAction(); this._attachClickEvent(); this._attachContextMenuEvent() }; _proto._attachClickEvent = function() { const that = this; const pointerDownAction = this._createAction(e => { that._pointerDownHandler(e.event) }); this._createCellClickAction(); const cellSelector = ".".concat(DATE_TABLE_CELL_CLASS, ",.").concat(ALL_DAY_TABLE_CELL_CLASS); const $element = this.$element(); _events_engine.default.off($element, SCHEDULER_WORKSPACE_DXPOINTERDOWN_EVENT_NAME); _events_engine.default.off($element, SCHEDULER_CELL_DXCLICK_EVENT_NAME); _events_engine.default.on($element, SCHEDULER_WORKSPACE_DXPOINTERDOWN_EVENT_NAME, e => { if ((0, _index.isMouseEvent)(e) && e.which > 1) { e.preventDefault(); return } pointerDownAction({ event: e }) }); _events_engine.default.on($element, SCHEDULER_CELL_DXCLICK_EVENT_NAME, cellSelector, e => { const $cell = (0, _renderer.default)(e.target); that._cellClickAction({ event: e, cellElement: (0, _element.getPublicElement)($cell), cellData: that.getCellData($cell) }) }) }; _proto._createCellClickAction = function() { this._cellClickAction = this._createActionByOption("onCellClick", { afterExecute: e => this._cellClickHandler(e.args[0].event) }) }; _proto._createSelectionChangedAction = function() { this._selectionChangedAction = this._createActionByOption("onSelectionChanged") }; _proto._cellClickHandler = function(argument) { if (this._showPopup) { delete this._showPopup; this._handleSelectedCellsClick() } }; _proto._pointerDownHandler = function(e) { const $target = (0, _renderer.default)(e.target); if (!$target.hasClass(DATE_TABLE_CELL_CLASS) && !$target.hasClass(ALL_DAY_TABLE_CELL_CLASS)) { this._isCellClick = false; return } this._isCellClick = true; if ($target.hasClass("dx-scheduler-focused-cell")) { this._showPopup = true } else { const cellCoordinates = this._getCoordinatesByCell($target); const isAllDayCell = this._hasAllDayClass($target); this._setSelectedCellsStateAndUpdateSelection(isAllDayCell, cellCoordinates, false, $target) } }; _proto._handleSelectedCellsClick = function() { const selectedCells = this.cellsSelectionState.getSelectedCells(); const firstCellData = selectedCells[0]; const lastCellData = selectedCells[selectedCells.length - 1]; const result = { startDate: firstCellData.startDate, endDate: lastCellData.endDate }; if (void 0 !== lastCellData.allDay) { result.allDay = lastCellData.allDay } this.option("onSelectedCellsClick")(result, lastCellData.groups) }; _proto._attachContextMenuEvent = function() { this._createContextMenuAction(); const cellSelector = ".".concat(DATE_TABLE_CELL_CLASS, ",.").concat(ALL_DAY_TABLE_CELL_CLASS); const $element = this.$element(); const eventName = (0, _index.addNamespace)(_contextmenu.name, this.NAME); _events_engine.default.off($element, eventName, cellSelector); _events_engine.default.on($element, eventName, cellSelector, this._contextMenuHandler.bind(this)) }; _proto._contextMenuHandler = function(e) { const $cell = (0, _renderer.default)(e.target); this._contextMenuAction({ event: e, cellElement: (0, _element.getPublicElement)($cell), cellData: this.getCellData($cell) }); this._contextMenuHandled = true }; _proto._createContextMenuAction = function() { this._contextMenuAction = this._createActionByOption("onCellContextMenu") }; _proto._getGroupHeaderContainer = function() { if (this._isVerticalGroupedWorkSpace()) { return this._$groupTable } return this._$thead }; _proto._getDateHeaderContainer = function() { return this._$thead }; _proto._getCalculateHeaderCellRepeatCount = function() { return this._groupedStrategy.calculateHeaderCellRepeatCount() }; _proto._updateScrollable = function() { var _a, _b; this._dateTableScrollable.update(); null === (_a = this._headerScrollable) || void 0 === _a ? void 0 : _a.update(); null === (_b = this._sidebarScrollable) || void 0 === _b ? void 0 : _b.update() }; _proto._getTimePanelRowCount = function() { return this._getCellCountInDay() }; _proto._getCellCountInDay = function() { const hoursInterval = this.option("hoursInterval"); const startDayHour = this.option("startDayHour"); const endDayHour = this.option("endDayHour"); return this.viewDataProvider.getCellCountInDay(startDayHour, endDayHour, hoursInterval) }; _proto._getTotalCellCount = function(groupCount) { return this._groupedStrategy.getTotalCellCount(groupCount) }; _proto._getTotalRowCount = function(groupCount, includeAllDayPanelRows) { let result = this._groupedStrategy.getTotalRowCount(groupCount); if (includeAllDayPanelRows && this.isAllDayPanelVisible) { result += groupCount } return result }; _proto._getGroupIndex = function(rowIndex, columnIndex) { return this._groupedStrategy.getGroupIndex(rowIndex, columnIndex) }; _proto.calculateEndDate = function(startDate) { const { viewDataGenerator: viewDataGenerator } = this.viewDataProvider; return viewDataGenerator.calculateEndDate(startDate, viewDataGenerator.getInterval(this.option("hoursInterval")), this.option("endDayHour")) }; _proto._getGroupCount = function() { return (0, _index3.getGroupCount)(this.option("groups")) }; _proto._attachTablesEvents = function() { const element = this.$element(); this._attachDragEvents(element); this._attachPointerEvents(element) }; _proto._detachDragEvents = function(element) { _events_engine.default.off(element, DragEventNames.ENTER); _events_engine.default.off(element, DragEventNames.LEAVE); _events_engine.default.off(element, DragEventNames.DROP) }; _proto._attachDragEvents = function(element) { this._detachDragEvents(element); _events_engine.default.on(element, DragEventNames.ENTER, DRAG_AND_DROP_SELECTOR, { checkDropTarget: (target, event) => !this._isOutsideScrollable(target, event) }, e => { if (!this.preventDefaultDragging) { this.removeDroppableCellClass(); (0, _renderer.default)(e.target).addClass(DATE_TABLE_DROPPABLE_CELL_CLASS) } }); _events_engine.default.on(element, DragEventNames.LEAVE, () => { if (!this.preventDefaultDragging) { this.removeDroppableCellClass() } }); _events_engine.default.on(element, DragEventNames.DROP, DRAG_AND_DROP_SELECTOR, () => { var _a, _b; if (!this.dragBehavior) { return } if (!(null === (_a = this.dragBehavior) || void 0 === _a ? void 0 : _a.dragBetweenComponentsPromise)) { this.dragBehavior.removeDroppableClasses(); return } null === (_b = this.dragBehavior.dragBetweenComponentsPromise) || void 0 === _b ? void 0 : _b.then(() => { this.dragBehavior.removeDroppableClasses() }) }) }; _proto._attachPointerEvents = function(element) { let isPointerDown = false; _events_engine.default.off(element, SCHEDULER_CELL_DXPOINTERMOVE_EVENT_NAME); _events_engine.default.off(element, SCHEDULER_CELL_DXPOINTERDOWN_EVENT_NAME); _events_engine.default.on(element, SCHEDULER_CELL_DXPOINTERDOWN_EVENT_NAME, DRAG_AND_DROP_SELECTOR, e => { if ((0, _index.isMouseEvent)(e) && 1 === e.which) { isPointerDown = true; this.$element().addClass(WORKSPACE_WITH_MOUSE_SELECTION_CLASS); _events_engine.default.off(_dom_adapter.default.getDocument(), SCHEDULER_CELL_DXPOINTERUP_EVENT_NAME); _events_engine.default.on(_dom_adapter.default.getDocument(), SCHEDULER_CELL_DXPOINTERUP_EVENT_NAME, () => { isPointerDown = false; this.$element().removeClass(WORKSPACE_WITH_MOUSE_SELECTION_CLASS) }) } }); _events_engine.default.on(element, SCHEDULER_CELL_DXPOINTERMOVE_EVENT_NAME, DRAG_AND_DROP_SELECTOR, e => { if (isPointerDown && this._dateTableScrollable && !this._dateTableScrollable.option("scrollByContent")) { e.preventDefault(); e.stopPropagation(); this._moveToCell((0, _renderer.default)(e.target), true) } }) }; _proto._getFormat = function() { return abstract() }; _proto.getWorkArea = function() { return this._$dateTableContainer }; _proto.getScrollable = function() { return this._dateTableScrollable }; _proto.getScrollableScrollTop = function() { return this._dateTableScrollable.scrollTop() }; _proto.getGroupedScrollableScrollTop = function(allDay) { return this._groupedStrategy.getScrollableScrollTop(allDay) }; _proto.getScrollableScrollLeft = function() { return this._dateTableScrollable.scrollLeft() }; _proto.getScrollableOuterWidth = function() { return this._dateTableScrollable.scrollWidth() }; _proto.getScrollableContainer = function() { return (0, _renderer.default)(this._dateTableScrollable.container()) }; _proto.getHeaderPanelHeight = function() { return this._$headerPanel && (0, _size.getOuterHeight)(this._$headerPanel, true) }; _proto.getTimePanelWidth = function() { return this._$timePanel && (0, _position.getBoundingRect)(this._$timePanel.get(0)).width }; _proto.getGroupTableWidth = function() { return this._$groupTable ? (0, _size.getOuterWidth)(this._$groupTable) : 0 }; _proto.getWorkSpaceLeftOffset = function() { return this._groupedStrategy.getLeftOffset() }; _proto._getCellCoordinatesByIndex = function(index) { const columnIndex = Math.floor(index / this._getRowCount()); const rowIndex = index - this._getRowCount() * columnIndex; return { columnIndex: columnIndex, rowIndex: rowIndex } }; _proto._getDateGenerationOptions = function() { var _a; return { startDayHour: this.option("startDayHour"), endDayHour: this.option("endDayHour"), isWorkView: this.viewDataProvider.viewDataGenerator.isWorkView, interval: null === (_a = this.viewDataProvider.viewDataGenerator) || void 0 === _a ? void 0 : _a.getInterval(this.option("hoursInterval")), startViewDate: this.getStartViewDate(), firstDayOfWeek: this._firstDayOfWeek() } }; _proto._getIntervalBetween = function(currentDate, allDay) { const firstViewDate = this.getStartViewDate(); const startDayTime = this.option("startDayHour") * HOUR_MS; const timeZoneOffset = _date.default.getTimezonesDifference(firstViewDate, currentDate); const fullInterval = currentDate.getTime() - firstViewDate.getTime() - timeZoneOffset; const days = this._getDaysOfInterval(fullInterval, startDayTime); const weekendsCount = this._getWeekendsCount(days); let result = (days - weekendsCount) * DAY_MS; if (!allDay) { const { hiddenInterval: hiddenInterval } = this.viewDataProvider; const visibleDayDuration = this.getVisibleDayDuration(); result = fullInterval - days * hiddenInterval - weekendsCount * visibleDayDuration } return result }; _proto._getWeekendsCount = function(argument) { return 0 }; _proto._getDaysOfInterval = function(fullInterval, startDayTime) { return Math.floor((fullInterval + startDayTime) / DAY_MS) }; _proto._updateIndex = function(index) { return index * this._getRowCount() }; _proto._getDroppableCell = function() { return this._getDateTables().find(".".concat(DATE_TABLE_DROPPABLE_CELL_CLASS)) }; _proto._getWorkSpaceWidth = function() { return this.cache.get("workspaceWidth", () => { if (this._needCreateCrossScrolling()) { return (0, _position.getBoundingRect)(this._$dateTable.get(0)).width } const totalWidth = (0, _position.getBoundingRect)(this.$element().get(0)).width; const timePanelWidth = this.getTimePanelWidth(); const groupTableWidth = this.getGroupTableWidth(); return totalWidth - timePanelWidth - groupTableWidth }) }; _proto._getCellByCoordinates = function(cellCoordinates, groupIndex, inAllDayRow) { const indexes = this._groupedStrategy.prepareCellIndexes(cellCoordinates, groupIndex, inAllDayRow); return this._dom_getDateCell(indexes) }; _proto._dom_getDateCell = function(position) { return this._$dateTable.find("tr:not(.".concat(VIRTUAL_ROW_CLASS, ")")).eq(position.rowIndex).find("td:not(.".concat(_m_classes.VIRTUAL_CELL_CLASS, ")")).eq(position.columnIndex) }; _proto._dom_getAllDayPanelCell = function(columnIndex) { return this._$allDayPanel.find("tr").eq(0).find("td").eq(columnIndex) }; _proto._getCells = function(allDay, direction) { const cellClass = allDay ? ALL_DAY_TABLE_CELL_CLASS : DATE_TABLE_CELL_CLASS; if ("vertical" === direction) { let result = []; for (let i = 1;; i++) { const cells = this.$element().find("tr .".concat(cellClass, ":nth-child(").concat(i, ")")); if (!cells.length) { break } result = result.concat(cells.toArray()) } return (0, _renderer.default)(result) } return this.$element().find(".".concat(cellClass)) }; _proto._getFirstAndLastDataTableCell = function() { const selector = this.isVirtualScrolling() ? ".".concat(DATE_TABLE_CELL_CLASS, ", .").concat(_m_classes.VIRTUAL_CELL_CLASS) : ".".concat(DATE_TABLE_CELL_CLASS); const $cells = this.$element().find(selector); return [$cells[0], $cells[$cells.length - 1]] }; _proto._getAllCells = function(allDay) { if (this._isVerticalGroupedWorkSpace()) { return this._$dateTable.find("td:not(.".concat(_m_classes.VIRTUAL_CELL_CLASS, ")")) } const cellClass = allDay && this.supportAllDayRow() ? ALL_DAY_TABLE_CELL_CLASS : DATE_TABLE_CELL_CLASS; return this.$element().find(".".concat(cellClass)) }; _proto._setHorizontalGroupHeaderCellsHeight = function() { const { height: height } = (0, _position.getBoundingRect)(this._$dateTable.get(0)); (0, _size.setOuterHeight)(this._$groupTable, height) }; _proto._getGroupHeaderCells = function() { return this.$element().find(".".concat(GROUP_HEADER_CLASS)) }; _proto._getScrollCoordinates = function(hours, minutes, date, groupIndex, allDay) { const currentDate = date || new Date(this.option("currentDate")); const startDayHour = this.option("startDayHour"); const endDayHour = this.option("endDayHour"); if (hours < startDayHour) { hours = startDayHour } if (hours >= endDayHour) { hours = endDayHour - 1 } currentDate.setHours(hours, minutes, 0, 0); const cell = this.viewDataProvider.findGlobalCellPosition(currentDate, groupIndex, allDay); const { position: position, cellData: cellData } = cell; return this.virtualScrollingDispatcher.calculateCoordinatesByDataAndPosition(cellData, position, currentDate, (0, _index3.isDateAndTimeView)(this.type), "vertical" === this.viewDirection) }; _proto._isOutsideScrollable = function(target, event) { const $dateTableScrollableElement = this._dateTableScrollable.$element(); const scrollableSize = (0, _position.getBoundingRect)($dateTableScrollableElement.get(0)); const window = (0, _window.getWindow)(); const isTargetInAllDayPanel = !(0, _renderer.default)(target).closest($dateTableScrollableElement).length; const isOutsideHorizontalScrollable = event.pageX < scrollableSize.left || event.pageX > scrollableSize.left + scrollableSize.width + (window.scrollX || 0); const isOutsideVerticalScrollable = event.pageY < scrollableSize.top || event.pageY > scrollableSize.top + scrollableSize.height + (window.scrollY || 0); if (isTargetInAllDayPanel && !isOutsideHorizontalScrollable) { return false } return isOutsideVerticalScrollable || isOutsideHorizontalScrollable }; _proto.setCellDataCache = function(cellCoordinates, groupIndex, $cell) { const key = JSON.stringify({ rowIndex: cellCoordinates.rowIndex, columnIndex: cellCoordinates.columnIndex, groupIndex: groupIndex }); this.cache.set(key, this.getCellData($cell)) }; _proto.setCellDataCacheAlias = function(appointment, geometry) { const key = JSON.stringify({ rowIndex: appointment.rowIndex, columnIndex: appointment.columnIndex, groupIndex: appointment.groupIndex }); const aliasKey = JSON.stringify({ top: geometry.top, left: geometry.left }); this.cache.set(aliasKey, this.cache.get(key)) }; _proto.supportAllDayRow = function() { return true }; _proto.keepOriginalHours = function() { return false }; _proto._filterCellDataFields = function(cellData) { return (0, _extend.extend)(true, {}, { startDate: cellData.startDate, endDate: cellData.endDate, groups: cellData.groups, groupIndex: cellData.groupIndex, allDay: cellData.allDay }) }; _proto.getCellData = function($cell) { const cellData = this._getFullCellData($cell) || {}; return this._filterCellDataFields(cellData) }; _proto._getFullCellData = function($cell) { const currentCell = $cell[0]; if (currentCell) { return this._getDataByCell($cell) } return }; _proto._getVirtualRowOffset = function() { return this.virtualScrollingDispatcher.virtualRowOffset }; _proto._getVirtualCellOffset = function() { return this.virtualScrollingDispatcher.virtualCellOffset }; _proto._getDataByCell = function($cell) { const rowIndex = $cell.parent().index() - this.virtualScrollingDispatcher.topVirtualRowsCount; const columnIndex = $cell.index() - this.virtualScrollingDispatcher.leftVirtualCellsCount; const { viewDataProvider: viewDataProvider } = this; const isAllDayCell = this._hasAllDayClass($cell); const cellData = viewDataProvider.getCellData(rowIndex, columnIndex, isAllDayCell); return cellData || void 0 }; _proto.isGroupedByDate = function() { return this.option("groupByDate") && this._isHorizontalGroupedWorkSpace() && this._getGroupCount() > 0 }; _proto.getCellIndexByDate = function(date, inAllDayRow) { const { viewDataGenerator: viewDataGenerator } = this.viewDataProvider; const timeInterval = inAllDayRow ? 864e5 : viewDa