devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
364 lines (350 loc) • 13.4 kB
JavaScript
/**
* DevExtreme (ui/scheduler/workspaces/ui.scheduler.work_space.grouped.strategy.vertical.js)
* Version: 20.1.7
* Build date: Tue Aug 25 2020
*
* Copyright (c) 2012 - 2020 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";
var _position = require("../../../core/utils/position");
var _uiSchedulerWork_spaceGrouped = require("./ui.scheduler.work_space.grouped.strategy");
var _uiSchedulerWork_spaceGrouped2 = _interopRequireDefault(_uiSchedulerWork_spaceGrouped);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
function _typeof(obj) {
"@babel/helpers - typeof";
if ("function" === typeof Symbol && "symbol" === typeof Symbol.iterator) {
_typeof = function(obj) {
return typeof obj
}
} else {
_typeof = function(obj) {
return obj && "function" === typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj
}
}
return _typeof(obj)
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function")
}
}
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, descriptor.key, descriptor)
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) {
_defineProperties(Constructor.prototype, protoProps)
}
if (staticProps) {
_defineProperties(Constructor, staticProps)
}
return Constructor
}
function _inherits(subClass, superClass) {
if ("function" !== typeof superClass && null !== superClass) {
throw new TypeError("Super expression must either be null or a function")
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) {
_setPrototypeOf(subClass, superClass)
}
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function(o, p) {
o.__proto__ = p;
return o
};
return _setPrototypeOf(o, p)
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function() {
var result, Super = _getPrototypeOf(Derived);
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget)
} else {
result = Super.apply(this, arguments)
}
return _possibleConstructorReturn(this, result)
}
}
function _possibleConstructorReturn(self, call) {
if (call && ("object" === _typeof(call) || "function" === typeof call)) {
return call
}
return _assertThisInitialized(self)
}
function _assertThisInitialized(self) {
if (void 0 === self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
}
return self
}
function _isNativeReflectConstruct() {
if ("undefined" === typeof Reflect || !Reflect.construct) {
return false
}
if (Reflect.construct.sham) {
return false
}
if ("function" === typeof Proxy) {
return true
}
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
return true
} catch (e) {
return false
}
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(o) {
return o.__proto__ || Object.getPrototypeOf(o)
};
return _getPrototypeOf(o)
}
var VERTICAL_GROUPED_ATTR = "dx-group-column-count";
var DATE_HEADER_OFFSET = 10;
var WORK_SPACE_BORDER = 1;
var VerticalGroupedStrategy = function(_GroupedStrategy) {
_inherits(VerticalGroupedStrategy, _GroupedStrategy);
var _super = _createSuper(VerticalGroupedStrategy);
function VerticalGroupedStrategy() {
_classCallCheck(this, VerticalGroupedStrategy);
return _super.apply(this, arguments)
}
_createClass(VerticalGroupedStrategy, [{
key: "prepareCellIndexes",
value: function(cellCoordinates, groupIndex, inAllDayRow) {
var rowIndex = cellCoordinates.rowIndex + groupIndex * this._workSpace._getRowCount();
if (this._workSpace.supportAllDayRow() && this._workSpace.option("showAllDayPanel")) {
rowIndex += groupIndex;
if (!inAllDayRow) {
rowIndex += 1
}
}
return {
rowIndex: rowIndex,
cellIndex: cellCoordinates.cellIndex
}
}
}, {
key: "calculateCellIndex",
value: function(rowIndex, cellIndex) {
rowIndex %= this._workSpace._getRowCount();
return this._workSpace._getRowCount() * cellIndex + rowIndex
}
}, {
key: "getGroupIndex",
value: function(rowIndex) {
return Math.floor(rowIndex / this._workSpace._getRowCount())
}
}, {
key: "calculateHeaderCellRepeatCount",
value: function() {
return 1
}
}, {
key: "insertAllDayRowsIntoDateTable",
value: function() {
return this._workSpace.option("showAllDayPanel")
}
}, {
key: "getTotalCellCount",
value: function() {
return this._workSpace._getCellCount()
}
}, {
key: "getTotalRowCount",
value: function() {
return this._workSpace._getRowCount() * this._workSpace._getGroupCount()
}
}, {
key: "addAdditionalGroupCellClasses",
value: function(cellClass, index, i, j) {
cellClass = this._addLastGroupCellClass(cellClass, i + 1);
return this._addFirstGroupCellClass(cellClass, i + 1)
}
}, {
key: "_addLastGroupCellClass",
value: function(cellClass, index) {
if (index % this._workSpace._getRowCount() === 0) {
return cellClass + " " + this.getLastGroupCellClass()
}
return cellClass
}
}, {
key: "_addFirstGroupCellClass",
value: function(cellClass, index) {
if ((index - 1) % this._workSpace._getRowCount() === 0) {
return cellClass + " " + this.getFirstGroupCellClass()
}
return cellClass
}
}, {
key: "getHorizontalMax",
value: function() {
return this._workSpace.getMaxAllowedPosition()[0]
}
}, {
key: "getVerticalMax",
value: function(groupIndex) {
var maxAllowedPosition = this._workSpace.getMaxAllowedVerticalPosition()[groupIndex];
maxAllowedPosition += this._getOffsetByAllDayPanel(groupIndex);
return maxAllowedPosition
}
}, {
key: "_getOffsetByAllDayPanel",
value: function(groupIndex) {
var result = 0;
if (this._workSpace.supportAllDayRow() && this._workSpace.option("showAllDayPanel")) {
result = this._workSpace.getCellHeight() * (groupIndex + 1)
}
return result
}
}, {
key: "_getGroupTop",
value: function(groupIndex) {
return this._workSpace.getMaxAllowedVerticalPosition()[groupIndex] - this._workSpace.getCellHeight() * this._workSpace._getRowCount()
}
}, {
key: "calculateTimeCellRepeatCount",
value: function() {
return this._workSpace._getGroupCount() || 1
}
}, {
key: "getWorkSpaceMinWidth",
value: function() {
var minWidth = this._workSpace._getWorkSpaceWidth();
var workspaceContainerWidth = (0, _position.getBoundingRect)(this._workSpace.$element().get(0)).width - this._workSpace.getTimePanelWidth() - this._workSpace.getGroupTableWidth() - 2 * WORK_SPACE_BORDER;
if (minWidth < workspaceContainerWidth) {
minWidth = workspaceContainerWidth
}
return minWidth
}
}, {
key: "getAllDayOffset",
value: function() {
return 0
}
}, {
key: "getAllDayTableHeight",
value: function() {
return 0
}
}, {
key: "getGroupCountAttr",
value: function() {
return {
attr: VERTICAL_GROUPED_ATTR,
count: this._workSpace.option("groups") && this._workSpace.option("groups").length
}
}
}, {
key: "getLeftOffset",
value: function() {
return this._workSpace.getTimePanelWidth() + this._workSpace.getGroupTableWidth()
}
}, {
key: "getGroupBoundsOffset",
value: function(cellCount, $cells, cellWidth, coordinates) {
var groupIndex = coordinates.groupIndex;
var startOffset = $cells.eq(0).offset().left;
var endOffset = $cells.eq(cellCount - 1).offset().left + cellWidth;
var dayHeight = this._workSpace._calculateDayDuration() / this._workSpace.option("hoursInterval") * this._workSpace.getCellHeight();
var scrollTop = this.getScrollableScrollTop();
var topOffset = groupIndex * dayHeight + (0, _position.getBoundingRect)(this._workSpace._$thead.get(0)).height + this._workSpace.invoke("getHeaderHeight") + DATE_HEADER_OFFSET - scrollTop;
if (this._workSpace.option("showAllDayPanel") && this._workSpace.supportAllDayRow()) {
topOffset += this._workSpace.getCellHeight() * (groupIndex + 1)
}
var bottomOffset = topOffset + dayHeight;
return {
left: startOffset,
right: endOffset,
top: topOffset,
bottom: bottomOffset
}
}
}, {
key: "shiftIndicator",
value: function($indicator, height, rtlOffset, i) {
var offset = this._workSpace.getIndicatorOffset(0);
var tableOffset = this._workSpace.option("crossScrollingEnabled") ? 0 : this._workSpace.getGroupTableWidth();
var horizontalOffset = rtlOffset ? rtlOffset - offset : offset;
var verticalOffset = this._workSpace._getRowCount() * this._workSpace.getCellHeight() * i;
if (this._workSpace.supportAllDayRow() && this._workSpace.option("showAllDayPanel")) {
verticalOffset += this._workSpace.getAllDayHeight() * (i + 1)
}
$indicator.css("left", horizontalOffset + tableOffset);
$indicator.css("top", height + verticalOffset)
}
}, {
key: "getShaderOffset",
value: function(i, width) {
var offset = this._workSpace.option("crossScrollingEnabled") ? 0 : this._workSpace.getGroupTableWidth();
return this._workSpace.option("rtlEnabled") ? (0, _position.getBoundingRect)(this._$container.get(0)).width - offset - this._workSpace.getWorkSpaceLeftOffset() - width : offset
}
}, {
key: "getShaderTopOffset",
value: function(i) {
return 0
}
}, {
key: "getShaderHeight",
value: function() {
var height = this._workSpace.getIndicationHeight();
if (this._workSpace.supportAllDayRow() && this._workSpace.option("showAllDayPanel")) {
height += this._workSpace.getCellHeight()
}
return height
}
}, {
key: "getShaderMaxHeight",
value: function() {
var height = this._workSpace._getRowCount() * this._workSpace.getCellHeight();
if (this._workSpace.supportAllDayRow() && this._workSpace.option("showAllDayPanel")) {
height += this._workSpace.getCellHeight()
}
return height
}
}, {
key: "getShaderWidth",
value: function() {
return this._workSpace.getIndicationWidth(0)
}
}, {
key: "getScrollableScrollTop",
value: function() {
return this._workSpace.getScrollable().scrollTop()
}
}, {
key: "getGroupIndexByCell",
value: function($cell) {
var rowIndex = $cell.parent().index();
var rowCount = this._workSpace._getRowCountWithAllDayRows();
return Math.ceil((rowIndex + 1) / rowCount)
}
}]);
return VerticalGroupedStrategy
}(_uiSchedulerWork_spaceGrouped2.default);
module.exports = VerticalGroupedStrategy;