devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
188 lines (187 loc) • 8.4 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/view_model/generate_view_model/options/option_manager.js)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
Cache
} from "../../../global_cache";
import {
getGroupSize
} from "./get_group_size";
import {
getMonthIntervals
} from "./get_month_intervals";
import {
getPanelCollectorOptions
} from "./get_panel_collector_options";
import {
getViewModelOptions
} from "./get_view_model_options";
import {
getWeekIntervals
} from "./get_week_intervals";
const getLayoutIntervals = (compareOptions, cellDurationMinutes, viewOffset, isTimeline, isMonthView, panelName) => {
switch (true) {
case isMonthView:
return getMonthIntervals(compareOptions, viewOffset, isTimeline);
case "allDayPanel" === panelName:
return getMonthIntervals(compareOptions, viewOffset, true);
default:
return getWeekIntervals(compareOptions, cellDurationMinutes, viewOffset, isTimeline)
}
};
export class OptionManager {
constructor(schedulerStore) {
this.schedulerStore = schedulerStore;
this.cache = new Cache;
this.options = getViewModelOptions(schedulerStore)
}
getPanelOptions(panelName) {
const workspace = this.schedulerStore.getWorkSpace();
const panelDOMSize = workspace.getPanelDOMSize("vertical" === this.options.groupOrientation ? "regularPanel" : panelName);
return this.cache.memo(`${panelDOMSize.width}.${panelDOMSize.height}.${panelName}`, () => {
const {
type: type,
viewOffset: viewOffset,
groupOrientation: groupOrientation,
viewOrientation: nativeViewOrientation,
isGroupByDate: isGroupByDate,
groupCount: groupCount,
compareOptions: compareOptions,
isMonthView: isMonthView,
isRTLEnabled: isRTLEnabled,
isAdaptivityEnabled: isAdaptivityEnabled,
cellDurationMinutes: cellDurationMinutes,
isTimelineView: isTimelineView,
hasAllDayPanel: hasAllDayPanel
} = this.options;
const viewOrientation = "allDayPanel" === panelName ? "horizontal" : nativeViewOrientation;
const isCompactCollector = isAdaptivityEnabled || "vertical" === viewOrientation;
const collectorCSS = workspace.getCollectorDimension(isCompactCollector, panelName);
const {
allDayPanelCellSize: allDayPanelCellSize,
cellSize: cellSize,
collectorSizes: collectorSizes,
maxLevel: maxLevel,
minLevel: minLevel
} = getPanelCollectorOptions(this.schedulerStore, {
alwaysReserveSpaceForCollector: "month" === type,
isTimelineView: isTimelineView,
viewOrientation: viewOrientation,
isAdaptivityEnabled: isAdaptivityEnabled,
collectorCSS: collectorCSS,
DOMMetaData: workspace.getDOMElementsMetaData(),
panelName: panelName
});
const {
cells: cells,
dayIntervals: dayIntervals,
intervals: intervals
} = getLayoutIntervals(compareOptions, cellDurationMinutes, viewOffset, isTimelineView || "allDayPanel" === panelName, isMonthView, panelName);
const groupByDateSplitIntervals = "vertical" === viewOrientation ? dayIntervals : cells;
const splitIntervals = isGroupByDate ? groupByDateSplitIntervals : intervals;
const geometryOptions = Object.assign({
intervals: intervals,
cells: cells,
maxAppointmentsPerCell: maxLevel,
hasAllDayPanel: hasAllDayPanel,
viewOrientation: viewOrientation,
groupOrientation: groupOrientation,
isGroupByDate: isGroupByDate,
isTimelineView: isTimelineView,
isRTLEnabled: isRTLEnabled,
isAdaptivityEnabled: isAdaptivityEnabled,
allDayPanelCellSize: allDayPanelCellSize,
cellSize: cellSize,
collectorPosition: "vertical" === viewOrientation ? "end" : "start"
}, collectorSizes, {
groupCount: groupCount,
groupSize: getGroupSize(Object.assign({}, compareOptions, {
cellSize: cellSize,
cellDurationMinutes: cellDurationMinutes,
intervals: intervals,
cells: cells,
viewType: type,
isAllDayPanel: "allDayPanel" === panelName
})),
panelSize: panelDOMSize
});
const collectorOptions = {
cells: cells,
minLevel: minLevel,
maxLevel: maxLevel,
collectBy: "horizontal" === viewOrientation ? "byOccupation" : "byStartDate",
isCompact: isCompactCollector
};
return {
splitIntervals: splitIntervals,
cells: cells,
collectorOptions: collectorOptions,
geometryOptions: geometryOptions
}
})
}
getSplitIntervals(panelName) {
return this.getPanelOptions(panelName).splitIntervals
}
getCells(panelName) {
return this.getPanelOptions(panelName).cells
}
getCollectorOptions(panelName) {
return this.getPanelOptions(panelName).collectorOptions
}
getGeometryOptions(panelName) {
return this.getPanelOptions(panelName).geometryOptions
}
getVirtualCropOptions() {
const {
cellSize: cellSize,
panelSize: panelSize
} = this.getPanelOptions("regularPanel").geometryOptions;
const {
positionHelper: positionHelper,
virtualScrollingDispatcher: virtualScrollingDispatcher
} = this.schedulerStore.getWorkSpace();
const {
hasAllDayPanel: hasAllDayPanel,
groupCount: groupCount,
groupOrientation: groupOrientation,
isVirtualScrolling: isVirtualScrolling,
isRTLEnabled: isRTLEnabled
} = this.options;
const {
cellCountInsideLeftVirtualCell: cellCountInsideLeftVirtualCell,
cellCountInsideRightVirtualCell: cellCountInsideRightVirtualCell,
cellCountInsideTopVirtualRow: cellCountInsideTopVirtualRow
} = virtualScrollingDispatcher;
const hVirtualItemsCount = isRTLEnabled ? cellCountInsideRightVirtualCell : cellCountInsideLeftVirtualCell;
const isVerticalGrouping = groupCount > 0 && "vertical" === groupOrientation;
const isGroupedAllDayPanel = isVerticalGrouping && hasAllDayPanel;
return {
isVirtualScrolling: isVirtualScrolling,
getVirtualScreen: groupIndex => this.cache.memo(`virtualScreen${groupIndex}`, () => {
const left = hVirtualItemsCount * cellSize.width;
const top = cellCountInsideTopVirtualRow * cellSize.height;
const right = Math.round(positionHelper.getHorizontalMax(groupIndex)) || 1 / 0;
const bottom = positionHelper.getVerticalMax({
groupIndex: groupIndex,
isVirtualScrolling: isVirtualScrolling,
showAllDayPanel: hasAllDayPanel,
supportAllDayRow: hasAllDayPanel,
isGroupedAllDayPanel: isGroupedAllDayPanel,
isVerticalGrouping: isVerticalGrouping
});
return {
left: isRTLEnabled ? panelSize.width - right : left,
right: isRTLEnabled ? panelSize.width - left : right,
top: top,
bottom: bottom
}
})
}
}
}