devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
186 lines (185 loc) • 7.53 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/workspaces/work_space_grouped_strategy_vertical.js)
* Version: 26.1.4
* Build date: Fri Jul 24 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
getBoundingRect
} from "../../../core/utils/position";
import {
calculateDayDuration,
getVerticalGroupCountClass
} from "../../scheduler/r1/utils/index";
import {
WORK_SPACE_BORDER_PX
} from "../../scheduler/workspaces/const";
import {
FIRST_GROUP_CELL_CLASS,
LAST_GROUP_CELL_CLASS
} from "../classes";
import {
Cache
} from "../global_cache";
class VerticalGroupedStrategy {
constructor(config) {
this.config = config;
this.cache = new Cache
}
prepareCellIndexes(cellCoordinates, groupIndex, inAllDayRow) {
let rowIndex = cellCoordinates.rowIndex + groupIndex * this.config.getRowCount();
if (this.config.supportAllDayRow() && this.config.showAllDayPanel()) {
rowIndex += groupIndex;
if (!inAllDayRow) {
rowIndex += 1
}
}
return {
rowIndex: rowIndex,
columnIndex: cellCoordinates.columnIndex
}
}
getGroupIndex(rowIndex) {
return Math.floor(rowIndex / this.config.getRowCount())
}
calculateHeaderCellRepeatCount() {
return 1
}
insertAllDayRowsIntoDateTable() {
return this.config.showAllDayPanel()
}
getTotalCellCount() {
return this.config.getCellCount()
}
getTotalRowCount() {
return this.config.getRowCount() * this.config.getGroupCount()
}
calculateTimeCellRepeatCount() {
return this.config.getGroupCount() || 1
}
getWorkSpaceMinWidth() {
let minWidth = this.config.getWorkSpaceWidth();
const workSpaceElementWidth = getBoundingRect(this.config.getElement()).width;
const workspaceContainerWidth = workSpaceElementWidth - this.config.getTimePanelWidth() - this.config.getGroupTableWidth() - 2 * WORK_SPACE_BORDER_PX;
if (minWidth < workspaceContainerWidth) {
minWidth = workspaceContainerWidth
}
return minWidth
}
getAllDayOffset() {
return 0
}
getGroupCountClass(groups) {
return getVerticalGroupCountClass(groups)
}
getLeftOffset() {
return this.config.getTimePanelWidth() + this.config.getGroupTableWidth()
}
getDefaultGroupHeight() {
const startDayHour = this.config.startDayHour();
const endDayHour = this.config.endDayHour();
const hoursInterval = this.config.hoursInterval();
return calculateDayDuration(startDayHour, endDayHour) / hoursInterval * this.config.getCellHeight()
}
getGroupHeight(groupIndex) {
var _this$config$getGroup, _this$config;
return (null === (_this$config$getGroup = (_this$config = this.config).getGroupHeights) || void 0 === _this$config$getGroup || null === (_this$config$getGroup = _this$config$getGroup.call(_this$config)) || void 0 === _this$config$getGroup ? void 0 : _this$config$getGroup[groupIndex]) ?? this.getDefaultGroupHeight()
}
getCumulativeGroupOffset(groupIndex) {
let offset = 0;
for (let i = 0; i < groupIndex; i += 1) {
offset += this.getGroupHeight(i)
}
return offset
}
getGroupBoundsOffset(groupIndex, _ref) {
var _this$config$getGroup2, _this$config2;
let [$firstCell, $lastCell] = _ref;
const groupHeightsKey = (null === (_this$config$getGroup2 = (_this$config2 = this.config).getGroupHeights) || void 0 === _this$config$getGroup2 || null === (_this$config$getGroup2 = _this$config$getGroup2.call(_this$config2)) || void 0 === _this$config$getGroup2 ? void 0 : _this$config$getGroup2.join(".")) ?? "";
return this.cache.memo(`groupBoundsOffset${groupIndex}.${groupHeightsKey}`, () => {
const groupHeight = this.getGroupHeight(groupIndex);
const scrollTop = this.getScrollableScrollTop();
const headerRowHeight = getBoundingRect(this.config.getHeaderPanelContainerElement()).height;
let topOffset = this.getCumulativeGroupOffset(groupIndex) + headerRowHeight + this.config.getHeaderHeight() - scrollTop;
if (this.config.showAllDayPanel() && this.config.supportAllDayRow()) {
topOffset += this.config.getCellHeight() * (groupIndex + 1)
}
const bottomOffset = topOffset + groupHeight;
const {
left: left
} = $firstCell.getBoundingClientRect();
const {
right: right
} = $lastCell.getBoundingClientRect();
this.groupBoundsOffset = {
left: left,
right: right,
top: topOffset,
bottom: bottomOffset
};
return this.groupBoundsOffset
})
}
shiftIndicator($indicator, height, rtlOffset, i) {
const offset = this.config.getIndicatorOffset();
const tableOffset = this.config.crossScrollingEnabled() ? 0 : this.config.getGroupTableWidth();
const horizontalOffset = rtlOffset ? rtlOffset - offset : offset;
let verticalOffset = this.getCumulativeGroupOffset(i);
if (this.config.supportAllDayRow() && this.config.showAllDayPanel()) {
verticalOffset += this.config.getAllDayHeight() * (i + 1)
}
$indicator.css("left", horizontalOffset + tableOffset);
$indicator.css("top", height + verticalOffset)
}
getShaderOffset(i, width) {
const offset = this.config.crossScrollingEnabled() ? 0 : this.config.getGroupTableWidth();
if (this.config.rtlEnabled()) {
const containerWidth = getBoundingRect(this.config.getScrollableContentElement()).width;
return containerWidth - offset - this.config.getWorkSpaceLeftOffset() - width
}
return offset
}
getShaderTopOffset(i) {
return 0
}
getShaderHeight() {
let height = this.config.getIndicationHeight();
if (this.config.supportAllDayRow() && this.config.showAllDayPanel()) {
height += this.config.getCellHeight()
}
return height
}
getShaderMaxHeight() {
let groupIndex = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0;
let height = this.getGroupHeight(groupIndex);
if (this.config.supportAllDayRow() && this.config.showAllDayPanel()) {
height += this.config.getCellHeight()
}
return height
}
getShaderWidth() {
return this.config.getIndicationWidth()
}
getScrollableScrollTop() {
return this.config.getScrollableScrollTop()
}
addAdditionalGroupCellClasses(cellClass, index, i, j) {
const newCellClass = this.addLastGroupCellClass(cellClass, i + 1);
return this.addFirstGroupCellClass(newCellClass, i + 1)
}
addLastGroupCellClass(cellClass, index) {
if (index % this.config.getRowCount() === 0) {
return `${cellClass} ${LAST_GROUP_CELL_CLASS}`
}
return cellClass
}
addFirstGroupCellClass(cellClass, index) {
if ((index - 1) % this.config.getRowCount() === 0) {
return `${cellClass} ${FIRST_GROUP_CELL_CLASS}`
}
return cellClass
}
}
export default VerticalGroupedStrategy;