').addClass(SCHEDULER_DATE_TIME_INDICATOR_CLASS);
- $container.append($indicator);
+ _renderDateTimeIndication() {
+ if (this.isIndicationAvailable()) {
+ if (this.option('shadeUntilCurrentTime')) {
+ this._shader.render();
+ }
- return $indicator;
- }
+ if (this.isIndicationOnView() && this.isIndicatorVisible()) {
+ const groupCount = this._getGroupCount() || 1;
+ const $container = this._dateTableScrollable.$content();
+ const height = this.getIndicationHeight();
+ const rtlOffset = this._getRtlOffset(this.getCellWidth());
- _getRtlOffset(width) {
- return this.option('rtlEnabled') ? getBoundingRect(this._dateTableScrollable.$content().get(0)).width - this.getTimePanelWidth() - width : 0;
+ this._renderIndicator(height, rtlOffset, $container, groupCount);
+ this._setCurrentTimeCells();
+ }
}
+ }
+
+ _renderIndicator(height, rtlOffset, $container, groupCount) {
+ const groupedByDate = this.isGroupedByDate();
+ const repeatCount = groupedByDate ? 1 : groupCount;
+ for (let i = 0; i < repeatCount; i++) {
+ const $indicator = this._createIndicator($container);
+
+ setWidth(
+ $indicator,
+ groupedByDate ? this.getCellWidth() * groupCount : this.getCellWidth(),
+ );
+ this._groupedStrategy.shiftIndicator($indicator, height, rtlOffset, i);
+ }
+ }
- _setIndicationUpdateInterval() {
- if(!this.option('showCurrentTimeIndicator') || this.option('indicatorUpdateInterval') === 0) {
- return;
- }
+ _createIndicator($container) {
+ const $indicator = $('
').addClass(SCHEDULER_DATE_TIME_INDICATOR_CLASS);
+ $container.append($indicator);
- this._clearIndicatorUpdateInterval();
+ return $indicator;
+ }
- this._indicatorInterval = setInterval(function() {
- this._refreshDateTimeIndication();
- }.bind(this), this.option('indicatorUpdateInterval'));
- }
+ _getRtlOffset(width) {
+ return this.option('rtlEnabled') ? getBoundingRect(this._dateTableScrollable.$content().get(0)).width - this.getTimePanelWidth() - width : 0;
+ }
- _clearIndicatorUpdateInterval() {
- if(this._indicatorInterval) {
- clearInterval(this._indicatorInterval);
- delete this._indicatorInterval;
- }
+ _setIndicationUpdateInterval() {
+ if (!this.option('showCurrentTimeIndicator') || this.option('indicatorUpdateInterval') === 0) {
+ return;
}
- _isVerticalShader() {
- return true;
+ this._clearIndicatorUpdateInterval();
+
+ this._indicatorInterval = setInterval(() => {
+ this._refreshDateTimeIndication();
+ }, this.option('indicatorUpdateInterval'));
+ }
+
+ _clearIndicatorUpdateInterval() {
+ if (this._indicatorInterval) {
+ clearInterval(this._indicatorInterval);
+ delete this._indicatorInterval;
}
+ }
- getIndicationWidth(groupIndex) {
- const maxWidth = this.getCellWidth() * this._getCellCount();
+ _isVerticalShader() {
+ return true;
+ }
- let difference = this._getIndicatorDuration();
- if(difference > this._getCellCount()) {
- difference = this._getCellCount();
- }
- const width = difference * this.getRoundedCellWidth(groupIndex, groupIndex * this._getCellCount(), difference);
+ getIndicationWidth(groupIndex) {
+ const maxWidth = this.getCellWidth() * this._getCellCount();
- return maxWidth < width ? maxWidth : width;
+ let difference = this._getIndicatorDuration();
+ if (difference > this._getCellCount()) {
+ difference = this._getCellCount();
}
+ const width = difference * this.getRoundedCellWidth(groupIndex, groupIndex * this._getCellCount(), difference);
- getIndicatorOffset(groupIndex) {
- const difference = this._getIndicatorDuration() - 1;
- const offset = difference * this.getRoundedCellWidth(groupIndex, groupIndex * this._getCellCount(), difference);
+ return maxWidth < width ? maxWidth : width;
+ }
- return offset;
- }
+ getIndicatorOffset(groupIndex) {
+ const difference = this._getIndicatorDuration() - 1;
+ const offset = difference * this.getRoundedCellWidth(groupIndex, groupIndex * this._getCellCount(), difference);
- _getIndicatorDuration() {
- const today = this._getToday();
- const firstViewDate = new Date(this.getStartViewDate());
- let timeDiff = today.getTime() - firstViewDate.getTime();
- if(this.option('type') === 'workWeek') {
- timeDiff = timeDiff - (this._getWeekendsCount(Math.round(timeDiff / toMs('day'))) * toMs('day'));
- }
+ return offset;
+ }
- return Math.ceil((timeDiff + 1) / toMs('day'));
+ _getIndicatorDuration() {
+ const today = this._getToday();
+ const firstViewDate = new Date(this.getStartViewDate());
+ let timeDiff = today.getTime() - firstViewDate.getTime();
+ if (this.option('type') === 'workWeek') {
+ timeDiff -= this._getWeekendsCount(Math.round(timeDiff / toMs('day'))) * toMs('day');
}
- getIndicationHeight() {
- const today = timezoneUtils.getDateWithoutTimezoneChange(this._getToday());
- const cellHeight = this.getCellHeight();
- const date = new Date(this.getStartViewDate());
-
- if(this.isIndicationOnView()) {
- date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());
- }
+ return Math.ceil((timeDiff + 1) / toMs('day'));
+ }
- const duration = today.getTime() - date.getTime();
- const cellCount = duration / this.getCellDuration();
+ getIndicationHeight() {
+ const today = timezoneUtils.getDateWithoutTimezoneChange(this._getToday());
+ const cellHeight = this.getCellHeight();
+ const date = new Date(this.getStartViewDate());
- return cellCount * cellHeight;
+ if (this.isIndicationOnView()) {
+ date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());
}
- _dispose() {
- this._clearIndicatorUpdateInterval();
- super._dispose.apply(this, arguments);
- }
+ const duration = today.getTime() - date.getTime();
+ const cellCount = duration / this.getCellDuration();
- _refreshDateTimeIndication() {
- this._cleanDateTimeIndicator();
- this._cleanCurrentTimeCells();
+ return cellCount * cellHeight;
+ }
- this._shader?.clean();
+ _dispose() {
+ this._clearIndicatorUpdateInterval();
+ super._dispose.apply(this, arguments as any);
+ }
- this._renderDateTimeIndication();
- }
+ _refreshDateTimeIndication() {
+ this._cleanDateTimeIndicator();
+ this._cleanCurrentTimeCells();
- _setCurrentTimeCells() {
- const timePanelCells = this._getTimePanelCells();
- const currentTimeCellIndices = this._getCurrentTimePanelCellIndices();
- currentTimeCellIndices.forEach((timePanelCellIndex) => {
- timePanelCells.eq(timePanelCellIndex)
- .addClass(TIME_PANEL_CURRENT_TIME_CELL_CLASS);
- });
- }
+ this._shader?.clean();
+
+ this._renderDateTimeIndication();
+ }
- _isCurrentTimeHeaderCell(headerIndex) {
- if(this.isIndicationOnView()) {
- const completeDateHeaderMap = this.viewDataProvider.completeDateHeaderMap;
- const date = completeDateHeaderMap[completeDateHeaderMap.length - 1][headerIndex].startDate;
+ _setCurrentTimeCells() {
+ const timePanelCells = this._getTimePanelCells();
+ const currentTimeCellIndices = this._getCurrentTimePanelCellIndices();
+ currentTimeCellIndices.forEach((timePanelCellIndex) => {
+ timePanelCells.eq(timePanelCellIndex)
+ .addClass(TIME_PANEL_CURRENT_TIME_CELL_CLASS);
+ });
+ }
- return dateUtils.sameDate(date, this._getToday());
- }
+ _isCurrentTimeHeaderCell(headerIndex) {
+ if (this.isIndicationOnView()) {
+ const { completeDateHeaderMap } = this.viewDataProvider;
+ const date = completeDateHeaderMap[completeDateHeaderMap.length - 1][headerIndex].startDate;
- return false;
+ return dateUtils.sameDate(date, this._getToday());
}
- _getHeaderPanelCellClass(i) {
- const cellClass = super._getHeaderPanelCellClass(i);
+ return false;
+ }
- if(this._isCurrentTimeHeaderCell(i)) {
- return cellClass + ' ' + HEADER_CURRENT_TIME_CELL_CLASS;
- }
+ _getHeaderPanelCellClass(i) {
+ const cellClass = super._getHeaderPanelCellClass(i);
- return cellClass;
+ if (this._isCurrentTimeHeaderCell(i)) {
+ return `${cellClass} ${HEADER_CURRENT_TIME_CELL_CLASS}`;
}
- _cleanView() {
- super._cleanView();
+ return cellClass;
+ }
- this._cleanDateTimeIndicator();
- }
+ _cleanView() {
+ super._cleanView();
- _dimensionChanged() {
- super._dimensionChanged();
+ this._cleanDateTimeIndicator();
+ }
- this._refreshDateTimeIndication();
- }
+ _dimensionChanged() {
+ super._dimensionChanged();
- _cleanDateTimeIndicator() {
- this.$element().find('.' + SCHEDULER_DATE_TIME_INDICATOR_CLASS).remove();
- }
+ this._refreshDateTimeIndication();
+ }
- _cleanCurrentTimeCells() {
- this.$element()
- .find(`.${TIME_PANEL_CURRENT_TIME_CELL_CLASS}`)
- .removeClass(TIME_PANEL_CURRENT_TIME_CELL_CLASS);
- }
+ _cleanDateTimeIndicator() {
+ (this.$element() as any).find(`.${SCHEDULER_DATE_TIME_INDICATOR_CLASS}`).remove();
+ }
+
+ _cleanCurrentTimeCells() {
+ (this.$element() as any)
+ .find(`.${TIME_PANEL_CURRENT_TIME_CELL_CLASS}`)
+ .removeClass(TIME_PANEL_CURRENT_TIME_CELL_CLASS);
+ }
- _cleanWorkSpace() {
- super._cleanWorkSpace();
+ _cleanWorkSpace() {
+ super._cleanWorkSpace();
- this._renderDateTimeIndication();
+ this._renderDateTimeIndication();
+ this._setIndicationUpdateInterval();
+ }
+
+ _optionChanged(args) {
+ switch (args.name) {
+ case 'showCurrentTimeIndicator':
+ case 'indicatorTime':
+ this._cleanWorkSpace();
+ break;
+ case 'indicatorUpdateInterval':
this._setIndicationUpdateInterval();
+ break;
+ case 'showAllDayPanel':
+ super._optionChanged(args);
+ this._refreshDateTimeIndication();
+ break;
+ case 'allDayExpanded':
+ super._optionChanged(args);
+ this._refreshDateTimeIndication();
+ break;
+ case 'crossScrollingEnabled':
+ super._optionChanged(args);
+ this._refreshDateTimeIndication();
+ break;
+ case 'shadeUntilCurrentTime':
+ this._refreshDateTimeIndication();
+ break;
+ default:
+ super._optionChanged(args);
}
-
- _optionChanged(args) {
-
- switch(args.name) {
- case 'showCurrentTimeIndicator':
- case 'indicatorTime':
- this._cleanWorkSpace();
- break;
- case 'indicatorUpdateInterval':
- this._setIndicationUpdateInterval();
- break;
- case 'showAllDayPanel':
- super._optionChanged(args);
- this._refreshDateTimeIndication();
- break;
- case 'allDayExpanded':
- super._optionChanged(args);
- this._refreshDateTimeIndication();
- break;
- case 'crossScrollingEnabled':
- super._optionChanged(args);
- this._refreshDateTimeIndication();
- break;
- case 'shadeUntilCurrentTime':
- this._refreshDateTimeIndication();
- break;
- default:
- super._optionChanged(args);
- }
+ }
+
+ _getDefaultOptions() {
+ return extend(super._getDefaultOptions(), {
+ showCurrentTimeIndicator: true,
+ indicatorTime: new Date(),
+ indicatorUpdateInterval: 5 * toMs('minute'),
+ shadeUntilCurrentTime: true,
+ });
+ }
+
+ _getCurrentTimePanelCellIndices() {
+ const rowCountPerGroup = this._getTimePanelRowCount();
+ const today = this._getToday();
+ const index = this.getCellIndexByDate(today);
+ const { rowIndex: currentTimeRowIndex } = this._getCellCoordinatesByIndex(index);
+
+ if (currentTimeRowIndex === undefined) {
+ return [];
}
- _getDefaultOptions() {
- return extend(super._getDefaultOptions(), {
- showCurrentTimeIndicator: true,
- indicatorTime: new Date(),
- indicatorUpdateInterval: 5 * toMs('minute'),
- shadeUntilCurrentTime: true
- });
+ let cellIndices;
+ if (currentTimeRowIndex === 0) {
+ cellIndices = [currentTimeRowIndex];
+ } else {
+ cellIndices = currentTimeRowIndex % 2 === 0
+ ? [currentTimeRowIndex - 1, currentTimeRowIndex]
+ : [currentTimeRowIndex, currentTimeRowIndex + 1];
}
- _getCurrentTimePanelCellIndices() {
- const rowCountPerGroup = this._getTimePanelRowCount();
- const today = this._getToday();
- const index = this.getCellIndexByDate(today);
- const { rowIndex: currentTimeRowIndex } = this._getCellCoordinatesByIndex(index);
-
- if(currentTimeRowIndex === undefined) {
- return [];
- }
-
- let cellIndices;
- if(currentTimeRowIndex === 0) {
- cellIndices = [currentTimeRowIndex];
- } else {
- cellIndices = currentTimeRowIndex % 2 === 0
- ? [currentTimeRowIndex - 1, currentTimeRowIndex]
- : [currentTimeRowIndex, currentTimeRowIndex + 1];
- }
-
- const verticalGroupCount = this._isVerticalGroupedWorkSpace()
- ? this._getGroupCount()
- : 1;
-
- return [...(new Array(verticalGroupCount))]
- .reduce((currentIndices, _, groupIndex) => {
- return [
- ...currentIndices,
- ...cellIndices.map(cellIndex => rowCountPerGroup * groupIndex + cellIndex),
- ];
- }, []);
- }
+ const verticalGroupCount = this._isVerticalGroupedWorkSpace()
+ ? this._getGroupCount()
+ : 1;
+
+ return [...new Array(verticalGroupCount)]
+ .reduce((currentIndices, _, groupIndex) => [
+ ...currentIndices,
+ ...cellIndices.map((cellIndex) => rowCountPerGroup * groupIndex + cellIndex),
+ ], []);
+ }
}
-registerComponent('dxSchedulerWorkSpace', SchedulerWorkSpaceIndicator);
+registerComponent('dxSchedulerWorkSpace', SchedulerWorkSpaceIndicator as any);
export default SchedulerWorkSpaceIndicator;
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_month.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_month.ts
index a229d9d190aa..2871a83eecf3 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_month.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_month.ts
@@ -1,17 +1,20 @@
-import { noop } from '../../../core/utils/common';
-import registerComponent from '../../../core/component_registrator';
-import SchedulerWorkSpace from './ui.scheduler.work_space.indicator';
-import dateUtils from '../../../core/utils/date';
-import { getBoundingRect } from '../../../core/utils/position';
-import { utils } from '../utils';
-import { hasWindow } from '../../../core/utils/window';
-import dxrMonthDateTableLayout from '../../../renovation/ui/scheduler/workspaces/month/date_table/layout.j';
+import registerComponent from '@js/core/component_registrator';
+import { noop } from '@js/core/utils/common';
+import dateUtils from '@js/core/utils/date';
+import { getBoundingRect } from '@js/core/utils/position';
+import { hasWindow } from '@js/core/utils/window';
+import { formatWeekday } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
import {
- getViewStartByOptions,
- getCellText,
-} from '../../../renovation/ui/scheduler/view_model/to_test/views/utils/month';
-import { formatWeekday } from '../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
-import { VIEWS } from '../constants';
+ getCellText,
+ getViewStartByOptions,
+} from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/month';
+
+// NOTE: Renovation component import.
+// @ts-expect-error
+import dxrMonthDateTableLayout from '../../../renovation/ui/scheduler/workspaces/month/date_table/layout.j';
+import { VIEWS } from '../m_constants';
+import { utils } from '../m_utils';
+import SchedulerWorkSpace from './m_work_space_indicator';
const MONTH_CLASS = 'dx-scheduler-work-space-month';
@@ -23,168 +26,172 @@ const DATE_TABLE_OTHER_MONTH_DATE_CLASS = 'dx-scheduler-date-table-other-month';
const toMs = dateUtils.dateToMilliseconds;
class SchedulerWorkSpaceMonth extends SchedulerWorkSpace {
- get type() { return VIEWS.MONTH; }
-
- _getElementClass() {
- return MONTH_CLASS;
+ get type() { return VIEWS.MONTH; }
+
+ _getElementClass() {
+ return MONTH_CLASS;
+ }
+
+ _getFormat() {
+ return formatWeekday;
+ }
+
+ _getIntervalBetween(currentDate) {
+ const firstViewDate = this.getStartViewDate();
+ const timeZoneOffset = dateUtils.getTimezonesDifference(firstViewDate, currentDate);
+
+ return currentDate.getTime() - (firstViewDate.getTime() - (this.option('startDayHour') as any) * 3600000) - timeZoneOffset;
+ }
+
+ _getDateGenerationOptions() {
+ return {
+ ...super._getDateGenerationOptions(),
+ cellCountInDay: 1,
+ };
+ }
+
+ // TODO: temporary fix, in the future, if we replace table layout on div layout, getCellWidth method need remove. Details in T712431
+ // TODO: there is a test for this bug, when changing the layout, the test will also be useless
+ getCellWidth() {
+ return this.cache.get('cellWidth', () => {
+ const DAYS_IN_WEEK = 7;
+
+ let averageWidth = 0;
+ const cells = this._getCells().slice(0, DAYS_IN_WEEK);
+ cells.each((index, element) => {
+ averageWidth += hasWindow() ? getBoundingRect(element).width : 0;
+ });
+
+ return cells.length === 0 ? undefined : averageWidth / DAYS_IN_WEEK;
+ });
+ }
+
+ _insertAllDayRowsIntoDateTable() {
+ return false;
+ }
+
+ _getCellCoordinatesByIndex(index) {
+ const rowIndex = Math.floor(index / this._getCellCount());
+ const columnIndex = index - this._getCellCount() * rowIndex;
+
+ return {
+ rowIndex,
+ columnIndex,
+ };
+ }
+
+ _needCreateCrossScrolling() {
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+ return this.option('crossScrollingEnabled') || this._isVerticalGroupedWorkSpace();
+ }
+
+ _getViewStartByOptions() {
+ return getViewStartByOptions(
+ this.option('startDate') as any,
+ this.option('currentDate') as any,
+ this.option('intervalCount') as any,
+ dateUtils.getFirstMonthDate(this.option('startDate')) as any,
+ );
+ }
+
+ _updateIndex(index) {
+ return index;
+ }
+
+ isIndicationAvailable() {
+ return false;
+ }
+
+ getIntervalDuration() {
+ return toMs('day');
+ }
+
+ getTimePanelWidth() {
+ return 0;
+ }
+
+ supportAllDayRow() {
+ return false;
+ }
+
+ keepOriginalHours() {
+ return true;
+ }
+
+ getWorkSpaceLeftOffset() {
+ return 0;
+ }
+
+ needApplyCollectorOffset() {
+ return true;
+ }
+
+ _getHeaderDate() {
+ return this._getViewStartByOptions();
+ }
+
+ scrollToTime() { return noop(); }
+
+ renderRAllDayPanel() {}
+
+ renderRTimeTable() {}
+
+ renderRDateTable() {
+ utils.renovation.renderComponent(
+ this,
+ this._$dateTable,
+ dxrMonthDateTableLayout,
+ 'renovatedDateTable',
+ this._getRDateTableProps(),
+ );
+ }
+
+ // -------------
+ // We need these methods for now but they are useless for renovation
+ // -------------
+
+ _createWorkSpaceElements() {
+ if (this._isVerticalGroupedWorkSpace()) {
+ this._createWorkSpaceScrollableElements();
+ } else {
+ super._createWorkSpaceElements();
}
+ }
+
+ _toggleAllDayVisibility() { return noop(); }
- _getFormat() {
- return formatWeekday;
- }
+ _changeAllDayVisibility() { return noop(); }
- _getIntervalBetween(currentDate) {
- const firstViewDate = this.getStartViewDate();
- const timeZoneOffset = dateUtils.getTimezonesDifference(firstViewDate, currentDate);
+ // --------------
+ // These methods should be deleted when we get rid of old render
+ // --------------
- return currentDate.getTime() - (firstViewDate.getTime() - this.option('startDayHour') * 3600000) - timeZoneOffset;
- }
+ _renderTimePanel() { return noop(); }
- _getDateGenerationOptions() {
- return {
- ...super._getDateGenerationOptions(),
- cellCountInDay: 1,
- };
- }
+ _renderAllDayPanel() { return noop(); }
- // TODO: temporary fix, in the future, if we replace table layout on div layout, getCellWidth method need remove. Details in T712431
- // TODO: there is a test for this bug, when changing the layout, the test will also be useless
- getCellWidth() {
- return this.cache.get('cellWidth', () => {
- const DAYS_IN_WEEK = 7;
+ _setMonthClassesToCell($cell, data) {
+ $cell
+ .toggleClass(DATE_TABLE_CURRENT_DATE_CLASS, data.isCurrentDate)
+ .toggleClass(DATE_TABLE_FIRST_OF_MONTH_CLASS, data.firstDayOfMonth)
+ .toggleClass(DATE_TABLE_OTHER_MONTH_DATE_CLASS, data.otherMonth);
+ }
- let averageWidth = 0;
- const cells = this._getCells().slice(0, DAYS_IN_WEEK);
- cells.each((index, element) => {
- averageWidth += hasWindow() ? getBoundingRect(element).width : 0;
- });
+ _createAllDayPanelElements() {}
- return cells.length === 0 ? undefined : averageWidth / DAYS_IN_WEEK;
- });
- }
-
- _insertAllDayRowsIntoDateTable() {
- return false;
- }
- _getCellCoordinatesByIndex(index) {
- const rowIndex = Math.floor(index / this._getCellCount());
- const columnIndex = index - this._getCellCount() * rowIndex;
-
- return {
- rowIndex: rowIndex,
- columnIndex,
- };
- }
+ _renderTableBody(options) {
+ options.getCellText = (rowIndex, columnIndex) => {
+ const date = this.viewDataProvider.completeViewDataMap[rowIndex][columnIndex].startDate;
- _needCreateCrossScrolling() {
- return this.option('crossScrollingEnabled') || this._isVerticalGroupedWorkSpace();
- }
+ return getCellText(date, this.option('intervalCount') as any);
+ };
+ options.getCellTextClass = DATE_TABLE_CELL_TEXT_CLASS;
+ options.setAdditionalClasses = this._setMonthClassesToCell.bind(this);
- _getViewStartByOptions() {
- return getViewStartByOptions(
- this.option('startDate'),
- this.option('currentDate'),
- this.option('intervalCount'),
- dateUtils.getFirstMonthDate(this.option('startDate')),
- );
- }
-
- _updateIndex(index) {
- return index;
- }
-
- isIndicationAvailable() {
- return false;
- }
-
- getIntervalDuration() {
- return toMs('day');
- }
-
- getTimePanelWidth() {
- return 0;
- }
-
- supportAllDayRow() {
- return false;
- }
-
- keepOriginalHours() {
- return true;
- }
-
- getWorkSpaceLeftOffset() {
- return 0;
- }
-
- needApplyCollectorOffset() {
- return true;
- }
-
- _getHeaderDate() {
- return this._getViewStartByOptions();
- }
-
- scrollToTime() { return noop(); }
-
- renderRAllDayPanel() {}
-
- renderRTimeTable() {}
-
- renderRDateTable() {
- utils.renovation.renderComponent(
- this,
- this._$dateTable,
- dxrMonthDateTableLayout,
- 'renovatedDateTable',
- this._getRDateTableProps(),
- );
- }
-
- // -------------
- // We need these methods for now but they are useless for renovation
- // -------------
-
- _createWorkSpaceElements() {
- if(this._isVerticalGroupedWorkSpace()) {
- this._createWorkSpaceScrollableElements();
- } else {
- super._createWorkSpaceElements();
- }
- }
-
- _toggleAllDayVisibility() { return noop(); }
- _changeAllDayVisibility() { return noop(); }
-
- // --------------
- // These methods should be deleted when we get rid of old render
- // --------------
-
- _renderTimePanel() { return noop(); }
- _renderAllDayPanel() { return noop(); }
-
- _setMonthClassesToCell($cell, data) {
- $cell
- .toggleClass(DATE_TABLE_CURRENT_DATE_CLASS, data.isCurrentDate)
- .toggleClass(DATE_TABLE_FIRST_OF_MONTH_CLASS, data.firstDayOfMonth)
- .toggleClass(DATE_TABLE_OTHER_MONTH_DATE_CLASS, data.otherMonth);
- }
-
- _createAllDayPanelElements() {}
-
- _renderTableBody(options) {
- options.getCellText = (rowIndex, columnIndex) => {
- const date = this.viewDataProvider.completeViewDataMap[rowIndex][columnIndex].startDate;
-
- return getCellText(date, this.option('intervalCount'));
- };
- options.getCellTextClass = DATE_TABLE_CELL_TEXT_CLASS;
- options.setAdditionalClasses = this._setMonthClassesToCell.bind(this),
-
- super._renderTableBody(options);
- }
+ super._renderTableBody(options);
+ }
}
-registerComponent('dxSchedulerWorkSpaceMonth', SchedulerWorkSpaceMonth);
+registerComponent('dxSchedulerWorkSpaceMonth', SchedulerWorkSpaceMonth as any);
export default SchedulerWorkSpaceMonth;
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_vertical.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_vertical.ts
index e348e8685437..0258c9fbcce5 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_vertical.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_vertical.ts
@@ -1,24 +1,24 @@
-import SchedulerWorkSpaceIndicator from './ui.scheduler.work_space.indicator';
-import { formatWeekdayAndDay } from '../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
+import { formatWeekdayAndDay } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
-class SchedulerWorkspaceVertical extends SchedulerWorkSpaceIndicator {
- _getFormat() {
- return formatWeekdayAndDay;
- }
+import SchedulerWorkSpaceIndicator from './m_work_space_indicator';
- generateRenderOptions() {
- const options = super.generateRenderOptions();
+class SchedulerWorkspaceVertical extends SchedulerWorkSpaceIndicator {
+ _getFormat() {
+ return formatWeekdayAndDay;
+ }
- return {
- ...options,
- isGenerateTimePanelData: true,
- };
- }
+ generateRenderOptions() {
+ const options = super.generateRenderOptions();
- _isRenderHeaderPanelEmptyCell() {
- return true;
- }
+ return {
+ ...options,
+ isGenerateTimePanelData: true,
+ };
+ }
+ _isRenderHeaderPanelEmptyCell() {
+ return true;
+ }
}
export default SchedulerWorkspaceVertical;
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_week.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_week.ts
index 45d991229111..f565cb79e508 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_week.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_week.ts
@@ -1,21 +1,22 @@
-import registerComponent from '../../../core/component_registrator';
-import { VIEWS } from '../constants';
-import SchedulerWorkSpaceVertical from './ui.scheduler.work_space_vertical';
-import { calculateViewStartDate } from '../../../renovation/ui/scheduler/view_model/to_test/views/utils/week';
+import registerComponent from '@js/core/component_registrator';
+import { calculateViewStartDate } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/week';
+
+import { VIEWS } from '../m_constants';
+import SchedulerWorkSpaceVertical from './m_work_space_vertical';
const WEEK_CLASS = 'dx-scheduler-work-space-week';
class SchedulerWorkSpaceWeek extends SchedulerWorkSpaceVertical {
- get type() { return VIEWS.WEEK; }
+ get type() { return VIEWS.WEEK; }
- _getElementClass() {
- return WEEK_CLASS;
- }
+ _getElementClass() {
+ return WEEK_CLASS;
+ }
- _calculateViewStartDate() {
- return calculateViewStartDate(this.option('startDate'), this._firstDayOfWeek());
- }
+ _calculateViewStartDate() {
+ return calculateViewStartDate(this.option('startDate') as any, this._firstDayOfWeek());
+ }
}
-registerComponent('dxSchedulerWorkSpaceWeek', SchedulerWorkSpaceWeek);
+registerComponent('dxSchedulerWorkSpaceWeek', SchedulerWorkSpaceWeek as any);
export default SchedulerWorkSpaceWeek;
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_work_week.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_work_week.ts
index bba90803e2d9..75d32325b680 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_work_week.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_work_week.ts
@@ -1,25 +1,27 @@
-import registerComponent from '../../../core/component_registrator';
+import registerComponent from '@js/core/component_registrator';
import {
- getWeekendsCount,
-} from '../../../renovation/ui/scheduler/view_model/to_test/views/utils/work_week';
-import SchedulerWorkSpaceWeek from './ui.scheduler.work_space_week';
-import { VIEWS } from '../constants';
+ getWeekendsCount,
+} from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/work_week';
+
+import { VIEWS } from '../m_constants';
+import SchedulerWorkSpaceWeek from './m_work_space_week';
const WORK_WEEK_CLASS = 'dx-scheduler-work-space-work-week';
class SchedulerWorkSpaceWorkWeek extends SchedulerWorkSpaceWeek {
- get type() { return VIEWS.WORK_WEEK; }
+ get type() { return VIEWS.WORK_WEEK; }
- constructor(...args) {
- super(...args);
+ constructor(...args: any[]) {
+ // @ts-expect-error
+ super(...args);
- this._getWeekendsCount = getWeekendsCount;
- }
+ this._getWeekendsCount = getWeekendsCount;
+ }
- _getElementClass() {
- return WORK_WEEK_CLASS;
- }
+ _getElementClass() {
+ return WORK_WEEK_CLASS;
+ }
}
-registerComponent('dxSchedulerWorkSpaceWorkWeek', SchedulerWorkSpaceWorkWeek);
+registerComponent('dxSchedulerWorkSpaceWorkWeek', SchedulerWorkSpaceWorkWeek as any);
export default SchedulerWorkSpaceWorkWeek;
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/__tests__/utils.test.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/__tests__/utils.test.ts
index 002fccff1237..4b5a0fbc6b3b 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/__tests__/utils.test.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/__tests__/utils.test.ts
@@ -1,7 +1,13 @@
-/* eslint-disable no-undef */
-import { alignToFirstDayOfWeek, alignToLastDayOfWeek, calculateDaysBetweenDates, calculateAlignedWeeksBetweenDates } from '../utils';
+/* eslint-disable no-undef, forbidden-imports/no-restricted-imports */
import each from 'jest-each';
+import {
+ alignToFirstDayOfWeek,
+ alignToLastDayOfWeek,
+ calculateAlignedWeeksBetweenDates,
+ calculateDaysBetweenDates,
+} from '../m_utils';
+
/*
Calendar for 2023-06 for easier test cases understanding:
@@ -16,19 +22,19 @@ mon tue wed thu fri sat sun
*/
describe('alignToFirstDayOfWeek', () => {
- each`
+ each`
date | firstDayOfWeek
${new Date('2023-06-26')} | ${1}
${new Date('2023-06-25')} | ${0}
`.it('should return the same value if date is first day of week', ({
- date, firstDayOfWeek
- }) => {
- const resultDate = alignToFirstDayOfWeek(date, firstDayOfWeek);
- expect(resultDate).toEqual(date);
- });
-
- each`
- date | rightDate | firstDayOfWeek
+ date, firstDayOfWeek,
+ }) => {
+ const resultDate = alignToFirstDayOfWeek(date, firstDayOfWeek);
+ expect(resultDate).toEqual(date);
+ });
+
+ each`
+ date | rightDate | firstDayOfWeek
${new Date('2023-06-29')} | ${new Date('2023-06-26')} | ${1}
${new Date('2023-06-27')} | ${new Date('2023-06-26')} | ${1}
${new Date('2023-06-30')} | ${new Date('2023-06-26')} | ${1}
@@ -37,82 +43,82 @@ describe('alignToFirstDayOfWeek', () => {
${new Date('2023-06-26')} | ${new Date('2023-06-25')} | ${0}
`.it('should return first day of current week', ({
- date, rightDate, firstDayOfWeek
- }) => {
- const resultDate = alignToFirstDayOfWeek(date, firstDayOfWeek);
- expect(resultDate).toEqual(rightDate);
- });
+ date, rightDate, firstDayOfWeek,
+ }) => {
+ const resultDate = alignToFirstDayOfWeek(date, firstDayOfWeek);
+ expect(resultDate).toEqual(rightDate);
+ });
});
describe('alignToLastDayOfWeek', () => {
- each`
+ each`
date | firstDayOfWeek
${new Date('2023-06-25')} | ${1}
${new Date('2023-06-24')} | ${0}
`.it('should return the same value if date is last day of week', ({
- date, firstDayOfWeek
- }) => {
- const resultDate = alignToLastDayOfWeek(date, firstDayOfWeek);
- expect(resultDate).toEqual(date);
- });
-
- each`
- date | rightDate | firstDayOfWeek
+ date, firstDayOfWeek,
+ }) => {
+ const resultDate = alignToLastDayOfWeek(date, firstDayOfWeek);
+ expect(resultDate).toEqual(date);
+ });
+
+ each`
+ date | rightDate | firstDayOfWeek
${new Date('2023-06-12')} | ${new Date('2023-06-18')} | ${1}
${new Date('2023-06-14')} | ${new Date('2023-06-18')} | ${1}
${new Date('2023-06-16')} | ${new Date('2023-06-18')} | ${1}
${new Date('2023-06-21')} | ${new Date('2023-06-25')} | ${1}
`.it('should return last day of current week', ({
- date, rightDate, firstDayOfWeek
- }) => {
- const resultDate = alignToLastDayOfWeek(date, firstDayOfWeek);
- expect(resultDate).toEqual(rightDate);
- });
+ date, rightDate, firstDayOfWeek,
+ }) => {
+ const resultDate = alignToLastDayOfWeek(date, firstDayOfWeek);
+ expect(resultDate).toEqual(rightDate);
+ });
});
describe('calculateDaysBetweenDates', () => {
- each`
+ each`
fromDate | toDate | res
${new Date('2023-06-28')} | ${new Date('2023-06-28')} | ${1}
${new Date('2023-06-28')} | ${new Date('2023-06-29')} | ${2}
${new Date('2023-06-28')} | ${new Date('2023-07-04')} | ${7}
`.it('should return right count of days between dates', ({
- fromDate, toDate, res
- }) => {
- expect(calculateDaysBetweenDates(fromDate, toDate)).toBe(res);
- });
+ fromDate, toDate, res,
+ }) => {
+ expect(calculateDaysBetweenDates(fromDate, toDate)).toBe(res);
+ });
- each`
+ each`
fromDate | toDate | res
${new Date('2023-06-28T23:59:00')} | ${new Date('2023-06-29T00:01:00')} | ${2}
${new Date('2023-06-28T00:01:00')} | ${new Date('2023-06-28T23:59:00')} | ${1}
`.it('should return right count of days between dates when they have non-zero time', ({
- fromDate, toDate, res
- }) => {
- expect(calculateDaysBetweenDates(fromDate, toDate)).toBe(res);
- });
+ fromDate, toDate, res,
+ }) => {
+ expect(calculateDaysBetweenDates(fromDate, toDate)).toBe(res);
+ });
});
describe('calculateAlignedWeeksBetweenDates', () => {
- each`
+ each`
fromDate | toDate | res
${new Date('2023-10-01')} | ${new Date('2023-10-31')} | ${6}
${new Date('2023-06-01')} | ${new Date('2023-07-31')} | ${10}
`.it('should return right count of days between dates', ({
- fromDate, toDate, res
- }) => {
- expect(calculateAlignedWeeksBetweenDates(fromDate, toDate, 1)).toBe(res);
- });
+ fromDate, toDate, res,
+ }) => {
+ expect(calculateAlignedWeeksBetweenDates(fromDate, toDate, 1)).toBe(res);
+ });
- each`
+ each`
fromDate | toDate | res
${new Date('2023-06-04')} | ${new Date('2023-06-12')} | ${6}
${new Date('2023-06-05')} | ${new Date('2023-06-12')} | ${6}
${new Date('2023-06-05')} | ${new Date('2023-06-11')} | ${6}
`.it('should return at least 6 weeks in order to not make breaking change', ({
- fromDate, toDate, res
- }) => {
- expect(calculateAlignedWeeksBetweenDates(fromDate, toDate, 1)).toBe(res);
- });
+ fromDate, toDate, res,
+ }) => {
+ expect(calculateAlignedWeeksBetweenDates(fromDate, toDate, 1)).toBe(res);
+ });
});
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_date_header_data_generator.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_date_header_data_generator.ts
index ce608573896e..95f8ec5b2a70 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_date_header_data_generator.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_date_header_data_generator.ts
@@ -1,237 +1,237 @@
-import dateUtils from '../../../../core/utils/date';
-import { getGroupCount } from '../../../../__internal/scheduler/resources/m_utils';
+import dateUtils from '@js/core/utils/date';
import {
- getHeaderCellText,
- formatWeekdayAndDay,
- getHorizontalGroupCount,
- getTotalCellCountByCompleteData,
- getDisplayedCellCount,
-} from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
+ formatWeekdayAndDay,
+ getDisplayedCellCount,
+ getHeaderCellText,
+ getHorizontalGroupCount,
+ getTotalCellCountByCompleteData,
+} from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
-export class DateHeaderDataGenerator {
- constructor(viewDataGenerator) {
- this._viewDataGenerator = viewDataGenerator;
- }
-
- getCompleteDateHeaderMap(options, completeViewDataMap) {
- const {
- isGenerateWeekDaysHeaderData,
- } = options;
-
- const result = [];
-
- if(isGenerateWeekDaysHeaderData) {
- const weekDaysRow = this._generateWeekDaysHeaderRowMap(options, completeViewDataMap);
- result.push(weekDaysRow);
- }
-
- const dateRow = this._generateHeaderDateRow(options, completeViewDataMap);
+import { getGroupCount } from '../../resources/m_utils';
- result.push(dateRow);
+export class DateHeaderDataGenerator {
+ constructor(public _viewDataGenerator) {
+ }
- return result;
- }
+ getCompleteDateHeaderMap(options, completeViewDataMap) {
+ const {
+ isGenerateWeekDaysHeaderData,
+ } = options;
- _generateWeekDaysHeaderRowMap(options, completeViewDataMap) {
- const {
- isGroupedByDate,
- groups,
- groupOrientation,
- startDayHour,
- endDayHour,
- hoursInterval,
- isHorizontalGrouping,
- intervalCount,
- } = options;
-
- const cellCountInDay = this._viewDataGenerator.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
- const horizontalGroupCount = getHorizontalGroupCount(groups, groupOrientation);
- const index = completeViewDataMap[0][0].allDay ? 1 : 0;
- const colSpan = isGroupedByDate ? horizontalGroupCount * cellCountInDay : cellCountInDay;
-
- const groupCount = getGroupCount(groups);
- const datesRepeatCount = isHorizontalGrouping && !isGroupedByDate
- ? groupCount
- : 1;
-
- const daysInGroup = this._viewDataGenerator.daysInInterval * intervalCount;
- const daysInView = daysInGroup * datesRepeatCount;
-
- const weekDaysRow = [];
-
- for(let dayIndex = 0; dayIndex < daysInView; dayIndex += 1) {
- const cell = completeViewDataMap[index][dayIndex * colSpan];
-
- weekDaysRow.push({
- ...cell,
- colSpan,
- text: formatWeekdayAndDay(cell.startDate),
- isFirstGroupCell: false,
- isLastGroupCell: false,
- });
- }
-
- return weekDaysRow;
- }
+ const result: any[] = [];
- _generateHeaderDateRow(options, completeViewDataMap) {
- const {
- today,
- isGroupedByDate,
- groupOrientation,
- groups,
- headerCellTextFormat,
- getDateForHeaderText,
- interval,
- startViewDate,
- startDayHour,
- endDayHour,
- hoursInterval,
- intervalCount,
- currentDate,
- viewType,
- } = options;
-
- const horizontalGroupCount = getHorizontalGroupCount(groups, groupOrientation);
- const index = completeViewDataMap[0][0].allDay ? 1 : 0;
- const colSpan = isGroupedByDate ? horizontalGroupCount : 1;
- const isVerticalGrouping = groupOrientation === 'vertical';
- const cellCountInGroupRow = this._viewDataGenerator.getCellCount({
- intervalCount, currentDate, viewType,
- hoursInterval, startDayHour, endDayHour,
- });
- const cellCountInDay = this._viewDataGenerator.getCellCountInDay(
- startDayHour, endDayHour, hoursInterval,
- );
-
- const slicedByColumnsData = isGroupedByDate
- ? completeViewDataMap[index].filter((_, columnIndex) => columnIndex % horizontalGroupCount === 0)
- : completeViewDataMap[index];
-
- return slicedByColumnsData.map(({
- startDate,
- endDate,
- isFirstGroupCell,
- isLastGroupCell,
- ...restProps
- }, index) => {
- const text = getHeaderCellText(
- index % cellCountInGroupRow,
- startDate,
- headerCellTextFormat,
- getDateForHeaderText,
- {
- interval,
- startViewDate,
- startDayHour,
- cellCountInDay,
- },
- );
-
- return ({
- ...restProps,
- startDate,
- text,
- today: dateUtils.sameDate(startDate, today),
- colSpan,
- isFirstGroupCell: isGroupedByDate || (isFirstGroupCell && !isVerticalGrouping),
- isLastGroupCell: isGroupedByDate || (isLastGroupCell && !isVerticalGrouping),
- });
- });
+ if (isGenerateWeekDaysHeaderData) {
+ const weekDaysRow = this._generateWeekDaysHeaderRowMap(options, completeViewDataMap);
+ result.push(weekDaysRow);
}
- generateDateHeaderData(completeDateHeaderMap, completeViewDataMap, options) {
- const {
- isGenerateWeekDaysHeaderData,
- cellWidth,
- isProvideVirtualCellsWidth,
- startDayHour,
- endDayHour,
- hoursInterval,
- isMonthDateHeader,
- } = options;
-
- const dataMap = [];
- let weekDayRowConfig = {};
- const validCellWidth = cellWidth || 0;
-
- if(isGenerateWeekDaysHeaderData) {
- weekDayRowConfig = this._generateDateHeaderDataRow(
- options,
- completeDateHeaderMap,
- completeViewDataMap,
- this._viewDataGenerator.getCellCountInDay(
- startDayHour, endDayHour, hoursInterval,
- ),
- 0,
- validCellWidth,
- );
-
- dataMap.push(weekDayRowConfig.dateRow);
- }
-
- const datesRowConfig = this._generateDateHeaderDataRow(
- options,
- completeDateHeaderMap,
- completeViewDataMap,
- 1,
- isGenerateWeekDaysHeaderData ? 1 : 0,
- validCellWidth,
- );
-
- dataMap.push(datesRowConfig.dateRow);
-
- return {
- dataMap,
- leftVirtualCellWidth: isProvideVirtualCellsWidth ? datesRowConfig.leftVirtualCellWidth : undefined,
- rightVirtualCellWidth: isProvideVirtualCellsWidth ? datesRowConfig.rightVirtualCellWidth : undefined,
- leftVirtualCellCount: datesRowConfig.leftVirtualCellCount,
- rightVirtualCellCount: datesRowConfig.rightVirtualCellCount,
- weekDayLeftVirtualCellWidth: weekDayRowConfig.leftVirtualCellWidth,
- weekDayRightVirtualCellWidth: weekDayRowConfig.rightVirtualCellWidth,
- weekDayLeftVirtualCellCount: weekDayRowConfig.leftVirtualCellCount,
- weekDayRightVirtualCellCount: weekDayRowConfig.rightVirtualCellCount,
- isMonthDateHeader,
- };
+ const dateRow = this._generateHeaderDateRow(options, completeViewDataMap);
+
+ result.push(dateRow);
+
+ return result;
+ }
+
+ _generateWeekDaysHeaderRowMap(options, completeViewDataMap) {
+ const {
+ isGroupedByDate,
+ groups,
+ groupOrientation,
+ startDayHour,
+ endDayHour,
+ hoursInterval,
+ isHorizontalGrouping,
+ intervalCount,
+ } = options;
+
+ const cellCountInDay = this._viewDataGenerator.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
+ const horizontalGroupCount = getHorizontalGroupCount(groups, groupOrientation);
+ const index = completeViewDataMap[0][0].allDay ? 1 : 0;
+ const colSpan = isGroupedByDate ? horizontalGroupCount * cellCountInDay : cellCountInDay;
+
+ const groupCount = getGroupCount(groups);
+ const datesRepeatCount = isHorizontalGrouping && !isGroupedByDate
+ ? groupCount
+ : 1;
+
+ const daysInGroup = this._viewDataGenerator.daysInInterval * intervalCount;
+ const daysInView = daysInGroup * datesRepeatCount;
+
+ const weekDaysRow: any[] = [];
+
+ for (let dayIndex = 0; dayIndex < daysInView; dayIndex += 1) {
+ const cell = completeViewDataMap[index][dayIndex * colSpan];
+
+ weekDaysRow.push({
+ ...cell,
+ colSpan,
+ text: formatWeekdayAndDay(cell.startDate),
+ isFirstGroupCell: false,
+ isLastGroupCell: false,
+ });
}
- _generateDateHeaderDataRow(
+ return weekDaysRow;
+ }
+
+ _generateHeaderDateRow(options, completeViewDataMap) {
+ const {
+ today,
+ isGroupedByDate,
+ groupOrientation,
+ groups,
+ headerCellTextFormat,
+ getDateForHeaderText,
+ interval,
+ startViewDate,
+ startDayHour,
+ endDayHour,
+ hoursInterval,
+ intervalCount,
+ currentDate,
+ viewType,
+ } = options;
+
+ const horizontalGroupCount = getHorizontalGroupCount(groups, groupOrientation);
+ const index = completeViewDataMap[0][0].allDay ? 1 : 0;
+ const colSpan = isGroupedByDate ? horizontalGroupCount : 1;
+ const isVerticalGrouping = groupOrientation === 'vertical';
+ const cellCountInGroupRow = this._viewDataGenerator.getCellCount({
+ intervalCount,
+ currentDate,
+ viewType,
+ hoursInterval,
+ startDayHour,
+ endDayHour,
+ });
+ const cellCountInDay = this._viewDataGenerator.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
+
+ const slicedByColumnsData = isGroupedByDate
+ ? completeViewDataMap[index].filter((_, columnIndex) => columnIndex % horizontalGroupCount === 0)
+ : completeViewDataMap[index];
+
+ return slicedByColumnsData.map(({
+ startDate,
+ endDate,
+ isFirstGroupCell,
+ isLastGroupCell,
+ ...restProps
+ }, index) => {
+ const text = getHeaderCellText(
+ index % cellCountInGroupRow,
+ startDate,
+ headerCellTextFormat,
+ getDateForHeaderText,
+ {
+ interval,
+ startViewDate,
+ startDayHour,
+ cellCountInDay,
+ },
+ );
+
+ return {
+ ...restProps,
+ startDate,
+ text,
+ today: dateUtils.sameDate(startDate, today),
+ colSpan,
+ isFirstGroupCell: isGroupedByDate || (isFirstGroupCell && !isVerticalGrouping),
+ isLastGroupCell: isGroupedByDate || (isLastGroupCell && !isVerticalGrouping),
+ };
+ });
+ }
+
+ generateDateHeaderData(completeDateHeaderMap, completeViewDataMap, options) {
+ const {
+ isGenerateWeekDaysHeaderData,
+ cellWidth,
+ isProvideVirtualCellsWidth,
+ startDayHour,
+ endDayHour,
+ hoursInterval,
+ isMonthDateHeader,
+ } = options;
+
+ const dataMap: any[] = [];
+ let weekDayRowConfig: any = {};
+ const validCellWidth = cellWidth || 0;
+
+ if (isGenerateWeekDaysHeaderData) {
+ weekDayRowConfig = this._generateDateHeaderDataRow(
options,
completeDateHeaderMap,
completeViewDataMap,
- baseColSpan,
- rowIndex,
- cellWidth,
- ) {
- const {
- startCellIndex,
- cellCount,
- isProvideVirtualCellsWidth,
- groups,
- groupOrientation,
- isGroupedByDate,
- } = options;
-
- const horizontalGroupCount = getHorizontalGroupCount(groups, groupOrientation);
- const colSpan = isGroupedByDate ? horizontalGroupCount * baseColSpan : baseColSpan;
- const leftVirtualCellCount = Math.floor(startCellIndex / colSpan);
- const displayedCellCount = getDisplayedCellCount(cellCount, completeViewDataMap);
- const actualCellCount = Math.ceil((startCellIndex + displayedCellCount) / colSpan);
- const totalCellCount = getTotalCellCountByCompleteData(completeViewDataMap);
-
- const dateRow = completeDateHeaderMap[rowIndex].slice(leftVirtualCellCount, actualCellCount);
-
- const finalLeftVirtualCellCount = leftVirtualCellCount * colSpan;
- const finalLeftVirtualCellWidth = finalLeftVirtualCellCount * cellWidth;
- const finalRightVirtualCellCount = totalCellCount - actualCellCount * colSpan;
- const finalRightVirtualCellWidth = finalRightVirtualCellCount * cellWidth;
-
- return {
- dateRow,
- leftVirtualCellCount: finalLeftVirtualCellCount,
- leftVirtualCellWidth: isProvideVirtualCellsWidth ? finalLeftVirtualCellWidth : undefined,
- rightVirtualCellCount: finalRightVirtualCellCount,
- rightVirtualCellWidth: isProvideVirtualCellsWidth ? finalRightVirtualCellWidth : undefined,
- };
+ this._viewDataGenerator.getCellCountInDay(startDayHour, endDayHour, hoursInterval),
+ 0,
+ validCellWidth,
+ );
+
+ dataMap.push(weekDayRowConfig.dateRow);
}
+
+ const datesRowConfig = this._generateDateHeaderDataRow(
+ options,
+ completeDateHeaderMap,
+ completeViewDataMap,
+ 1,
+ isGenerateWeekDaysHeaderData ? 1 : 0,
+ validCellWidth,
+ );
+
+ dataMap.push(datesRowConfig.dateRow);
+
+ return {
+ dataMap,
+ leftVirtualCellWidth: isProvideVirtualCellsWidth ? datesRowConfig.leftVirtualCellWidth : undefined,
+ rightVirtualCellWidth: isProvideVirtualCellsWidth ? datesRowConfig.rightVirtualCellWidth : undefined,
+ leftVirtualCellCount: datesRowConfig.leftVirtualCellCount,
+ rightVirtualCellCount: datesRowConfig.rightVirtualCellCount,
+ weekDayLeftVirtualCellWidth: weekDayRowConfig.leftVirtualCellWidth,
+ weekDayRightVirtualCellWidth: weekDayRowConfig.rightVirtualCellWidth,
+ weekDayLeftVirtualCellCount: weekDayRowConfig.leftVirtualCellCount,
+ weekDayRightVirtualCellCount: weekDayRowConfig.rightVirtualCellCount,
+ isMonthDateHeader,
+ };
+ }
+
+ _generateDateHeaderDataRow(
+ options,
+ completeDateHeaderMap,
+ completeViewDataMap,
+ baseColSpan,
+ rowIndex,
+ cellWidth,
+ ) {
+ const {
+ startCellIndex,
+ cellCount,
+ isProvideVirtualCellsWidth,
+ groups,
+ groupOrientation,
+ isGroupedByDate,
+ } = options;
+
+ const horizontalGroupCount = getHorizontalGroupCount(groups, groupOrientation);
+ const colSpan = isGroupedByDate ? horizontalGroupCount * baseColSpan : baseColSpan;
+ const leftVirtualCellCount = Math.floor(startCellIndex / colSpan);
+ const displayedCellCount = getDisplayedCellCount(cellCount, completeViewDataMap);
+ const actualCellCount = Math.ceil((startCellIndex + displayedCellCount) / colSpan);
+ const totalCellCount = getTotalCellCountByCompleteData(completeViewDataMap);
+
+ const dateRow = completeDateHeaderMap[rowIndex].slice(leftVirtualCellCount, actualCellCount);
+
+ const finalLeftVirtualCellCount = leftVirtualCellCount * colSpan;
+ const finalLeftVirtualCellWidth = finalLeftVirtualCellCount * cellWidth;
+ const finalRightVirtualCellCount = totalCellCount - actualCellCount * colSpan;
+ const finalRightVirtualCellWidth = finalRightVirtualCellCount * cellWidth;
+
+ return {
+ dateRow,
+ leftVirtualCellCount: finalLeftVirtualCellCount,
+ leftVirtualCellWidth: isProvideVirtualCellsWidth ? finalLeftVirtualCellWidth : undefined,
+ rightVirtualCellCount: finalRightVirtualCellCount,
+ rightVirtualCellWidth: isProvideVirtualCellsWidth ? finalRightVirtualCellWidth : undefined,
+ };
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_grouped_data_map_provider.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_grouped_data_map_provider.ts
index bb6a59165541..e88959aee42f 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_grouped_data_map_provider.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_grouped_data_map_provider.ts
@@ -1,220 +1,229 @@
-import dateUtils from '../../../../core/utils/date';
-import { isDateAndTimeView } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
+import dateUtils from '@js/core/utils/date';
+import { isDateAndTimeView } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
export class GroupedDataMapProvider {
- constructor(viewDataGenerator, viewDataMap, completeViewDataMap, viewOptions) {
- this.groupedDataMap = viewDataGenerator.generateGroupedDataMap(viewDataMap);
- this.completeViewDataMap = completeViewDataMap;
- this._viewOptions = viewOptions;
- }
+ groupedDataMap: any;
- getGroupStartDate(groupIndex) {
- const firstRow = this.getFirstGroupRow(groupIndex);
+ completeViewDataMap: any;
- if(firstRow) {
- const { startDate } = firstRow[0].cellData;
+ _viewOptions: any;
- return startDate;
- }
- }
+ constructor(viewDataGenerator, viewDataMap, completeViewDataMap, viewOptions) {
+ this.groupedDataMap = viewDataGenerator.generateGroupedDataMap(viewDataMap);
+ this.completeViewDataMap = completeViewDataMap;
+ this._viewOptions = viewOptions;
+ }
- getGroupEndDate(groupIndex) {
- const lastRow = this.getLastGroupRow(groupIndex);
+ getGroupStartDate(groupIndex) {
+ const firstRow = this.getFirstGroupRow(groupIndex);
- if(lastRow) {
- const lastColumnIndex = lastRow.length - 1;
- const { cellData } = lastRow[lastColumnIndex];
- const { endDate } = cellData;
+ if (firstRow) {
+ const { startDate } = firstRow[0].cellData;
- return endDate;
- }
+ return startDate;
}
+ }
- findGroupCellStartDate(groupIndex, startDate, endDate, isFindByDate) {
- const groupData = this.getGroupFromDateTableGroupMap(groupIndex);
- const checkCellStartDate = (rowIndex, columnIndex) => {
- const { cellData } = groupData[rowIndex][columnIndex];
- let {
- startDate: secondMin,
- endDate: secondMax
- } = cellData;
-
- if(isFindByDate) {
- secondMin = dateUtils.trimTime(secondMin);
- secondMax = dateUtils.setToDayEnd(secondMin);
- }
-
- if(dateUtils.intervalsOverlap({
- firstMin: startDate,
- firstMax: endDate,
- secondMin,
- secondMax
- })) {
- return secondMin;
- }
- };
- const searchVertical = () => {
- const cellCount = groupData[0].length;
- for(let columnIndex = 0; columnIndex < cellCount; ++columnIndex) {
- for(let rowIndex = 0; rowIndex < groupData.length; ++rowIndex) {
- const result = checkCellStartDate(rowIndex, columnIndex);
- if(result) return result;
- }
- }
- };
- const searchHorizontal = () => {
- for(let rowIndex = 0; rowIndex < groupData.length; ++rowIndex) {
- const row = groupData[rowIndex];
- for(let columnIndex = 0; columnIndex < row.length; ++columnIndex) {
- const result = checkCellStartDate(rowIndex, columnIndex);
- if(result) return result;
- }
- }
- };
-
- const startDateVerticalSearch = searchVertical();
- const startDateHorizontalSearch = searchHorizontal();
-
- return startDateVerticalSearch > startDateHorizontalSearch
- ? startDateHorizontalSearch
- : startDateVerticalSearch;
- }
+ getGroupEndDate(groupIndex) {
+ const lastRow = this.getLastGroupRow(groupIndex);
- findAllDayGroupCellStartDate(groupIndex, startDate) {
- const groupStartDate = this.getGroupStartDate(groupIndex);
+ if (lastRow) {
+ const lastColumnIndex = lastRow.length - 1;
+ const { cellData } = lastRow[lastColumnIndex];
+ const { endDate } = cellData;
- return groupStartDate > startDate
- ? groupStartDate
- : startDate;
+ return endDate;
}
-
- findCellPositionInMap(cellInfo) {
- const { groupIndex, startDate, isAllDay, index } = cellInfo;
-
- const startTime = isAllDay
- ? dateUtils.trimTime(startDate).getTime()
- : startDate.getTime();
-
- const isStartDateInCell = cellData => {
- if(!isDateAndTimeView(this._viewOptions.viewType)) {
- return dateUtils.sameDate(startDate, cellData.startDate);
- }
-
- const cellStartTime = cellData.startDate.getTime();
- const cellEndTime = cellData.endDate.getTime();
-
- return isAllDay
- ? cellData.allDay && startTime >= cellStartTime && startTime <= cellEndTime
- : startTime >= cellStartTime && startTime < cellEndTime;
- };
-
- const {
- allDayPanelGroupedMap,
- dateTableGroupedMap
- } = this.groupedDataMap;
-
- const rows = isAllDay && !this._viewOptions.isVerticalGrouping
- ? (allDayPanelGroupedMap[groupIndex] ? [allDayPanelGroupedMap[groupIndex]] : [])
- : dateTableGroupedMap[groupIndex] || [];
-
- for(let rowIndex = 0; rowIndex < rows.length; ++rowIndex) {
- const row = rows[rowIndex];
-
- for(let columnIndex = 0; columnIndex < row.length; ++columnIndex) {
- const cell = row[columnIndex];
- const { cellData } = cell;
-
- if(this._isSameGroupIndexAndIndex(cellData, groupIndex, index)) {
- if(isStartDateInCell(cellData)) {
- return cell.position;
- }
- }
- }
+ }
+
+ findGroupCellStartDate(groupIndex, startDate, endDate, isFindByDate) {
+ const groupData = this.getGroupFromDateTableGroupMap(groupIndex);
+ const checkCellStartDate = (rowIndex, columnIndex) => {
+ const { cellData } = groupData[rowIndex][columnIndex];
+ let {
+ startDate: secondMin,
+ endDate: secondMax,
+ } = cellData;
+
+ if (isFindByDate) {
+ secondMin = dateUtils.trimTime(secondMin);
+ secondMax = dateUtils.setToDayEnd(secondMin);
+ }
+
+ if (dateUtils.intervalsOverlap({
+ firstMin: startDate,
+ firstMax: endDate,
+ secondMin,
+ secondMax,
+ })) {
+ return secondMin;
+ }
+ };
+ const searchVertical = () => {
+ const cellCount = groupData[0].length;
+ for (let columnIndex = 0; columnIndex < cellCount; ++columnIndex) {
+ for (let rowIndex = 0; rowIndex < groupData.length; ++rowIndex) {
+ const result = checkCellStartDate(rowIndex, columnIndex);
+ if (result) return result;
}
-
- return undefined;
- }
-
- _isSameGroupIndexAndIndex(cellData, groupIndex, index) {
- return cellData.groupIndex === groupIndex
- && (index === undefined || cellData.index === index);
- }
-
- getCellsGroup(groupIndex) {
- const { dateTableGroupedMap } = this.groupedDataMap;
- const groupData = dateTableGroupedMap[groupIndex];
-
- if(groupData) {
- const { cellData } = groupData[0][0];
-
- return cellData.groups;
+ }
+ };
+ const searchHorizontal = () => {
+ for (let rowIndex = 0; rowIndex < groupData.length; ++rowIndex) {
+ const row = groupData[rowIndex];
+ for (let columnIndex = 0; columnIndex < row.length; ++columnIndex) {
+ const result = checkCellStartDate(rowIndex, columnIndex);
+ if (result) return result;
}
+ }
+ };
+
+ const startDateVerticalSearch = searchVertical();
+ const startDateHorizontalSearch = searchHorizontal();
+
+ return startDateVerticalSearch > startDateHorizontalSearch
+ ? startDateHorizontalSearch
+ : startDateVerticalSearch;
+ }
+
+ findAllDayGroupCellStartDate(groupIndex, startDate) {
+ const groupStartDate = this.getGroupStartDate(groupIndex);
+
+ return groupStartDate > startDate
+ ? groupStartDate
+ : startDate;
+ }
+
+ findCellPositionInMap(cellInfo) {
+ const {
+ groupIndex, startDate, isAllDay, index,
+ } = cellInfo;
+
+ const startTime = isAllDay
+ ? dateUtils.trimTime(startDate).getTime()
+ : startDate.getTime();
+
+ const isStartDateInCell = (cellData) => {
+ if (!isDateAndTimeView(this._viewOptions.viewType)) {
+ return dateUtils.sameDate(startDate, cellData.startDate);
+ }
+
+ const cellStartTime = cellData.startDate.getTime();
+ const cellEndTime = cellData.endDate.getTime();
+
+ return isAllDay
+ ? cellData.allDay && startTime >= cellStartTime && startTime <= cellEndTime
+ : startTime >= cellStartTime && startTime < cellEndTime;
+ };
+
+ const {
+ allDayPanelGroupedMap,
+ dateTableGroupedMap,
+ } = this.groupedDataMap;
+
+ const rows = isAllDay && !this._viewOptions.isVerticalGrouping
+ ? allDayPanelGroupedMap[groupIndex] ? [allDayPanelGroupedMap[groupIndex]] : []
+ : dateTableGroupedMap[groupIndex] || [];
+
+ for (let rowIndex = 0; rowIndex < rows.length; ++rowIndex) {
+ const row = rows[rowIndex];
+
+ for (let columnIndex = 0; columnIndex < row.length; ++columnIndex) {
+ const cell = row[columnIndex];
+ const { cellData } = cell;
+
+ if (this._isSameGroupIndexAndIndex(cellData, groupIndex, index)) {
+ if (isStartDateInCell(cellData)) {
+ return cell.position;
+ }
+ }
+ }
}
- getCompletedGroupsInfo() {
- const { dateTableGroupedMap } = this.groupedDataMap;
- return dateTableGroupedMap.map(groupData => {
- const firstCell = groupData[0][0];
- const {
- allDay,
- groupIndex
- } = firstCell.cellData;
-
- return {
- allDay,
- groupIndex,
- startDate: this.getGroupStartDate(groupIndex),
- endDate: this.getGroupEndDate(groupIndex)
- };
- }).filter(({ startDate }) => !!startDate);
- }
-
- getGroupIndices() {
- return this.getCompletedGroupsInfo()
- .map(({ groupIndex }) => groupIndex);
- }
-
- getGroupFromDateTableGroupMap(groupIndex) {
- const { dateTableGroupedMap } = this.groupedDataMap;
+ return undefined;
+ }
- return dateTableGroupedMap[groupIndex];
- }
+ _isSameGroupIndexAndIndex(cellData, groupIndex, index) {
+ return cellData.groupIndex === groupIndex
+ && (index === undefined || cellData.index === index);
+ }
- getFirstGroupRow(groupIndex) {
- const groupedData = this.getGroupFromDateTableGroupMap(groupIndex);
+ getCellsGroup(groupIndex) {
+ const { dateTableGroupedMap } = this.groupedDataMap;
+ const groupData = dateTableGroupedMap[groupIndex];
- if(groupedData) {
- const { cellData } = groupedData[0][0];
+ if (groupData) {
+ const { cellData } = groupData[0][0];
- return !cellData.allDay
- ? groupedData[0]
- : groupedData[1];
- }
+ return cellData.groups;
}
+ }
+
+ getCompletedGroupsInfo() {
+ const { dateTableGroupedMap } = this.groupedDataMap;
+ return dateTableGroupedMap.map((groupData) => {
+ const firstCell = groupData[0][0];
+ const {
+ allDay,
+ groupIndex,
+ } = firstCell.cellData;
+
+ return {
+ allDay,
+ groupIndex,
+ startDate: this.getGroupStartDate(groupIndex),
+ endDate: this.getGroupEndDate(groupIndex),
+ };
+ }).filter(({ startDate }) => !!startDate);
+ }
+
+ getGroupIndices() {
+ return this.getCompletedGroupsInfo()
+ .map(({ groupIndex }) => groupIndex);
+ }
+
+ getGroupFromDateTableGroupMap(groupIndex) {
+ const { dateTableGroupedMap } = this.groupedDataMap;
+
+ return dateTableGroupedMap[groupIndex];
+ }
+
+ getFirstGroupRow(groupIndex) {
+ const groupedData = this.getGroupFromDateTableGroupMap(groupIndex);
+
+ if (groupedData) {
+ const { cellData } = groupedData[0][0];
+
+ return !cellData.allDay
+ ? groupedData[0]
+ : groupedData[1];
+ }
+ }
- getLastGroupRow(groupIndex) {
- const { dateTableGroupedMap } = this.groupedDataMap;
- const groupedData = dateTableGroupedMap[groupIndex];
+ getLastGroupRow(groupIndex) {
+ const { dateTableGroupedMap } = this.groupedDataMap;
+ const groupedData = dateTableGroupedMap[groupIndex];
- if(groupedData) {
- const lastRowIndex = groupedData.length - 1;
+ if (groupedData) {
+ const lastRowIndex = groupedData.length - 1;
- return groupedData[lastRowIndex];
- }
+ return groupedData[lastRowIndex];
}
+ }
- getLastGroupCellPosition(groupIndex) {
- const groupRow = this.getLastGroupRow(groupIndex);
+ getLastGroupCellPosition(groupIndex) {
+ const groupRow = this.getLastGroupRow(groupIndex);
- return groupRow?.[groupRow?.length - 1].position;
- }
+ // eslint-disable-next-line no-unsafe-optional-chaining
+ return groupRow?.[groupRow?.length - 1].position;
+ }
- getRowCountInGroup(groupIndex) {
- const groupRow = this.getLastGroupRow(groupIndex);
- const cellAmount = groupRow.length;
- const lastCellData = groupRow[cellAmount - 1].cellData;
- const lastCellIndex = lastCellData.index;
+ getRowCountInGroup(groupIndex) {
+ const groupRow = this.getLastGroupRow(groupIndex);
+ const cellAmount = groupRow.length;
+ const lastCellData = groupRow[cellAmount - 1].cellData;
+ const lastCellIndex = lastCellData.index;
- return (lastCellIndex + 1) / groupRow.length;
- }
+ return (lastCellIndex + 1) / groupRow.length;
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_time_panel_data_generator.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_time_panel_data_generator.ts
index 01d983767eff..9bc0e51e3cdf 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_time_panel_data_generator.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_time_panel_data_generator.ts
@@ -1,122 +1,129 @@
-import { getIsGroupedAllDayPanel, getKeyByGroup } from '../../../../renovation/ui/scheduler/workspaces/utils';
-import { getDisplayedRowCount } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
-import { getTimePanelCellText } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/week';
+import { getDisplayedRowCount } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
+import { getTimePanelCellText } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/week';
+import { getIsGroupedAllDayPanel, getKeyByGroup } from '@js/renovation/ui/scheduler/workspaces/utils';
export class TimePanelDataGenerator {
- constructor(viewDataGenerator) {
- this._viewDataGenerator = viewDataGenerator;
- }
-
- getCompleteTimePanelMap(options, completeViewDataMap) {
- const {
- startViewDate,
- cellDuration,
- startDayHour,
- isVerticalGrouping,
- intervalCount,
- currentDate,
- viewType,
- hoursInterval,
- endDayHour,
- } = options;
-
- const rowCountInGroup = this._viewDataGenerator.getRowCount({
- intervalCount, currentDate, viewType,
- hoursInterval, startDayHour, endDayHour,
+ constructor(public _viewDataGenerator) {
+ }
+
+ getCompleteTimePanelMap(options, completeViewDataMap) {
+ const {
+ startViewDate,
+ cellDuration,
+ startDayHour,
+ isVerticalGrouping,
+ intervalCount,
+ currentDate,
+ viewType,
+ hoursInterval,
+ endDayHour,
+ } = options;
+
+ const rowCountInGroup = this._viewDataGenerator.getRowCount({
+ intervalCount,
+ currentDate,
+ viewType,
+ hoursInterval,
+ startDayHour,
+ endDayHour,
+ });
+ const cellCountInGroupRow = this._viewDataGenerator.getCellCount({
+ intervalCount,
+ currentDate,
+ viewType,
+ hoursInterval,
+ startDayHour,
+ endDayHour,
+ });
+ let allDayRowsCount = 0;
+
+ return completeViewDataMap.map((row, index) => {
+ const {
+ allDay,
+ startDate,
+ endDate,
+ groups,
+ groupIndex,
+ isFirstGroupCell,
+ isLastGroupCell,
+ index: cellIndex,
+ ...restCellProps
+ } = row[0];
+
+ if (allDay) {
+ allDayRowsCount += 1;
+ }
+
+ const timeIndex = (index - allDayRowsCount) % rowCountInGroup;
+
+ return {
+ ...restCellProps,
+ startDate,
+ allDay,
+ text: getTimePanelCellText(timeIndex, startDate, startViewDate, cellDuration, startDayHour),
+ groups: isVerticalGrouping ? groups : undefined,
+ groupIndex: isVerticalGrouping ? groupIndex : undefined,
+ isFirstGroupCell: isVerticalGrouping && isFirstGroupCell,
+ isLastGroupCell: isVerticalGrouping && isLastGroupCell,
+ index: Math.floor(cellIndex / cellCountInGroupRow),
+ };
+ });
+ }
+
+ generateTimePanelData(completeTimePanelMap, options) {
+ const {
+ startRowIndex,
+ rowCount,
+ topVirtualRowHeight,
+ bottomVirtualRowHeight,
+ isGroupedAllDayPanel,
+ isVerticalGrouping,
+ isAllDayPanelVisible,
+ } = options;
+
+ const indexDifference = isVerticalGrouping || !isAllDayPanelVisible ? 0 : 1;
+ const correctedStartRowIndex = startRowIndex + indexDifference;
+
+ const displayedRowCount = getDisplayedRowCount(rowCount, completeTimePanelMap);
+ const timePanelMap = completeTimePanelMap
+ .slice(correctedStartRowIndex, correctedStartRowIndex + displayedRowCount);
+
+ const timePanelData: any = {
+ topVirtualRowHeight,
+ bottomVirtualRowHeight,
+ isGroupedAllDayPanel,
+ };
+
+ const {
+ previousGroupedData: groupedData,
+ } = this._generateTimePanelDataFromMap(timePanelMap, isVerticalGrouping);
+
+ timePanelData.groupedData = groupedData;
+
+ return timePanelData;
+ }
+
+ _generateTimePanelDataFromMap(timePanelMap, isVerticalGrouping) {
+ return timePanelMap.reduce(({ previousGroupIndex, previousGroupedData }, cellData) => {
+ const currentGroupIndex = cellData.groupIndex;
+ if (currentGroupIndex !== previousGroupIndex) {
+ previousGroupedData.push({
+ dateTable: [],
+ isGroupedAllDayPanel: getIsGroupedAllDayPanel(!!cellData.allDay, isVerticalGrouping),
+ groupIndex: currentGroupIndex,
+ key: getKeyByGroup(currentGroupIndex, isVerticalGrouping),
});
- const cellCountInGroupRow = this._viewDataGenerator.getCellCount({
- intervalCount, currentDate, viewType,
- hoursInterval, startDayHour, endDayHour,
- });
- let allDayRowsCount = 0;
-
- return completeViewDataMap.map((row, index) => {
- const {
- allDay,
- startDate,
- endDate,
- groups,
- groupIndex,
- isFirstGroupCell,
- isLastGroupCell,
- index: cellIndex,
- ...restCellProps
- } = row[0];
-
- if(allDay) {
- allDayRowsCount += 1;
- }
-
- const timeIndex = (index - allDayRowsCount) % rowCountInGroup;
-
- return {
- ...restCellProps,
- startDate,
- allDay,
- text: getTimePanelCellText(timeIndex, startDate, startViewDate, cellDuration, startDayHour),
- groups: isVerticalGrouping ? groups : undefined,
- groupIndex: isVerticalGrouping ? groupIndex : undefined,
- isFirstGroupCell: isVerticalGrouping && isFirstGroupCell,
- isLastGroupCell: isVerticalGrouping && isLastGroupCell,
- index: Math.floor(cellIndex / cellCountInGroupRow),
- };
- });
- }
-
- generateTimePanelData(completeTimePanelMap, options) {
- const {
- startRowIndex,
- rowCount,
- topVirtualRowHeight,
- bottomVirtualRowHeight,
- isGroupedAllDayPanel,
- isVerticalGrouping,
- isAllDayPanelVisible,
- } = options;
-
- const indexDifference = isVerticalGrouping || !isAllDayPanelVisible ? 0 : 1;
- const correctedStartRowIndex = startRowIndex + indexDifference;
-
- const displayedRowCount = getDisplayedRowCount(rowCount, completeTimePanelMap);
- const timePanelMap = completeTimePanelMap
- .slice(correctedStartRowIndex, correctedStartRowIndex + displayedRowCount);
-
- const timePanelData = {
- topVirtualRowHeight,
- bottomVirtualRowHeight,
- isGroupedAllDayPanel,
- };
-
- const {
- previousGroupedData: groupedData,
- } = this._generateTimePanelDataFromMap(timePanelMap, isVerticalGrouping);
-
- timePanelData.groupedData = groupedData;
-
- return timePanelData;
- }
-
- _generateTimePanelDataFromMap(timePanelMap, isVerticalGrouping) {
- return timePanelMap.reduce(({ previousGroupIndex, previousGroupedData }, cellData) => {
- const currentGroupIndex = cellData.groupIndex;
- if(currentGroupIndex !== previousGroupIndex) {
- previousGroupedData.push({
- dateTable: [],
- isGroupedAllDayPanel: getIsGroupedAllDayPanel(!!cellData.allDay, isVerticalGrouping),
- groupIndex: currentGroupIndex,
- key: getKeyByGroup(currentGroupIndex, isVerticalGrouping),
- });
- }
- if(cellData.allDay) {
- previousGroupedData[previousGroupedData.length - 1].allDayPanel = cellData;
- } else {
- previousGroupedData[previousGroupedData.length - 1].dateTable.push(cellData);
- }
-
- return {
- previousGroupIndex: currentGroupIndex,
- previousGroupedData,
- };
- }, { previousGroupIndex: -1, previousGroupedData: [] });
- }
+ }
+ if (cellData.allDay) {
+ previousGroupedData[previousGroupedData.length - 1].allDayPanel = cellData;
+ } else {
+ previousGroupedData[previousGroupedData.length - 1].dateTable.push(cellData);
+ }
+
+ return {
+ previousGroupIndex: currentGroupIndex,
+ previousGroupedData,
+ };
+ }, { previousGroupIndex: -1, previousGroupedData: [] });
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_utils.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_utils.ts
index 2ca0fb20110b..136f07e79769 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_utils.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_utils.ts
@@ -1,63 +1,65 @@
-import dateUtils from '../../../../core/utils/date';
-import { VIEWS } from '../../constants';
-import { ViewDataGenerator } from './view_data_generator';
-import { ViewDataGeneratorDay } from './view_data_generator_day';
-import { ViewDataGeneratorMonth } from './view_data_generator_month';
-import { ViewDataGeneratorTimelineMonth } from './view_data_generator_timeline_month';
-import { ViewDataGeneratorWeek } from './view_data_generator_week';
-import { ViewDataGeneratorWorkWeek } from './view_data_generator_work_week';
+import dateUtils from '@js/core/utils/date';
+
+import { VIEWS } from '../../m_constants';
+import { ViewDataGenerator } from './m_view_data_generator';
+import { ViewDataGeneratorDay } from './m_view_data_generator_day';
+// eslint-disable-next-line import/no-cycle
+import { ViewDataGeneratorMonth } from './m_view_data_generator_month';
+import { ViewDataGeneratorTimelineMonth } from './m_view_data_generator_timeline_month';
+import { ViewDataGeneratorWeek } from './m_view_data_generator_week';
+import { ViewDataGeneratorWorkWeek } from './m_view_data_generator_work_week';
const DAYS_IN_WEEK = 7;
const MS_IN_DAY = 24 * 60 * 60 * 1000;
export const getViewDataGeneratorByViewType = (viewType) => {
- switch(viewType) {
- case VIEWS.MONTH:
- return new ViewDataGeneratorMonth();
- case VIEWS.TIMELINE_MONTH:
- return new ViewDataGeneratorTimelineMonth();
- case VIEWS.DAY:
- case VIEWS.TIMELINE_DAY:
- return new ViewDataGeneratorDay();
- case VIEWS.WEEK:
- case VIEWS.TIMELINE_WEEK:
- return new ViewDataGeneratorWeek();
- case VIEWS.WORK_WEEK:
- case VIEWS.TIMELINE_WORK_WEEK:
- return new ViewDataGeneratorWorkWeek();
- default:
- return new ViewDataGenerator();
- }
+ switch (viewType) {
+ case VIEWS.MONTH:
+ return new ViewDataGeneratorMonth();
+ case VIEWS.TIMELINE_MONTH:
+ return new ViewDataGeneratorTimelineMonth();
+ case VIEWS.DAY:
+ case VIEWS.TIMELINE_DAY:
+ return new ViewDataGeneratorDay();
+ case VIEWS.WEEK:
+ case VIEWS.TIMELINE_WEEK:
+ return new ViewDataGeneratorWeek();
+ case VIEWS.WORK_WEEK:
+ case VIEWS.TIMELINE_WORK_WEEK:
+ return new ViewDataGeneratorWorkWeek();
+ default:
+ return new ViewDataGenerator();
+ }
};
export function alignToFirstDayOfWeek(date, firstDayOfWeek) {
- const newDate = new Date(date);
- let dayDiff = newDate.getDay() - firstDayOfWeek;
+ const newDate = new Date(date);
+ let dayDiff = newDate.getDay() - firstDayOfWeek;
- if(dayDiff < 0) {
- dayDiff += DAYS_IN_WEEK;
- }
+ if (dayDiff < 0) {
+ dayDiff += DAYS_IN_WEEK;
+ }
- newDate.setDate(newDate.getDate() - dayDiff);
+ newDate.setDate(newDate.getDate() - dayDiff);
- return newDate;
+ return newDate;
}
export function alignToLastDayOfWeek(date, firstDayOfWeek) {
- const newDate = alignToFirstDayOfWeek(date, firstDayOfWeek);
- newDate.setDate(newDate.getDate() + DAYS_IN_WEEK - 1);
- return newDate;
+ const newDate = alignToFirstDayOfWeek(date, firstDayOfWeek);
+ newDate.setDate(newDate.getDate() + DAYS_IN_WEEK - 1);
+ return newDate;
}
export function calculateDaysBetweenDates(fromDate, toDate) {
- const msDiff = dateUtils.trimTime(toDate).getTime() - dateUtils.trimTime(fromDate).getTime();
- return Math.round(msDiff / MS_IN_DAY) + 1;
+ const msDiff = dateUtils.trimTime(toDate).getTime() - dateUtils.trimTime(fromDate).getTime();
+ return Math.round(msDiff / MS_IN_DAY) + 1;
}
export function calculateAlignedWeeksBetweenDates(fromDate, toDate, firstDayOfWeek) {
- const alignedFromDate = alignToFirstDayOfWeek(fromDate, firstDayOfWeek);
- const alignedToDate = alignToLastDayOfWeek(toDate, firstDayOfWeek);
+ const alignedFromDate = alignToFirstDayOfWeek(fromDate, firstDayOfWeek);
+ const alignedToDate = alignToLastDayOfWeek(toDate, firstDayOfWeek);
- const weekCount = calculateDaysBetweenDates(alignedFromDate, alignedToDate) / DAYS_IN_WEEK;
- return Math.max(weekCount, 6);
+ const weekCount = calculateDaysBetweenDates(alignedFromDate, alignedToDate) / DAYS_IN_WEEK;
+ return Math.max(weekCount, 6);
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator.ts
index ba3184b58e9e..568e85bbf721 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator.ts
@@ -1,711 +1,706 @@
-import dateUtils from '../../../../core/utils/date';
-import { HORIZONTAL_GROUP_ORIENTATION } from '../../constants';
-import { getAllGroups, getGroupCount } from '../../../../__internal/scheduler/resources/m_utils';
+import dateUtils from '@js/core/utils/date';
import {
- calculateCellIndex,
- calculateDayDuration,
- isHorizontalView,
- getStartViewDateWithoutDST,
- getDisplayedRowCount,
- getTotalCellCountByCompleteData,
- getTotalRowCountByCompleteData,
- getDisplayedCellCount,
-} from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
-import { getIsGroupedAllDayPanel, getKeyByGroup } from '../../../../renovation/ui/scheduler/workspaces/utils';
+ calculateCellIndex,
+ calculateDayDuration,
+ getDisplayedCellCount,
+ getDisplayedRowCount,
+ getStartViewDateWithoutDST,
+ getTotalCellCountByCompleteData,
+ getTotalRowCountByCompleteData,
+ isHorizontalView,
+} from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
+import { getIsGroupedAllDayPanel, getKeyByGroup } from '@js/renovation/ui/scheduler/workspaces/utils';
+
+import { HORIZONTAL_GROUP_ORIENTATION } from '../../m_constants';
+import { getAllGroups, getGroupCount } from '../../resources/m_utils';
const HOUR_MS = dateUtils.dateToMilliseconds('hour');
const DAY_MS = dateUtils.dateToMilliseconds('day');
export class ViewDataGenerator {
- get daysInInterval() { return 1; }
+ readonly daysInInterval: number = 1;
- get isWorkView() { return false; }
+ readonly isWorkView: boolean = false;
- get tableAllDay() { return false; }
+ tableAllDay = false;
- isSkippedDate() {
- return false;
- }
-
- getStartViewDate(options) {
- return this._calculateStartViewDate(options);
- }
-
- getCompleteViewDataMap(options) {
- const {
- groups,
- isGroupedByDate,
- isHorizontalGrouping,
- isVerticalGrouping,
- intervalCount,
- currentDate,
- viewType,
- startDayHour,
- endDayHour,
- hoursInterval,
- } = options;
-
- this._setVisibilityDates(options);
- this.setHiddenInterval(startDayHour, endDayHour, hoursInterval);
-
- const groupsList = getAllGroups(groups);
- const cellCountInGroupRow = this.getCellCount({
- intervalCount,
- currentDate,
- viewType,
- startDayHour,
- endDayHour,
- hoursInterval,
- });
- const rowCountInGroup = this.getRowCount({
- intervalCount,
- currentDate,
- viewType,
- hoursInterval,
- startDayHour,
- endDayHour,
- });
-
- let viewDataMap = [];
- const allDayPanelData = this._generateAllDayPanelData(options, rowCountInGroup, cellCountInGroupRow);
- const viewCellsData = this._generateViewCellsData(options, rowCountInGroup, cellCountInGroupRow);
-
- allDayPanelData && viewDataMap.push(allDayPanelData);
- viewDataMap.push(...viewCellsData);
-
- if(isHorizontalGrouping && !isGroupedByDate) {
- viewDataMap = this._transformViewDataMapForHorizontalGrouping(viewDataMap, groupsList);
- }
-
- if(isVerticalGrouping) {
- viewDataMap = this._transformViewDataMapForVerticalGrouping(viewDataMap, groupsList);
- }
+ hiddenInterval: any;
- if(isGroupedByDate) {
- viewDataMap = this._transformViewDataMapForGroupingByDate(viewDataMap, groupsList);
- }
-
- const completeViewDataMap = this._addKeysToCells(viewDataMap);
-
- return completeViewDataMap;
- }
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ isSkippedDate(date: any) {
+ return false;
+ }
- _transformViewDataMapForHorizontalGrouping(viewDataMap, groupsList) {
- const result = viewDataMap.map(row => row.slice());
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ _calculateStartViewDate(options: any) {}
- groupsList.slice(1).forEach((groups, index) => {
- const groupIndex = index + 1;
+ getStartViewDate(options): any {
+ return this._calculateStartViewDate(options);
+ }
- viewDataMap.forEach((row, rowIndex) => {
- const nextGroupRow = row.map((cellData) => {
- return ({
- ...cellData,
- groups,
- groupIndex,
- });
- });
-
- result[rowIndex].push(...nextGroupRow);
- });
+ getCompleteViewDataMap(options) {
+ const {
+ groups,
+ isGroupedByDate,
+ isHorizontalGrouping,
+ isVerticalGrouping,
+ intervalCount,
+ currentDate,
+ viewType,
+ startDayHour,
+ endDayHour,
+ hoursInterval,
+ } = options;
+
+ this._setVisibilityDates(options);
+ this.setHiddenInterval(startDayHour, endDayHour, hoursInterval);
+
+ const groupsList = getAllGroups(groups);
+ const cellCountInGroupRow = this.getCellCount({
+ intervalCount,
+ currentDate,
+ viewType,
+ startDayHour,
+ endDayHour,
+ hoursInterval,
+ });
+ const rowCountInGroup = this.getRowCount({
+ intervalCount,
+ currentDate,
+ viewType,
+ hoursInterval,
+ startDayHour,
+ endDayHour,
+ });
+
+ let viewDataMap: any[] = [];
+ const allDayPanelData = this._generateAllDayPanelData(options, rowCountInGroup, cellCountInGroupRow);
+ const viewCellsData = this._generateViewCellsData(options, rowCountInGroup, cellCountInGroupRow);
+
+ allDayPanelData && viewDataMap.push(allDayPanelData);
+ viewDataMap.push(...viewCellsData);
+
+ if (isHorizontalGrouping && !isGroupedByDate) {
+ viewDataMap = this._transformViewDataMapForHorizontalGrouping(viewDataMap, groupsList);
+ }
+
+ if (isVerticalGrouping) {
+ viewDataMap = this._transformViewDataMapForVerticalGrouping(viewDataMap, groupsList);
+ }
+
+ if (isGroupedByDate) {
+ viewDataMap = this._transformViewDataMapForGroupingByDate(viewDataMap, groupsList);
+ }
+
+ const completeViewDataMap = this._addKeysToCells(viewDataMap);
+
+ return completeViewDataMap;
+ }
+
+ _transformViewDataMapForHorizontalGrouping(viewDataMap, groupsList) {
+ const result = viewDataMap.map((row) => row.slice());
+
+ groupsList.slice(1).forEach((groups, index) => {
+ const groupIndex = index + 1;
+
+ viewDataMap.forEach((row, rowIndex) => {
+ const nextGroupRow = row.map((cellData) => ({
+ ...cellData,
+ groups,
+ groupIndex,
+ }));
+
+ result[rowIndex].push(...nextGroupRow);
+ });
+ });
+
+ return result;
+ }
+
+ _transformViewDataMapForVerticalGrouping(viewDataMap, groupsList) {
+ const result = viewDataMap.map((row) => row.slice());
+
+ groupsList.slice(1).forEach((groups, index) => {
+ const groupIndex = index + 1;
+
+ const nextGroupMap = viewDataMap.map((cellsRow) => {
+ const nextRow = cellsRow.map((cellData) => ({
+ ...cellData,
+ groupIndex,
+ groups,
+ }));
+
+ return nextRow;
+ });
+
+ result.push(...nextGroupMap);
+ });
+
+ return result;
+ }
+
+ _transformViewDataMapForGroupingByDate(viewDataMap, groupsList) {
+ const correctedGroupList = groupsList.slice(1);
+ const correctedGroupCount = correctedGroupList.length;
+
+ const result = viewDataMap.map((cellsRow) => {
+ const groupedByDateCellsRow = cellsRow.reduce((currentRow, cell) => {
+ const rowWithCurrentCell = [
+ ...currentRow,
+ {
+ ...cell,
+ isFirstGroupCell: true,
+ isLastGroupCell: correctedGroupCount === 0,
+ },
+ ...correctedGroupList.map((groups, index) => ({
+ ...cell,
+ groups,
+ groupIndex: index + 1,
+ isFirstGroupCell: false,
+ isLastGroupCell: index === correctedGroupCount - 1,
+ })),
+ ];
+
+ return rowWithCurrentCell;
+ }, []);
+
+ return groupedByDateCellsRow;
+ });
+
+ return result;
+ }
+
+ _addKeysToCells(viewDataMap) {
+ const totalColumnCount = viewDataMap[0].length;
+ const {
+ currentViewDataMap: result,
+ } = viewDataMap.reduce(({ allDayPanelsCount, currentViewDataMap }, row, rowIndex) => {
+ const isAllDay = row[0].allDay;
+
+ const keyBase = (rowIndex - allDayPanelsCount) * totalColumnCount;
+
+ const currentAllDayPanelsCount = isAllDay
+ ? allDayPanelsCount + 1
+ : allDayPanelsCount;
+
+ currentViewDataMap[rowIndex].forEach((cell, columnIndex) => {
+ cell.key = keyBase + columnIndex;
+ });
+
+ return { allDayPanelsCount: currentAllDayPanelsCount, currentViewDataMap };
+ }, {
+ allDayPanelsCount: 0,
+ currentViewDataMap: viewDataMap,
+ });
+
+ return result;
+ }
+
+ generateViewDataMap(completeViewDataMap, options) {
+ const {
+ rowCount,
+ startCellIndex,
+ startRowIndex,
+ cellCount,
+ isVerticalGrouping,
+ isAllDayPanelVisible,
+ } = options;
+
+ const sliceCells = (row, rowIndex, startIndex, count) => {
+ const sliceToIndex = count !== undefined
+ ? startIndex + count
+ : undefined;
+
+ return row
+ .slice(startIndex, sliceToIndex)
+ .map((cellData, columnIndex) => (
+ {
+ cellData,
+ position: {
+ rowIndex,
+ columnIndex,
+ },
+ }));
+ };
+
+ let correctedStartRowIndex = startRowIndex;
+ let allDayPanelMap = [];
+ if (this._isStandaloneAllDayPanel(isVerticalGrouping, isAllDayPanelVisible)) {
+ correctedStartRowIndex++;
+ allDayPanelMap = sliceCells(completeViewDataMap[0], 0, startCellIndex, cellCount);
+ }
+
+ const displayedRowCount = getDisplayedRowCount(rowCount, completeViewDataMap);
+
+ const dateTableMap = completeViewDataMap
+ .slice(correctedStartRowIndex, correctedStartRowIndex + displayedRowCount)
+ .map((row, rowIndex) => sliceCells(row, rowIndex, startCellIndex, cellCount));
+
+ return {
+ allDayPanelMap,
+ dateTableMap,
+ };
+ }
+
+ _isStandaloneAllDayPanel(isVerticalGrouping, isAllDayPanelVisible) {
+ return !isVerticalGrouping && isAllDayPanelVisible;
+ }
+
+ getViewDataFromMap(completeViewDataMap, viewDataMap, options) {
+ const {
+ topVirtualRowHeight,
+ bottomVirtualRowHeight,
+ leftVirtualCellWidth,
+ rightVirtualCellWidth,
+ cellCount,
+ rowCount,
+ startRowIndex,
+ startCellIndex,
+ isProvideVirtualCellsWidth,
+ isGroupedAllDayPanel,
+ isVerticalGrouping,
+ isAllDayPanelVisible,
+ } = options;
+ const {
+ allDayPanelMap,
+ dateTableMap,
+ } = viewDataMap;
+
+ const {
+ groupedData,
+ } = dateTableMap.reduce(({ previousGroupIndex, groupedData }, cellsRow) => {
+ const cellDataRow = cellsRow.map(({ cellData }) => cellData);
+
+ const firstCell = cellDataRow[0];
+ const isAllDayRow = firstCell.allDay;
+ const currentGroupIndex = firstCell.groupIndex;
+
+ if (currentGroupIndex !== previousGroupIndex) {
+ groupedData.push({
+ dateTable: [],
+ isGroupedAllDayPanel: getIsGroupedAllDayPanel(!!isAllDayRow, isVerticalGrouping),
+ groupIndex: currentGroupIndex,
+ key: getKeyByGroup(currentGroupIndex, isVerticalGrouping),
});
-
- return result;
- }
-
- _transformViewDataMapForVerticalGrouping(viewDataMap, groupsList) {
- const result = viewDataMap.map(row => row.slice());
-
- groupsList.slice(1).forEach((groups, index) => {
- const groupIndex = index + 1;
-
- const nextGroupMap = viewDataMap.map((cellsRow) => {
- const nextRow = cellsRow.map((cellData) => {
- return ({
- ...cellData,
- groupIndex,
- groups,
- });
- });
-
- return nextRow;
- });
-
- result.push(...nextGroupMap);
+ }
+
+ if (isAllDayRow) {
+ groupedData[groupedData.length - 1].allDayPanel = cellDataRow;
+ } else {
+ groupedData[groupedData.length - 1].dateTable.push({
+ cells: cellDataRow,
+ key: cellDataRow[0].key - startCellIndex,
});
+ }
- return result;
- }
-
- _transformViewDataMapForGroupingByDate(viewDataMap, groupsList) {
- const correctedGroupList = groupsList.slice(1);
- const correctedGroupCount = correctedGroupList.length;
-
- const result = viewDataMap.map((cellsRow) => {
- const groupedByDateCellsRow = cellsRow.reduce((currentRow, cell) => {
- const rowWithCurrentCell = [
- ...currentRow,
- {
- ...cell,
- isFirstGroupCell: true,
- isLastGroupCell: correctedGroupCount === 0,
- },
- ...correctedGroupList.map((groups, index) => ({
- ...cell,
- groups,
- groupIndex: index + 1,
- isFirstGroupCell: false,
- isLastGroupCell: index === correctedGroupCount - 1,
- })),
- ];
-
- return rowWithCurrentCell;
- }, []);
-
- return groupedByDateCellsRow;
- });
+ return {
+ groupedData,
+ previousGroupIndex: currentGroupIndex,
+ };
+ }, { previousGroupIndex: -1, groupedData: [] });
- return result;
+ if (this._isStandaloneAllDayPanel(isVerticalGrouping, isAllDayPanelVisible)) {
+ groupedData[0].allDayPanel = allDayPanelMap.map(({ cellData }) => cellData);
}
- _addKeysToCells(viewDataMap) {
- const totalColumnCount = viewDataMap[0].length;
- const {
- currentViewDataMap: result,
- } = viewDataMap.reduce(({ allDayPanelsCount, currentViewDataMap }, row, rowIndex) => {
- const isAllDay = row[0].allDay;
-
- const keyBase = (rowIndex - allDayPanelsCount) * totalColumnCount;
+ const totalCellCount = getTotalCellCountByCompleteData(completeViewDataMap);
+ const totalRowCount = getTotalRowCountByCompleteData(completeViewDataMap);
+ const displayedCellCount = getDisplayedCellCount(cellCount, completeViewDataMap);
+ const displayedRowCount = getDisplayedRowCount(rowCount, completeViewDataMap);
- const currentAllDayPanelsCount = isAllDay
- ? allDayPanelsCount + 1
- : allDayPanelsCount;
+ return {
+ groupedData,
+ topVirtualRowHeight,
+ bottomVirtualRowHeight,
+ leftVirtualCellWidth: isProvideVirtualCellsWidth ? leftVirtualCellWidth : undefined,
+ rightVirtualCellWidth: isProvideVirtualCellsWidth ? rightVirtualCellWidth : undefined,
+ isGroupedAllDayPanel,
+ leftVirtualCellCount: startCellIndex,
+ rightVirtualCellCount: cellCount === undefined ? 0 : totalCellCount - startCellIndex - displayedCellCount,
+ topVirtualRowCount: startRowIndex,
+ bottomVirtualRowCount: totalRowCount - startRowIndex - displayedRowCount,
+ };
+ }
- currentViewDataMap[rowIndex].forEach((cell, columnIndex) => {
- cell.key = keyBase + columnIndex;
- });
+ _generateViewCellsData(options, rowCount, cellCountInGroupRow) {
+ const viewCellsData: any[] = [];
- return { allDayPanelsCount: currentAllDayPanelsCount, currentViewDataMap };
- }, {
- allDayPanelsCount: 0,
- currentViewDataMap: viewDataMap,
- });
-
- return result;
+ for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
+ viewCellsData.push(this._generateCellsRow(options, false, rowIndex, rowCount, cellCountInGroupRow));
}
- generateViewDataMap(completeViewDataMap, options) {
- const {
- rowCount,
- startCellIndex,
- startRowIndex,
- cellCount,
- isVerticalGrouping,
- isAllDayPanelVisible,
- } = options;
-
- const sliceCells = (row, rowIndex, startIndex, count) => {
- const sliceToIndex = count !== undefined
- ? startIndex + count
- : undefined;
-
- return row
- .slice(startIndex, sliceToIndex)
- .map((cellData, columnIndex) => (
- {
- cellData,
- position: {
- rowIndex,
- columnIndex
- }
- })
- );
-
- };
-
- let correctedStartRowIndex = startRowIndex;
- let allDayPanelMap = [];
- if(this._isStandaloneAllDayPanel(isVerticalGrouping, isAllDayPanelVisible)) {
- correctedStartRowIndex++;
- allDayPanelMap = sliceCells(completeViewDataMap[0], 0, startCellIndex, cellCount);
- }
+ return viewCellsData;
+ }
- const displayedRowCount = getDisplayedRowCount(rowCount, completeViewDataMap);
-
- const dateTableMap = completeViewDataMap
- .slice(correctedStartRowIndex, correctedStartRowIndex + displayedRowCount)
- .map((row, rowIndex) => sliceCells(row, rowIndex, startCellIndex, cellCount));
-
- return {
- allDayPanelMap,
- dateTableMap
- };
+ _generateAllDayPanelData(options, rowCount, columnCount) {
+ if (!options.isAllDayPanelVisible) {
+ return null;
}
- _isStandaloneAllDayPanel(isVerticalGrouping, isAllDayPanelVisible) {
- return !isVerticalGrouping && isAllDayPanelVisible;
- }
+ return this._generateCellsRow(options, true, 0, rowCount, columnCount);
+ }
- getViewDataFromMap(completeViewDataMap, viewDataMap, options) {
- const {
- topVirtualRowHeight,
- bottomVirtualRowHeight,
- leftVirtualCellWidth,
- rightVirtualCellWidth,
- cellCount,
- rowCount,
- startRowIndex,
- startCellIndex,
- isProvideVirtualCellsWidth,
- isGroupedAllDayPanel,
- isVerticalGrouping,
- isAllDayPanelVisible,
- } = options;
- const {
- allDayPanelMap,
- dateTableMap
- } = viewDataMap;
-
- const {
- groupedData,
- } = dateTableMap.reduce(({ previousGroupIndex, groupedData }, cellsRow) => {
- const cellDataRow = cellsRow.map(({ cellData }) => cellData);
-
- const firstCell = cellDataRow[0];
- const isAllDayRow = firstCell.allDay;
- const currentGroupIndex = firstCell.groupIndex;
-
- if(currentGroupIndex !== previousGroupIndex) {
- groupedData.push({
- dateTable: [],
- isGroupedAllDayPanel: getIsGroupedAllDayPanel(!!isAllDayRow, isVerticalGrouping),
- groupIndex: currentGroupIndex,
- key: getKeyByGroup(currentGroupIndex, isVerticalGrouping),
- });
- }
-
- if(isAllDayRow) {
- groupedData[groupedData.length - 1].allDayPanel = cellDataRow;
- } else {
- groupedData[groupedData.length - 1].dateTable.push({
- cells: cellDataRow,
- key: cellDataRow[0].key - startCellIndex,
- });
- }
-
- return {
- groupedData,
- previousGroupIndex: currentGroupIndex,
- };
- }, { previousGroupIndex: -1, groupedData: [] });
-
- if(this._isStandaloneAllDayPanel(isVerticalGrouping, isAllDayPanelVisible)) {
- groupedData[0].allDayPanel = allDayPanelMap.map(({ cellData }) => cellData);
- }
+ _generateCellsRow(options, allDay, rowIndex, rowCount, columnCount) {
+ const cellsRow: any[] = [];
- const totalCellCount = getTotalCellCountByCompleteData(completeViewDataMap);
- const totalRowCount = getTotalRowCountByCompleteData(completeViewDataMap);
- const displayedCellCount = getDisplayedCellCount(cellCount, completeViewDataMap);
- const displayedRowCount = getDisplayedRowCount(rowCount, completeViewDataMap);
-
- return {
- groupedData,
- topVirtualRowHeight,
- bottomVirtualRowHeight,
- leftVirtualCellWidth: isProvideVirtualCellsWidth ? leftVirtualCellWidth : undefined,
- rightVirtualCellWidth: isProvideVirtualCellsWidth ? rightVirtualCellWidth : undefined,
- isGroupedAllDayPanel,
- leftVirtualCellCount: startCellIndex,
- rightVirtualCellCount: cellCount === undefined ? 0 : totalCellCount - startCellIndex - displayedCellCount,
- topVirtualRowCount: startRowIndex,
- bottomVirtualRowCount: totalRowCount - startRowIndex - displayedRowCount,
- };
- }
+ for (let columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
+ const cellDataValue: any = this.getCellData(rowIndex, columnIndex, options, allDay);
- _generateViewCellsData(options, rowCount, cellCountInGroupRow) {
- const viewCellsData = [];
+ cellDataValue.index = rowIndex * columnCount + columnIndex;
- for(let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
- viewCellsData.push(this._generateCellsRow(
- options, false, rowIndex, rowCount, cellCountInGroupRow,
- ));
- }
+ cellDataValue.isFirstGroupCell = this._isFirstGroupCell(rowIndex, columnIndex, options, rowCount, columnCount);
+ cellDataValue.isLastGroupCell = this._isLastGroupCell(rowIndex, columnIndex, options, rowCount, columnCount);
- return viewCellsData;
+ cellsRow.push(cellDataValue);
}
- _generateAllDayPanelData(options, rowCount, columnCount) {
- if(!options.isAllDayPanelVisible) {
- return null;
- }
-
- return this._generateCellsRow(options, true, 0, rowCount, columnCount);
- }
+ return cellsRow;
+ }
- _generateCellsRow(options, allDay, rowIndex, rowCount, columnCount) {
- const cellsRow = [];
+ getCellData(rowIndex, columnIndex, options, allDay) {
+ return allDay
+ ? this.prepareAllDayCellData(options, rowIndex, columnIndex)
+ : this.prepareCellData(options, rowIndex, columnIndex);
+ }
- for(let columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
- const cellDataValue = this.getCellData(rowIndex, columnIndex, options, allDay);
+ prepareCellData(options, rowIndex, columnIndex) {
+ const {
+ groups,
+ startDayHour,
+ endDayHour,
+ interval,
+ hoursInterval,
+ } = options;
- cellDataValue.index = rowIndex * columnCount + columnIndex;
-
- cellDataValue.isFirstGroupCell = this._isFirstGroupCell(
- rowIndex, columnIndex, options, rowCount, columnCount,
- );
- cellDataValue.isLastGroupCell = this._isLastGroupCell(
- rowIndex, columnIndex, options, rowCount, columnCount,
- );
-
- cellsRow.push(cellDataValue);
- }
+ const groupsList = getAllGroups(groups);
- return cellsRow;
- }
+ const startDate = this.getDateByCellIndices(
+ options,
+ rowIndex,
+ columnIndex,
+ this.getCellCountInDay(startDayHour, endDayHour, hoursInterval),
+ );
+ const endDate = this.calculateEndDate(startDate, interval, endDayHour);
- getCellData(rowIndex, columnIndex, options, allDay) {
- return allDay
- ? this.prepareAllDayCellData(options, rowIndex, columnIndex)
- : this.prepareCellData(options, rowIndex, columnIndex);
- }
+ const data: any = {
+ startDate,
+ endDate,
+ allDay: this.tableAllDay,
+ groupIndex: 0,
+ };
- prepareCellData(options, rowIndex, columnIndex) {
- const {
- groups,
- startDayHour,
- endDayHour,
- interval,
- hoursInterval,
- } = options;
-
- const groupsList = getAllGroups(groups);
-
- const startDate = this.getDateByCellIndices(
- options,
- rowIndex,
- columnIndex,
- this.getCellCountInDay(startDayHour, endDayHour, hoursInterval),
- );
- const endDate = this.calculateEndDate(startDate, interval, endDayHour);
-
- const data = {
- startDate: startDate,
- endDate: endDate,
- allDay: this.tableAllDay,
- groupIndex: 0,
- };
-
- if(groupsList.length > 0) {
- data.groups = groupsList[0];
- }
+ if (groupsList.length > 0) {
+ // eslint-disable-next-line prefer-destructuring
+ data.groups = groupsList[0];
+ }
+
+ return data;
+ }
+
+ prepareAllDayCellData(options, rowIndex, columnIndex) {
+ const data = this.prepareCellData(options, rowIndex, columnIndex);
+ const startDate = dateUtils.trimTime(data.startDate);
+
+ return {
+ ...data,
+ startDate,
+ endDate: startDate,
+ allDay: true,
+ };
+ }
+
+ getDateByCellIndices(options, rowIndex, columnIndex, cellCountInDay) {
+ let { startViewDate } = options;
+ const {
+ startDayHour,
+ interval,
+ firstDayOfWeek,
+ intervalCount,
+ } = options;
- return data;
- }
+ const isStartViewDateDuringDST = startViewDate.getHours() !== Math.floor(startDayHour);
- prepareAllDayCellData(options, rowIndex, columnIndex) {
- const data = this.prepareCellData(options, rowIndex, columnIndex);
- const startDate = dateUtils.trimTime(data.startDate);
+ if (isStartViewDateDuringDST) {
+ const dateWithCorrectHours = getStartViewDateWithoutDST(startViewDate, startDayHour);
- return {
- ...data,
- startDate,
- endDate: startDate,
- allDay: true,
- };
+ // @ts-expect-error
+ startViewDate = new Date(dateWithCorrectHours - dateUtils.dateToMilliseconds('day'));
}
- getDateByCellIndices(options, rowIndex, columnIndex, cellCountInDay) {
- let startViewDate = options.startViewDate;
- const {
- startDayHour,
- interval,
- firstDayOfWeek,
- intervalCount,
- } = options;
-
- const isStartViewDateDuringDST = startViewDate.getHours() !== Math.floor(startDayHour);
+ const columnCountBase = this.getCellCount(options);
+ const rowCountBase = this.getRowCount(options);
+ const cellIndex = this._calculateCellIndex(rowIndex, columnIndex, rowCountBase, columnCountBase);
+ const millisecondsOffset = this.getMillisecondsOffset(cellIndex, interval, cellCountInDay);
- if(isStartViewDateDuringDST) {
- const dateWithCorrectHours = getStartViewDateWithoutDST(startViewDate, startDayHour);
-
- startViewDate = new Date(dateWithCorrectHours - dateUtils.dateToMilliseconds('day'));
+ const offsetByCount = this.isWorkView
+ ? this.getTimeOffsetByColumnIndex(
+ columnIndex,
+ this.getFirstDayOfWeek(firstDayOfWeek),
+ columnCountBase,
+ intervalCount,
+ ) : 0;
+
+ const startViewDateTime = startViewDate.getTime();
+ const currentDate = new Date(startViewDateTime + millisecondsOffset + offsetByCount);
+
+ const timeZoneDifference = isStartViewDateDuringDST
+ ? 0
+ : dateUtils.getTimezonesDifference(startViewDate, currentDate);
+
+ currentDate.setTime(currentDate.getTime() + timeZoneDifference);
+
+ return currentDate;
+ }
+
+ getMillisecondsOffset(cellIndex, interval, cellCountInDay) {
+ const dayIndex = Math.floor(cellIndex / cellCountInDay);
+ const realHiddenInterval = dayIndex * this.hiddenInterval;
+
+ return interval * cellIndex + realHiddenInterval;
+ }
+
+ getTimeOffsetByColumnIndex(columnIndex, firstDayOfWeek, columnCount, intervalCount) {
+ const firstDayOfWeekDiff = Math.max(0, firstDayOfWeek - 1);
+ const columnsInWeek = columnCount / intervalCount;
+ const weekendCount = Math.floor((columnIndex + firstDayOfWeekDiff) / columnsInWeek);
+
+ return DAY_MS * weekendCount * 2;
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ calculateEndDate(startDate, interval, endDayHour?: any) {
+ const result = new Date(startDate);
+ result.setMilliseconds(result.getMilliseconds() + Math.round(interval));
+
+ return result;
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ _calculateCellIndex(rowIndex, columnIndex, rowCount, columnCountBase) {
+ return (calculateCellIndex as any)(rowIndex, columnIndex, rowCount);
+ }
+
+ generateGroupedDataMap(viewDataMap) {
+ const {
+ allDayPanelMap,
+ dateTableMap,
+ } = viewDataMap;
+
+ const { previousGroupedDataMap: dateTableGroupedMap } = dateTableMap.reduce((previousOptions, cellsRow) => {
+ const {
+ previousGroupedDataMap, previousRowIndex, previousGroupIndex,
+ } = previousOptions;
+ const { groupIndex: currentGroupIndex } = cellsRow[0].cellData;
+ const currentRowIndex = currentGroupIndex === previousGroupIndex
+ ? previousRowIndex + 1
+ : 0;
+
+ cellsRow.forEach((cell) => {
+ const { groupIndex } = cell.cellData;
+
+ if (!previousGroupedDataMap[groupIndex]) {
+ previousGroupedDataMap[groupIndex] = [];
+ }
+ if (!previousGroupedDataMap[groupIndex][currentRowIndex]) {
+ previousGroupedDataMap[groupIndex][currentRowIndex] = [];
}
- const columnCountBase = this.getCellCount(options);
- const rowCountBase = this.getRowCount(options);
- const cellIndex = this._calculateCellIndex(rowIndex, columnIndex, rowCountBase, columnCountBase);
- const millisecondsOffset = this.getMillisecondsOffset(cellIndex, interval, cellCountInDay);
+ previousGroupedDataMap[groupIndex][currentRowIndex].push(cell);
+ });
- const offsetByCount = this.isWorkView
- ? this.getTimeOffsetByColumnIndex(
- columnIndex,
- this.getFirstDayOfWeek(firstDayOfWeek),
- columnCountBase,
- intervalCount,
- ) : 0;
+ return {
+ previousGroupedDataMap,
+ previousRowIndex: currentRowIndex,
+ previousGroupIndex: currentGroupIndex,
+ };
+ }, {
+ previousGroupedDataMap: [],
+ previousRowIndex: -1,
+ previousGroupIndex: -1,
+ });
- const startViewDateTime = startViewDate.getTime();
- const currentDate = new Date(startViewDateTime + millisecondsOffset + offsetByCount);
+ const allDayPanelGroupedMap: any = [];
+ allDayPanelMap?.forEach((cell) => {
+ const { groupIndex } = cell.cellData;
- const timeZoneDifference = isStartViewDateDuringDST
- ? 0
- : dateUtils.getTimezonesDifference(startViewDate, currentDate);
+ if (!allDayPanelGroupedMap[groupIndex]) {
+ allDayPanelGroupedMap[groupIndex] = [];
+ }
- currentDate.setTime(currentDate.getTime() + timeZoneDifference);
+ allDayPanelGroupedMap[groupIndex].push(cell);
+ });
- return currentDate;
- }
+ return {
+ allDayPanelGroupedMap,
+ dateTableGroupedMap,
+ };
+ }
- getMillisecondsOffset(cellIndex, interval, cellCountInDay) {
- const dayIndex = Math.floor(cellIndex / cellCountInDay);
- const realHiddenInterval = dayIndex * this.hiddenInterval;
+ _isFirstGroupCell(rowIndex, columnIndex, options, rowCount, columnCount) {
+ const {
+ groupOrientation,
+ groups,
+ isGroupedByDate,
+ } = options;
- return interval * cellIndex + realHiddenInterval;
- }
+ const groupCount = getGroupCount(groups);
- getTimeOffsetByColumnIndex(columnIndex, firstDayOfWeek, columnCount, intervalCount) {
- const firstDayOfWeekDiff = Math.max(0, firstDayOfWeek - 1);
- const columnsInWeek = columnCount / intervalCount;
- const weekendCount = Math.floor((columnIndex + firstDayOfWeekDiff) / columnsInWeek);
-
- return DAY_MS * weekendCount * 2;
+ if (isGroupedByDate) {
+ return columnIndex % groupCount === 0;
}
- calculateEndDate(startDate, interval, endDayHour) {
- const result = new Date(startDate);
- result.setMilliseconds(result.getMilliseconds() + Math.round(interval));
-
- return result;
+ if (groupOrientation === HORIZONTAL_GROUP_ORIENTATION) {
+ return columnIndex % columnCount === 0;
}
- _calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount) {
- return calculateCellIndex(rowIndex, columnIndex, rowCount);
- }
+ return rowIndex % rowCount === 0;
+ }
- generateGroupedDataMap(viewDataMap) {
- const {
- allDayPanelMap,
- dateTableMap
- } = viewDataMap;
-
- const { previousGroupedDataMap: dateTableGroupedMap } = dateTableMap.reduce((previousOptions, cellsRow) => {
- const {
- previousGroupedDataMap, previousRowIndex, previousGroupIndex,
- } = previousOptions;
- const { groupIndex: currentGroupIndex } = cellsRow[0].cellData;
- const currentRowIndex = currentGroupIndex === previousGroupIndex
- ? previousRowIndex + 1
- : 0;
-
- cellsRow.forEach((cell) => {
- const { groupIndex } = cell.cellData;
-
- if(!previousGroupedDataMap[groupIndex]) {
- previousGroupedDataMap[groupIndex] = [];
- }
- if(!previousGroupedDataMap[groupIndex][currentRowIndex]) {
- previousGroupedDataMap[groupIndex][currentRowIndex] = [];
- }
-
- previousGroupedDataMap[groupIndex][currentRowIndex].push(cell);
- });
-
- return {
- previousGroupedDataMap,
- previousRowIndex: currentRowIndex,
- previousGroupIndex: currentGroupIndex,
- };
- }, {
- previousGroupedDataMap: [],
- previousRowIndex: -1,
- previousGroupIndex: -1,
- });
-
- const allDayPanelGroupedMap = [];
- allDayPanelMap?.forEach((cell) => {
-
- const { groupIndex } = cell.cellData;
+ _isLastGroupCell(rowIndex, columnIndex, options, rowCount, columnCount) {
+ const {
+ groupOrientation,
+ groups,
+ isGroupedByDate,
+ } = options;
- if(!allDayPanelGroupedMap[groupIndex]) {
- allDayPanelGroupedMap[groupIndex] = [];
- }
+ const groupCount = getGroupCount(groups);
- allDayPanelGroupedMap[groupIndex].push(cell);
- });
-
- return {
- allDayPanelGroupedMap,
- dateTableGroupedMap
- };
+ if (isGroupedByDate) {
+ return (columnIndex + 1) % groupCount === 0;
}
- _isFirstGroupCell(rowIndex, columnIndex, options, rowCount, columnCount) {
- const {
- groupOrientation,
- groups,
- isGroupedByDate,
- } = options;
-
- const groupCount = getGroupCount(groups);
-
- if(isGroupedByDate) {
- return columnIndex % groupCount === 0;
- }
-
- if(groupOrientation === HORIZONTAL_GROUP_ORIENTATION) {
- return columnIndex % columnCount === 0;
- }
-
- return rowIndex % rowCount === 0;
+ if (groupOrientation === HORIZONTAL_GROUP_ORIENTATION) {
+ return (columnIndex + 1) % columnCount === 0;
}
- _isLastGroupCell(rowIndex, columnIndex, options, rowCount, columnCount) {
- const {
- groupOrientation,
- groups,
- isGroupedByDate,
- } = options;
+ return (rowIndex + 1) % rowCount === 0;
+ }
- const groupCount = getGroupCount(groups);
+ markSelectedAndFocusedCells(viewDataMap, renderOptions) {
+ const {
+ selectedCells,
+ focusedCell,
+ } = renderOptions;
- if(isGroupedByDate) {
- return (columnIndex + 1) % groupCount === 0;
- }
-
- if(groupOrientation === HORIZONTAL_GROUP_ORIENTATION) {
- return (columnIndex + 1) % columnCount === 0;
- }
-
- return (rowIndex + 1) % rowCount === 0;
+ if (!selectedCells && !focusedCell) {
+ return viewDataMap;
}
- markSelectedAndFocusedCells(viewDataMap, renderOptions) {
- const {
- selectedCells,
- focusedCell,
- } = renderOptions;
+ const {
+ allDayPanelMap,
+ dateTableMap,
+ } = viewDataMap;
- if(!selectedCells && !focusedCell) {
- return viewDataMap;
- }
+ const nextDateTableMap = dateTableMap.map((row) => this._markSelectedAndFocusedCellsInRow(row, selectedCells, focusedCell));
+ const nextAllDayMap = this._markSelectedAndFocusedCellsInRow(allDayPanelMap, selectedCells, focusedCell);
- const {
- allDayPanelMap,
- dateTableMap
- } = viewDataMap;
+ return {
+ allDayPanelMap: nextAllDayMap,
+ dateTableMap: nextDateTableMap,
+ };
+ }
- const nextDateTableMap = dateTableMap.map((row) => {
- return this._markSelectedAndFocusedCellsInRow(row, selectedCells, focusedCell);
- });
- const nextAllDayMap = this._markSelectedAndFocusedCellsInRow(allDayPanelMap, selectedCells, focusedCell);
+ _markSelectedAndFocusedCellsInRow(dataRow, selectedCells, focusedCell) {
+ return dataRow.map((cell) => {
+ const {
+ index,
+ groupIndex,
+ allDay,
+ startDate,
+ } = cell.cellData;
- return {
- allDayPanelMap: nextAllDayMap,
- dateTableMap: nextDateTableMap,
- };
- }
-
- _markSelectedAndFocusedCellsInRow(dataRow, selectedCells, focusedCell) {
- return dataRow.map((cell) => {
- const {
- index,
- groupIndex,
- allDay,
- startDate,
- } = cell.cellData;
-
- const indexInSelectedCells = selectedCells.findIndex(({
- index: selectedCellIndex,
- groupIndex: selectedCellGroupIndex,
- allDay: selectedCellAllDay,
- startDate: selectedCellStartDate,
- }) => (
- groupIndex === selectedCellGroupIndex
+ const indexInSelectedCells = selectedCells.findIndex(({
+ index: selectedCellIndex,
+ groupIndex: selectedCellGroupIndex,
+ allDay: selectedCellAllDay,
+ startDate: selectedCellStartDate,
+ }) => groupIndex === selectedCellGroupIndex
&& (index === selectedCellIndex
|| (selectedCellIndex === undefined
&& startDate.getTime() === selectedCellStartDate.getTime()))
- && !!allDay === !!selectedCellAllDay
- ));
+ && !!allDay === !!selectedCellAllDay);
- const isFocused = !!focusedCell
+ const isFocused = !!focusedCell
&& index === focusedCell.cellData.index
&& groupIndex === focusedCell.cellData.groupIndex
&& allDay === focusedCell.cellData.allDay;
- if(!isFocused && indexInSelectedCells === -1) {
- return cell;
- }
-
- return {
- ...cell,
- cellData: {
- ...cell.cellData,
- isSelected: indexInSelectedCells > -1,
- isFocused,
- },
- };
- });
- }
-
- getInterval(hoursInterval) {
- return hoursInterval * HOUR_MS;
- }
-
- _getIntervalDuration(intervalCount) {
- return dateUtils.dateToMilliseconds('day') * intervalCount;
- }
-
- _setVisibilityDates() {}
-
- getCellCountInDay(startDayHour, endDayHour, hoursInterval) {
- const result = calculateDayDuration(startDayHour, endDayHour) / hoursInterval;
-
- return Math.ceil(result);
- }
-
- getCellCount(options) {
- const {
- intervalCount,
- viewType,
- startDayHour,
- endDayHour,
- hoursInterval,
- } = options;
-
- const cellCountInDay = this.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
- const columnCountInDay = isHorizontalView(viewType)
- ? cellCountInDay
- : 1;
-
- return this.daysInInterval * intervalCount * columnCountInDay;
- }
-
- getRowCount(options) {
- const {
- viewType,
- startDayHour,
- endDayHour,
- hoursInterval,
- } = options;
-
- const cellCountInDay = this.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
- const rowCountInDay = !isHorizontalView(viewType)
- ? cellCountInDay
- : 1;
-
- return rowCountInDay;
- }
-
- setHiddenInterval(startDayHour, endDayHour, hoursInterval) {
- this.hiddenInterval = DAY_MS - this.getVisibleDayDuration(startDayHour, endDayHour, hoursInterval);
- }
-
- getVisibleDayDuration(startDayHour, endDayHour, hoursInterval) {
- const cellCountInDay = this.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
-
- return hoursInterval * cellCountInDay * HOUR_MS;
- }
-
- getFirstDayOfWeek(firstDayOfWeekOption) {
- return firstDayOfWeekOption;
- }
+ if (!isFocused && indexInSelectedCells === -1) {
+ return cell;
+ }
+
+ return {
+ ...cell,
+ cellData: {
+ ...cell.cellData,
+ isSelected: indexInSelectedCells > -1,
+ isFocused,
+ },
+ };
+ });
+ }
+
+ getInterval(hoursInterval) {
+ return hoursInterval * HOUR_MS;
+ }
+
+ _getIntervalDuration(intervalCount) {
+ return dateUtils.dateToMilliseconds('day') * intervalCount;
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ _setVisibilityDates(options: any) {}
+
+ getCellCountInDay(startDayHour, endDayHour, hoursInterval) {
+ const result = calculateDayDuration(startDayHour, endDayHour) / hoursInterval;
+
+ return Math.ceil(result);
+ }
+
+ getCellCount(options) {
+ const {
+ intervalCount,
+ viewType,
+ startDayHour,
+ endDayHour,
+ hoursInterval,
+ } = options;
+
+ const cellCountInDay = this.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
+ const columnCountInDay = isHorizontalView(viewType)
+ ? cellCountInDay
+ : 1;
+
+ return this.daysInInterval * intervalCount * columnCountInDay;
+ }
+
+ getRowCount(options) {
+ const {
+ viewType,
+ startDayHour,
+ endDayHour,
+ hoursInterval,
+ } = options;
+
+ const cellCountInDay = this.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
+ const rowCountInDay = !isHorizontalView(viewType)
+ ? cellCountInDay
+ : 1;
+
+ return rowCountInDay;
+ }
+
+ setHiddenInterval(startDayHour, endDayHour, hoursInterval) {
+ this.hiddenInterval = DAY_MS - this.getVisibleDayDuration(startDayHour, endDayHour, hoursInterval);
+ }
+
+ getVisibleDayDuration(startDayHour, endDayHour, hoursInterval) {
+ const cellCountInDay = this.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
+
+ return hoursInterval * cellCountInDay * HOUR_MS;
+ }
+
+ getFirstDayOfWeek(firstDayOfWeekOption) {
+ return firstDayOfWeekOption;
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_day.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_day.ts
index df12ebfd7eb7..5b0632bbb076 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_day.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_day.ts
@@ -1,13 +1,14 @@
-import { calculateStartViewDate } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/day';
-import { ViewDataGenerator } from './view_data_generator';
+import { calculateStartViewDate } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/day';
+
+import { ViewDataGenerator } from './m_view_data_generator';
export class ViewDataGeneratorDay extends ViewDataGenerator {
- _calculateStartViewDate(options) {
- return calculateStartViewDate(
- options.currentDate,
- options.startDayHour,
- options.startDate,
- this._getIntervalDuration(options.intervalCount),
- );
- }
+ _calculateStartViewDate(options) {
+ return calculateStartViewDate(
+ options.currentDate,
+ options.startDayHour,
+ options.startDate,
+ this._getIntervalDuration(options.intervalCount),
+ );
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_month.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_month.ts
index 1614c430526d..dd4c385c0f3d 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_month.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_month.ts
@@ -1,109 +1,116 @@
-import { getToday, setOptionHour } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
-import { ViewDataGenerator } from './view_data_generator';
-import dateUtils from '../../../../core/utils/date';
+import dateUtils from '@js/core/utils/date';
+import dateLocalization from '@js/localization/date';
+import { getToday, setOptionHour } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
import {
- calculateCellIndex,
- calculateStartViewDate,
- getCellText,
- isFirstCellInMonthWithIntervalCount,
- getViewStartByOptions,
-} from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/month';
-import { calculateAlignedWeeksBetweenDates } from './utils';
-import dateLocalization from '../../../../localization/date';
+ calculateCellIndex,
+ calculateStartViewDate,
+ getCellText,
+ getViewStartByOptions,
+ isFirstCellInMonthWithIntervalCount,
+} from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/month';
+
+// eslint-disable-next-line import/no-cycle
+import { calculateAlignedWeeksBetweenDates } from './m_utils';
+import { ViewDataGenerator } from './m_view_data_generator';
const DAY_IN_MILLISECONDS = dateUtils.dateToMilliseconds('day');
const DAYS_IN_WEEK = 7;
export class ViewDataGeneratorMonth extends ViewDataGenerator {
- get tableAllDay() { return undefined; }
-
- getCellData(rowIndex, columnIndex, options, allDay) {
- const data = super.getCellData(rowIndex, columnIndex, options, false);
-
- const startDate = data.startDate;
- const {
- indicatorTime,
- timeZoneCalculator,
- intervalCount,
- } = options;
-
- data.today = this.isCurrentDate(startDate, indicatorTime, timeZoneCalculator);
- data.otherMonth = this.isOtherMonth(startDate, this._minVisibleDate, this._maxVisibleDate);
- data.firstDayOfMonth = isFirstCellInMonthWithIntervalCount(startDate, intervalCount);
- data.text = getCellText(startDate, intervalCount);
-
- return data;
- }
-
- isCurrentDate(date, indicatorTime, timeZoneCalculator) {
- return dateUtils.sameDate(date, getToday(indicatorTime, timeZoneCalculator));
- }
-
- isOtherMonth(cellDate, minDate, maxDate) {
- return !dateUtils.dateInRange(cellDate, minDate, maxDate, 'date');
- }
-
- _calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount) {
- return calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount);
- }
-
- calculateEndDate(startDate, interval, endDayHour) {
- return setOptionHour(startDate, endDayHour);
- }
-
- getInterval() {
- return DAY_IN_MILLISECONDS;
- }
-
- _calculateStartViewDate(options) {
- return calculateStartViewDate(
- options.currentDate,
- options.startDayHour,
- options.startDate,
- options.intervalCount,
- this.getFirstDayOfWeek(options.firstDayOfWeek),
- );
- }
-
- _setVisibilityDates(options) {
- const {
- intervalCount,
- startDate,
- currentDate,
- } = options;
-
- const firstMonthDate = dateUtils.getFirstMonthDate(startDate);
- const viewStart = getViewStartByOptions(startDate, currentDate, intervalCount, firstMonthDate);
-
- this._minVisibleDate = new Date(viewStart.setDate(1));
-
- const nextMonthDate = new Date(viewStart.setMonth(viewStart.getMonth() + intervalCount));
- this._maxVisibleDate = new Date(nextMonthDate.setDate(0));
- }
-
- getCellCount() {
- return DAYS_IN_WEEK;
- }
-
- getRowCount(options) {
- const startDate = new Date(options.currentDate);
- startDate.setDate(1);
-
- const endDate = new Date(startDate);
- endDate.setMonth(endDate.getMonth() + options.intervalCount);
- endDate.setDate(0);
-
- return calculateAlignedWeeksBetweenDates(
- startDate,
- endDate,
- options.firstDayOfWeek ?? dateLocalization.firstDayOfWeekIndex(),
- );
- }
-
- getCellCountInDay() {
- return 1;
- }
-
- setHiddenInterval() {
- this.hiddenInterval = 0;
- }
+ _minVisibleDate: any;
+
+ _maxVisibleDate: any;
+
+ tableAllDay: any = undefined;
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ getCellData(rowIndex, columnIndex, options, allDay) {
+ const data = super.getCellData(rowIndex, columnIndex, options, false);
+
+ const { startDate } = data;
+ const {
+ indicatorTime,
+ timeZoneCalculator,
+ intervalCount,
+ } = options;
+
+ data.today = this.isCurrentDate(startDate, indicatorTime, timeZoneCalculator);
+ data.otherMonth = this.isOtherMonth(startDate, this._minVisibleDate, this._maxVisibleDate);
+ data.firstDayOfMonth = isFirstCellInMonthWithIntervalCount(startDate, intervalCount);
+ data.text = getCellText(startDate, intervalCount);
+
+ return data;
+ }
+
+ isCurrentDate(date, indicatorTime, timeZoneCalculator) {
+ return dateUtils.sameDate(date, getToday(indicatorTime, timeZoneCalculator));
+ }
+
+ isOtherMonth(cellDate, minDate, maxDate) {
+ return !dateUtils.dateInRange(cellDate, minDate, maxDate, 'date');
+ }
+
+ _calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount) {
+ return calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount);
+ }
+
+ calculateEndDate(startDate, interval, endDayHour) {
+ return setOptionHour(startDate, endDayHour);
+ }
+
+ getInterval() {
+ return DAY_IN_MILLISECONDS;
+ }
+
+ _calculateStartViewDate(options) {
+ return calculateStartViewDate(
+ options.currentDate,
+ options.startDayHour,
+ options.startDate,
+ options.intervalCount,
+ this.getFirstDayOfWeek(options.firstDayOfWeek),
+ );
+ }
+
+ _setVisibilityDates(options) {
+ const {
+ intervalCount,
+ startDate,
+ currentDate,
+ } = options;
+
+ const firstMonthDate: any = dateUtils.getFirstMonthDate(startDate);
+ const viewStart = getViewStartByOptions(startDate, currentDate, intervalCount, firstMonthDate);
+
+ this._minVisibleDate = new Date(viewStart.setDate(1));
+
+ const nextMonthDate = new Date(viewStart.setMonth(viewStart.getMonth() + intervalCount));
+ this._maxVisibleDate = new Date(nextMonthDate.setDate(0));
+ }
+
+ getCellCount() {
+ return DAYS_IN_WEEK;
+ }
+
+ getRowCount(options) {
+ const startDate = new Date(options.currentDate);
+ startDate.setDate(1);
+
+ const endDate = new Date(startDate);
+ endDate.setMonth(endDate.getMonth() + options.intervalCount);
+ endDate.setDate(0);
+
+ return calculateAlignedWeeksBetweenDates(
+ startDate,
+ endDate,
+ options.firstDayOfWeek ?? dateLocalization.firstDayOfWeekIndex(),
+ );
+ }
+
+ getCellCountInDay() {
+ return 1;
+ }
+
+ setHiddenInterval() {
+ this.hiddenInterval = 0;
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_timeline_month.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_timeline_month.ts
index f7ab0c5dd0d4..da802bc17d0f 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_timeline_month.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_timeline_month.ts
@@ -1,44 +1,45 @@
-import { ViewDataGenerator } from './view_data_generator';
-import { calculateCellIndex } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/month';
-import { calculateStartViewDate } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/timeline_month';
-import { setOptionHour } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
-import dateUtils from '../../../../core/utils/date';
+import dateUtils from '@js/core/utils/date';
+import { setOptionHour } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
+import { calculateCellIndex } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/month';
+import { calculateStartViewDate } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/timeline_month';
+
+import { ViewDataGenerator } from './m_view_data_generator';
const DAY_IN_MILLISECONDS = dateUtils.dateToMilliseconds('day');
export class ViewDataGeneratorTimelineMonth extends ViewDataGenerator {
- _calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount) {
- return calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount);
- }
-
- calculateEndDate(startDate, interval, endDayHour) {
- return setOptionHour(startDate, endDayHour);
- }
-
- getInterval() {
- return DAY_IN_MILLISECONDS;
+ _calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount) {
+ return calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount);
+ }
+
+ calculateEndDate(startDate, interval, endDayHour) {
+ return setOptionHour(startDate, endDayHour);
+ }
+
+ getInterval() {
+ return DAY_IN_MILLISECONDS;
+ }
+
+ _calculateStartViewDate(options: any) {
+ return calculateStartViewDate(
+ options.currentDate,
+ options.startDayHour,
+ options.startDate,
+ options.intervalCount,
+ );
+ }
+
+ getCellCount(options) {
+ const { intervalCount, currentDate } = options;
+ let cellCount = 0;
+ for (let i = 1; i <= intervalCount; i++) {
+ cellCount += new Date(currentDate.getFullYear(), currentDate.getMonth() + i, 0).getDate();
}
- _calculateStartViewDate(options) {
- return calculateStartViewDate(
- options.currentDate,
- options.startDayHour,
- options.startDate,
- options.intervalCount,
- );
- }
-
- getCellCount(options) {
- const { intervalCount, currentDate } = options;
- let cellCount = 0;
- for(let i = 1; i <= intervalCount; i++) {
- cellCount += new Date(currentDate.getFullYear(), currentDate.getMonth() + i, 0).getDate();
- }
+ return cellCount;
+ }
- return cellCount;
- }
-
- setHiddenInterval() {
- this.hiddenInterval = 0;
- }
+ setHiddenInterval() {
+ this.hiddenInterval = 0;
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_week.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_week.ts
index b48af01a6044..977a25387f44 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_week.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_week.ts
@@ -1,20 +1,21 @@
-import { calculateStartViewDate, getIntervalDuration } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/week';
-import { ViewDataGenerator } from './view_data_generator';
+import { calculateStartViewDate, getIntervalDuration } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/week';
+
+import { ViewDataGenerator } from './m_view_data_generator';
export class ViewDataGeneratorWeek extends ViewDataGenerator {
- get daysInInterval() { return 7; }
+ readonly daysInInterval: number = 7;
- _getIntervalDuration(intervalCount) {
- return getIntervalDuration(intervalCount);
- }
+ _getIntervalDuration(intervalCount) {
+ return getIntervalDuration(intervalCount);
+ }
- _calculateStartViewDate(options) {
- return calculateStartViewDate(
- options.currentDate,
- options.startDayHour,
- options.startDate,
- this._getIntervalDuration(options.intervalCount),
- this.getFirstDayOfWeek(options.firstDayOfWeek),
- );
- }
+ _calculateStartViewDate(options) {
+ return calculateStartViewDate(
+ options.currentDate,
+ options.startDayHour,
+ options.startDate,
+ this._getIntervalDuration(options.intervalCount),
+ this.getFirstDayOfWeek(options.firstDayOfWeek),
+ );
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_work_week.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_work_week.ts
index ef31f3575502..c18b5ebf06eb 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_work_week.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_generator_work_week.ts
@@ -1,29 +1,30 @@
import {
- calculateStartViewDate,
- isDataOnWeekend,
-} from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/work_week';
-import { ViewDataGeneratorWeek } from './view_data_generator_week';
+ calculateStartViewDate,
+ isDataOnWeekend,
+} from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/work_week';
+
+import { ViewDataGeneratorWeek } from './m_view_data_generator_week';
export class ViewDataGeneratorWorkWeek extends ViewDataGeneratorWeek {
- get daysInInterval() { return 5; }
+ readonly daysInInterval = 5;
- get isWorkView() { return true; }
+ readonly isWorkView: boolean = true;
- isSkippedDate(date) {
- return isDataOnWeekend(date);
- }
+ isSkippedDate(date) {
+ return isDataOnWeekend(date);
+ }
- _calculateStartViewDate(options) {
- return calculateStartViewDate(
- options.currentDate,
- options.startDayHour,
- options.startDate,
- this._getIntervalDuration(options.intervalCount),
- this.getFirstDayOfWeek(options.firstDayOfWeek),
- );
- }
+ _calculateStartViewDate(options) {
+ return calculateStartViewDate(
+ options.currentDate,
+ options.startDayHour,
+ options.startDate,
+ this._getIntervalDuration(options.intervalCount),
+ this.getFirstDayOfWeek(options.firstDayOfWeek),
+ );
+ }
- getFirstDayOfWeek(firstDayOfWeekOption) {
- return firstDayOfWeekOption || 0;
- }
+ getFirstDayOfWeek(firstDayOfWeekOption) {
+ return firstDayOfWeekOption || 0;
+ }
}
diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_provider.ts b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_provider.ts
index 8996237c2450..c035935673b9 100644
--- a/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_provider.ts
+++ b/packages/devextreme/js/__internal/scheduler/workspaces/view_model/m_view_data_provider.ts
@@ -1,467 +1,489 @@
-import dateUtils from '../../../../core/utils/date';
-import { getGroupPanelData } from '../../../../renovation/ui/scheduler/view_model/group_panel/utils';
-import { isGroupingByDate, isHorizontalGroupingApplied, isVerticalGroupingApplied } from '../../../../renovation/ui/scheduler/workspaces/utils';
-import { calculateIsGroupedAllDayPanel } from '../../../../renovation/ui/scheduler/view_model/to_test/views/utils/base';
-import { DateHeaderDataGenerator } from './date_header_data_generator';
-import { GroupedDataMapProvider } from './grouped_data_map_provider';
-import { TimePanelDataGenerator } from './time_panel_data_generator';
-import { getViewDataGeneratorByViewType } from './utils';
-import timeZoneUtils from '../../utils.timeZone';
+import dateUtils from '@js/core/utils/date';
+import { getGroupPanelData } from '@js/renovation/ui/scheduler/view_model/group_panel/utils';
+import { calculateIsGroupedAllDayPanel } from '@js/renovation/ui/scheduler/view_model/to_test/views/utils/base';
+import { isGroupingByDate, isHorizontalGroupingApplied, isVerticalGroupingApplied } from '@js/renovation/ui/scheduler/workspaces/utils';
-export default class ViewDataProvider {
- constructor(viewType) {
- this.viewDataGenerator = getViewDataGeneratorByViewType(viewType);
- this.viewData = {};
- this.completeViewDataMap = [];
- this.completeDateHeaderMap = [];
- this.viewDataMap = {};
- this._groupedDataMapProvider = null;
- }
-
- get groupedDataMap() { return this._groupedDataMapProvider.groupedDataMap; }
-
- get hiddenInterval() { return this.viewDataGenerator.hiddenInterval; }
-
- isSkippedDate(date) { return this.viewDataGenerator.isSkippedDate(date); }
-
- update(options, isGenerateNewViewData) {
- this.viewDataGenerator = getViewDataGeneratorByViewType(options.viewType);
-
- const viewDataGenerator = this.viewDataGenerator;
- const dateHeaderDataGenerator = new DateHeaderDataGenerator(viewDataGenerator);
- const timePanelDataGenerator = new TimePanelDataGenerator(viewDataGenerator);
-
- const renderOptions = this._transformRenderOptions(options);
-
- renderOptions.interval = this.viewDataGenerator.getInterval(renderOptions.hoursInterval);
- this._options = renderOptions;
-
- if(isGenerateNewViewData) {
- this.completeViewDataMap = viewDataGenerator.getCompleteViewDataMap(renderOptions);
- this.completeDateHeaderMap = dateHeaderDataGenerator
- .getCompleteDateHeaderMap(renderOptions, this.completeViewDataMap);
- if(renderOptions.isGenerateTimePanelData) {
- this.completeTimePanelMap = timePanelDataGenerator
- .getCompleteTimePanelMap(renderOptions, this.completeViewDataMap);
- }
- }
-
- this.viewDataMap = viewDataGenerator.generateViewDataMap(this.completeViewDataMap, renderOptions);
- this.updateViewData(renderOptions);
-
-
- this._groupedDataMapProvider = new GroupedDataMapProvider(
- this.viewDataGenerator,
- this.viewDataMap,
- this.completeViewDataMap,
- {
- isVerticalGrouping: renderOptions.isVerticalGrouping,
- viewType: renderOptions.viewType,
- },
- );
-
- this.dateHeaderData = dateHeaderDataGenerator
- .generateDateHeaderData(this.completeDateHeaderMap, this.completeViewDataMap, renderOptions);
-
- if(renderOptions.isGenerateTimePanelData) {
- this.timePanelData = timePanelDataGenerator.generateTimePanelData(
- this.completeTimePanelMap,
- renderOptions,
- );
- }
- }
-
- createGroupedDataMapProvider() {
- this._groupedDataMapProvider = new GroupedDataMapProvider(
- this.viewDataGenerator,
- this.viewDataMap,
- this.completeViewDataMap,
- {
- isVerticalGrouping: this._options.isVerticalGrouping,
- viewType: this._options.viewType,
- },
- );
- }
-
- updateViewData(options) {
- const renderOptions = this._transformRenderOptions(options);
- this.viewDataMapWithSelection = this.viewDataGenerator
- .markSelectedAndFocusedCells(this.viewDataMap, renderOptions);
- this.viewData = this.viewDataGenerator
- .getViewDataFromMap(
- this.completeViewDataMap,
- this.viewDataMapWithSelection,
- renderOptions,
- );
- }
+import timeZoneUtils from '../../m_utils_time_zone';
+import { DateHeaderDataGenerator } from './m_date_header_data_generator';
+import { GroupedDataMapProvider } from './m_grouped_data_map_provider';
+import { TimePanelDataGenerator } from './m_time_panel_data_generator';
+import { getViewDataGeneratorByViewType } from './m_utils';
- _transformRenderOptions(renderOptions) {
- const {
- groups,
- groupOrientation,
- groupByDate,
- isAllDayPanelVisible,
- ...restOptions
- } = renderOptions;
-
- return {
- ...restOptions,
- startViewDate: this.viewDataGenerator._calculateStartViewDate(renderOptions),
- isVerticalGrouping: isVerticalGroupingApplied(groups, groupOrientation),
- isHorizontalGrouping: isHorizontalGroupingApplied(groups, groupOrientation),
- isGroupedByDate: isGroupingByDate(groups, groupOrientation, groupByDate),
- isGroupedAllDayPanel: calculateIsGroupedAllDayPanel(
- groups, groupOrientation, isAllDayPanelVisible,
- ),
- groups,
- groupOrientation,
- isAllDayPanelVisible,
- };
- }
+export default class ViewDataProvider {
+ viewDataGenerator: any;
- getGroupPanelData(options) {
- const renderOptions = this._transformRenderOptions(options);
- if(renderOptions.groups.length > 0) {
- const cellCount = this.getCellCount(renderOptions);
- return getGroupPanelData(
- renderOptions.groups,
- cellCount,
- renderOptions.isGroupedByDate,
- renderOptions.isGroupedByDate ? 1 : cellCount,
- );
- }
+ viewData: any;
- return undefined;
- }
+ completeViewDataMap: any[];
- getGroupStartDate(groupIndex) {
- return this._groupedDataMapProvider.getGroupStartDate(groupIndex);
- }
+ completeDateHeaderMap: any[];
- getGroupEndDate(groupIndex) {
- return this._groupedDataMapProvider.getGroupEndDate(groupIndex);
- }
+ viewDataMap: any;
- findGroupCellStartDate(groupIndex, startDate, endDate, isFindByDate = false) {
- return this._groupedDataMapProvider.findGroupCellStartDate(groupIndex, startDate, endDate, isFindByDate);
- }
+ _groupedDataMapProvider: any;
- findAllDayGroupCellStartDate(groupIndex, startDate) {
- return this._groupedDataMapProvider.findAllDayGroupCellStartDate(groupIndex, startDate);
- }
+ _options: any;
- findCellPositionInMap(cellInfo) {
- return this._groupedDataMapProvider.findCellPositionInMap(cellInfo);
- }
+ completeTimePanelMap: any;
- hasAllDayPanel() {
- const { viewData } = this.viewDataMap;
- const { allDayPanel } = viewData.groupedData[0];
+ dateHeaderData: any;
- return !viewData.isGroupedAllDayPanel && allDayPanel?.length > 0;
- }
+ timePanelData: any;
+
+ viewDataMapWithSelection: any;
+
+ constructor(viewType) {
+ this.viewDataGenerator = getViewDataGeneratorByViewType(viewType);
+ this.viewData = {};
+ this.completeViewDataMap = [];
+ this.completeDateHeaderMap = [];
+ this.viewDataMap = {};
+ this._groupedDataMapProvider = null;
+ }
+
+ get groupedDataMap() { return this._groupedDataMapProvider.groupedDataMap; }
+
+ get hiddenInterval() { return this.viewDataGenerator.hiddenInterval; }
+
+ isSkippedDate(date) { return this.viewDataGenerator.isSkippedDate(date); }
+
+ update(options, isGenerateNewViewData) {
+ this.viewDataGenerator = getViewDataGeneratorByViewType(options.viewType);
+
+ const { viewDataGenerator } = this;
+ const dateHeaderDataGenerator = new DateHeaderDataGenerator(viewDataGenerator);
+ const timePanelDataGenerator = new TimePanelDataGenerator(viewDataGenerator);
+
+ const renderOptions = this._transformRenderOptions(options);
+
+ renderOptions.interval = this.viewDataGenerator.getInterval(renderOptions.hoursInterval);
+ this._options = renderOptions;
+
+ if (isGenerateNewViewData) {
+ this.completeViewDataMap = viewDataGenerator.getCompleteViewDataMap(renderOptions);
+ this.completeDateHeaderMap = dateHeaderDataGenerator
+ .getCompleteDateHeaderMap(renderOptions, this.completeViewDataMap);
+ if (renderOptions.isGenerateTimePanelData) {
+ this.completeTimePanelMap = timePanelDataGenerator
+ .getCompleteTimePanelMap(renderOptions, this.completeViewDataMap);
+ }
+ }
+
+ this.viewDataMap = viewDataGenerator.generateViewDataMap(this.completeViewDataMap, renderOptions);
+ this.updateViewData(renderOptions);
+
+ this._groupedDataMapProvider = new GroupedDataMapProvider(
+ this.viewDataGenerator,
+ this.viewDataMap,
+ this.completeViewDataMap,
+ {
+ isVerticalGrouping: renderOptions.isVerticalGrouping,
+ viewType: renderOptions.viewType,
+ },
+ );
+
+ this.dateHeaderData = dateHeaderDataGenerator
+ .generateDateHeaderData(this.completeDateHeaderMap, this.completeViewDataMap, renderOptions);
+
+ if (renderOptions.isGenerateTimePanelData) {
+ this.timePanelData = timePanelDataGenerator.generateTimePanelData(
+ this.completeTimePanelMap,
+ renderOptions,
+ );
+ }
+ }
+
+ createGroupedDataMapProvider() {
+ this._groupedDataMapProvider = new GroupedDataMapProvider(
+ this.viewDataGenerator,
+ this.viewDataMap,
+ this.completeViewDataMap,
+ {
+ isVerticalGrouping: this._options.isVerticalGrouping,
+ viewType: this._options.viewType,
+ },
+ );
+ }
+
+ updateViewData(options) {
+ const renderOptions = this._transformRenderOptions(options);
+ this.viewDataMapWithSelection = this.viewDataGenerator
+ .markSelectedAndFocusedCells(this.viewDataMap, renderOptions);
+ this.viewData = this.viewDataGenerator
+ .getViewDataFromMap(
+ this.completeViewDataMap,
+ this.viewDataMapWithSelection,
+ renderOptions,
+ );
+ }
+
+ _transformRenderOptions(renderOptions) {
+ const {
+ groups,
+ groupOrientation,
+ groupByDate,
+ isAllDayPanelVisible,
+ ...restOptions
+ } = renderOptions;
+
+ return {
+ ...restOptions,
+ startViewDate: this.viewDataGenerator._calculateStartViewDate(renderOptions),
+ isVerticalGrouping: isVerticalGroupingApplied(groups, groupOrientation),
+ isHorizontalGrouping: isHorizontalGroupingApplied(groups, groupOrientation),
+ isGroupedByDate: isGroupingByDate(groups, groupOrientation, groupByDate),
+ isGroupedAllDayPanel: calculateIsGroupedAllDayPanel(groups, groupOrientation, isAllDayPanelVisible),
+ groups,
+ groupOrientation,
+ isAllDayPanelVisible,
+ };
+ }
+
+ getGroupPanelData(options) {
+ const renderOptions = this._transformRenderOptions(options);
+ if (renderOptions.groups.length > 0) {
+ const cellCount = this.getCellCount(renderOptions);
+ return getGroupPanelData(
+ renderOptions.groups,
+ cellCount,
+ renderOptions.isGroupedByDate,
+ renderOptions.isGroupedByDate ? 1 : cellCount,
+ );
+ }
+
+ return undefined;
+ }
+
+ getGroupStartDate(groupIndex) {
+ return this._groupedDataMapProvider.getGroupStartDate(groupIndex);
+ }
+
+ getGroupEndDate(groupIndex) {
+ return this._groupedDataMapProvider.getGroupEndDate(groupIndex);
+ }
+
+ findGroupCellStartDate(groupIndex, startDate, endDate, isFindByDate = false) {
+ return this._groupedDataMapProvider.findGroupCellStartDate(groupIndex, startDate, endDate, isFindByDate);
+ }
+
+ findAllDayGroupCellStartDate(groupIndex, startDate) {
+ return this._groupedDataMapProvider.findAllDayGroupCellStartDate(groupIndex, startDate);
+ }
+
+ findCellPositionInMap(cellInfo) {
+ return this._groupedDataMapProvider.findCellPositionInMap(cellInfo);
+ }
+
+ hasAllDayPanel() {
+ const { viewData } = this.viewDataMap;
+ const { allDayPanel } = viewData.groupedData[0];
+
+ return !viewData.isGroupedAllDayPanel && allDayPanel?.length > 0;
+ }
+
+ getCellsGroup(groupIndex) {
+ return this._groupedDataMapProvider.getCellsGroup(groupIndex);
+ }
+
+ getCompletedGroupsInfo() {
+ return this._groupedDataMapProvider.getCompletedGroupsInfo();
+ }
+
+ getGroupIndices() {
+ return this._groupedDataMapProvider.getGroupIndices();
+ }
+
+ getLastGroupCellPosition(groupIndex) {
+ return this._groupedDataMapProvider.getLastGroupCellPosition(groupIndex);
+ }
+
+ getRowCountInGroup(groupIndex) {
+ return this._groupedDataMapProvider.getRowCountInGroup(groupIndex);
+ }
+
+ getCellData(rowIndex, columnIndex, isAllDay, rtlEnabled) {
+ const row = isAllDay && !this._options.isVerticalGrouping
+ ? this.viewDataMap.allDayPanelMap
+ : this.viewDataMap.dateTableMap[rowIndex];
+
+ const actualColumnIndex = !rtlEnabled
+ ? columnIndex
+ : row.length - 1 - columnIndex;
+
+ const { cellData } = row[actualColumnIndex];
+
+ return cellData;
+ }
+
+ getCellsByGroupIndexAndAllDay(groupIndex, allDay) {
+ const rowsPerGroup = this._getRowCountWithAllDayRows();
+ const isShowAllDayPanel = this._options.isAllDayPanelVisible;
+
+ const firstRowInGroup = this._options.isVerticalGrouping
+ ? groupIndex * rowsPerGroup
+ : 0;
+ const lastRowInGroup = this._options.isVerticalGrouping
+ ? (groupIndex + 1) * rowsPerGroup - 1
+ : rowsPerGroup;
+ const correctedFirstRow = isShowAllDayPanel && !allDay
+ ? firstRowInGroup + 1
+ : firstRowInGroup;
+ const correctedLastRow = allDay ? correctedFirstRow : lastRowInGroup;
+
+ return this.completeViewDataMap
+ .slice(correctedFirstRow, correctedLastRow + 1)
+ .map((row) => row.filter(({ groupIndex: currentGroupIndex }) => groupIndex === currentGroupIndex));
+ }
+
+ getCellCountWithGroup(groupIndex, rowIndex = 0) {
+ const { dateTableGroupedMap } = this.groupedDataMap;
- getCellsGroup(groupIndex) {
- return this._groupedDataMapProvider.getCellsGroup(groupIndex);
- }
+ return dateTableGroupedMap
+ .filter((_, index) => index <= groupIndex)
+ .reduce(
+ (previous, row) => previous + row[rowIndex].length,
+ 0,
+ );
+ }
- getCompletedGroupsInfo() {
- return this._groupedDataMapProvider.getCompletedGroupsInfo();
+ hasGroupAllDayPanel(groupIndex) {
+ if (this._options.isVerticalGrouping) {
+ return !!this.groupedDataMap.dateTableGroupedMap[groupIndex]?.[0][0].cellData.allDay;
}
- getGroupIndices() {
- return this._groupedDataMapProvider.getGroupIndices();
- }
-
- getLastGroupCellPosition(groupIndex) {
- return this._groupedDataMapProvider.getLastGroupCellPosition(groupIndex);
- }
+ return this.groupedDataMap.allDayPanelGroupedMap[groupIndex]?.length > 0;
+ }
- getRowCountInGroup(groupIndex) {
- return this._groupedDataMapProvider.getRowCountInGroup(groupIndex);
- }
+ isGroupIntersectDateInterval(groupIndex, startDate, endDate) {
+ const groupStartDate = this.getGroupStartDate(groupIndex);
+ const groupEndDate = this.getGroupEndDate(groupIndex);
- getCellData(rowIndex, columnIndex, isAllDay, rtlEnabled) {
- const row = isAllDay && !this._options.isVerticalGrouping
- ? this.viewDataMap.allDayPanelMap
- : this.viewDataMap.dateTableMap[rowIndex];
+ return startDate < groupEndDate && endDate > groupStartDate;
+ }
- const actualColumnIndex = !rtlEnabled
- ? columnIndex
- : (row.length - 1 - columnIndex);
+ findGlobalCellPosition(date, groupIndex = 0, allDay = false) {
+ const { completeViewDataMap } = this;
- const { cellData } = row[actualColumnIndex];
+ const showAllDayPanel = this._options.isAllDayPanelVisible;
- return cellData;
- }
+ for (let rowIndex = 0; rowIndex < completeViewDataMap.length; rowIndex += 1) {
+ const currentRow = completeViewDataMap[rowIndex];
- getCellsByGroupIndexAndAllDay(groupIndex, allDay) {
- const rowsPerGroup = this._getRowCountWithAllDayRows();
- const isShowAllDayPanel = this._options.isAllDayPanelVisible;
-
- const firstRowInGroup = this._options.isVerticalGrouping
- ? groupIndex * rowsPerGroup
- : 0;
- const lastRowInGroup = this._options.isVerticalGrouping
- ? (groupIndex + 1) * rowsPerGroup - 1
- : rowsPerGroup;
- const correctedFirstRow = isShowAllDayPanel && !allDay
- ? firstRowInGroup + 1
- : firstRowInGroup;
- const correctedLastRow = allDay ? correctedFirstRow : lastRowInGroup;
-
- return this.completeViewDataMap
- .slice(correctedFirstRow, correctedLastRow + 1)
- .map(row => row.filter(({ groupIndex: currentGroupIndex }) => groupIndex === currentGroupIndex));
- }
-
- getCellCountWithGroup(groupIndex, rowIndex = 0) {
- const { dateTableGroupedMap } = this.groupedDataMap;
-
- return dateTableGroupedMap
- .filter((_, index) => index <= groupIndex)
- .reduce(
- (previous, row) => previous + row[rowIndex].length,
- 0
- );
- }
-
- hasGroupAllDayPanel(groupIndex) {
- if(this._options.isVerticalGrouping) {
- return !!this.groupedDataMap.dateTableGroupedMap[groupIndex]?.[0][0].cellData.allDay;
- }
-
- return this.groupedDataMap.allDayPanelGroupedMap[groupIndex]?.length > 0;
- }
-
- isGroupIntersectDateInterval(groupIndex, startDate, endDate) {
- const groupStartDate = this.getGroupStartDate(groupIndex);
- const groupEndDate = this.getGroupEndDate(groupIndex);
-
- return startDate < groupEndDate && endDate > groupStartDate;
- }
-
- findGlobalCellPosition(date, groupIndex = 0, allDay = false) {
- const { completeViewDataMap } = this;
-
- const showAllDayPanel = this._options.isAllDayPanelVisible;
-
- for(let rowIndex = 0; rowIndex < completeViewDataMap.length; rowIndex += 1) {
- const currentRow = completeViewDataMap[rowIndex];
-
- for(let columnIndex = 0; columnIndex < currentRow.length; columnIndex += 1) {
- const cellData = currentRow[columnIndex];
- const {
- startDate: currentStartDate,
- endDate: currentEndDate,
- groupIndex: currentGroupIndex,
- allDay: currentAllDay,
- } = cellData;
+ for (let columnIndex = 0; columnIndex < currentRow.length; columnIndex += 1) {
+ const cellData = currentRow[columnIndex];
+ const {
+ startDate: currentStartDate,
+ endDate: currentEndDate,
+ groupIndex: currentGroupIndex,
+ allDay: currentAllDay,
+ } = cellData;
- if(groupIndex === currentGroupIndex
+ if (groupIndex === currentGroupIndex
&& allDay === !!currentAllDay
&& this._compareDatesAndAllDay(date, currentStartDate, currentEndDate, allDay)) {
- return {
- position: {
- columnIndex,
- rowIndex: showAllDayPanel && !this._options.isVerticalGrouping
- ? rowIndex - 1
- : rowIndex,
- },
- cellData,
- };
- }
- }
+ return {
+ position: {
+ columnIndex,
+ rowIndex: showAllDayPanel && !this._options.isVerticalGrouping
+ ? rowIndex - 1
+ : rowIndex,
+ },
+ cellData,
+ };
}
+ }
}
- _compareDatesAndAllDay(date, cellStartDate, cellEndDate, allDay) {
- const time = date.getTime();
- const trimmedTime = dateUtils.trimTime(date).getTime();
- const cellStartTime = cellStartDate.getTime();
- const cellEndTime = cellEndDate.getTime();
+ return undefined;
+ }
+
+ _compareDatesAndAllDay(date, cellStartDate, cellEndDate, allDay) {
+ const time = date.getTime();
+ const trimmedTime = dateUtils.trimTime(date).getTime();
+ const cellStartTime = cellStartDate.getTime();
+ const cellEndTime = cellEndDate.getTime();
- return (!allDay
+ return (!allDay
&& time >= cellStartTime
&& time < cellEndTime)
|| (allDay && trimmedTime === cellStartTime);
- }
+ }
- getSkippedDaysCount(groupIndex, startDate, endDate, daysCount) {
- const { dateTableGroupedMap } = this._groupedDataMapProvider.groupedDataMap;
- const groupedData = dateTableGroupedMap[groupIndex];
- let includedDays = 0;
+ getSkippedDaysCount(groupIndex, startDate, endDate, daysCount) {
+ const { dateTableGroupedMap } = this._groupedDataMapProvider.groupedDataMap;
+ const groupedData = dateTableGroupedMap[groupIndex];
+ let includedDays = 0;
- for(let rowIndex = 0; rowIndex < groupedData.length; rowIndex += 1) {
- for(let columnIndex = 0; columnIndex < groupedData[rowIndex].length; columnIndex += 1) {
- const cell = groupedData[rowIndex][columnIndex].cellData;
- if(startDate.getTime() < cell.endDate.getTime()
+ for (let rowIndex = 0; rowIndex < groupedData.length; rowIndex += 1) {
+ for (let columnIndex = 0; columnIndex < groupedData[rowIndex].length; columnIndex += 1) {
+ const cell = groupedData[rowIndex][columnIndex].cellData;
+ if (startDate.getTime() < cell.endDate.getTime()
&& endDate.getTime() > cell.startDate.getTime()) {
- includedDays += 1;
- }
- }
- }
-
- const lastCell = groupedData[groupedData.length - 1][groupedData[0].length - 1].cellData;
- const lastCellStart = dateUtils.trimTime(lastCell.startDate);
- const daysAfterView = Math.floor((endDate.getTime() - lastCellStart.getTime()) / dateUtils.dateToMilliseconds('day'));
-
- const deltaDays = daysAfterView > 0 ? daysAfterView : 0;
-
- return daysCount - includedDays - deltaDays;
- }
-
- getColumnsCount() {
- const { dateTableMap } = this.viewDataMap;
- return dateTableMap
- ? dateTableMap[0].length
- : 0;
- }
-
- getViewEdgeIndices(isAllDayPanel) {
- if(isAllDayPanel) {
- return {
- firstColumnIndex: 0,
- lastColumnIndex: this.viewDataMap.allDayPanelMap.length - 1,
- firstRowIndex: 0,
- lastRowIndex: 0,
- };
- }
-
- return {
- firstColumnIndex: 0,
- lastColumnIndex: this.viewDataMap.dateTableMap[0].length - 1,
- firstRowIndex: 0,
- lastRowIndex: this.viewDataMap.dateTableMap.length - 1,
- };
- }
-
- getGroupEdgeIndices(groupIndex, isAllDay) {
- const groupedDataMap = this.groupedDataMap.dateTableGroupedMap[groupIndex];
- const cellsCount = groupedDataMap[0].length;
- const rowsCount = groupedDataMap.length;
-
- const firstColumnIndex = groupedDataMap[0][0].position.columnIndex;
- const lastColumnIndex = groupedDataMap[0][cellsCount - 1].position.columnIndex;
-
- if(isAllDay) {
- return {
- firstColumnIndex,
- lastColumnIndex,
- firstRowIndex: 0,
- lastRowIndex: 0,
- };
+ includedDays += 1;
}
-
- return {
- firstColumnIndex,
- lastColumnIndex,
- firstRowIndex: groupedDataMap[0][0].position.rowIndex,
- lastRowIndex: groupedDataMap[rowsCount - 1][0].position.rowIndex,
- };
- }
-
- isSameCell(firstCellData, secondCellData) {
- const {
- startDate: firstStartDate,
- groupIndex: firstGroupIndex,
- allDay: firstAllDay,
- index: firstIndex,
- } = firstCellData;
- const {
- startDate: secondStartDate,
- groupIndex: secondGroupIndex,
- allDay: secondAllDay,
- index: secondIndex,
- } = secondCellData;
-
- return (
- firstStartDate.getTime() === secondStartDate.getTime()
+ }
+ }
+
+ const lastCell = groupedData[groupedData.length - 1][groupedData[0].length - 1].cellData;
+ const lastCellStart = dateUtils.trimTime(lastCell.startDate);
+ const daysAfterView = Math.floor((endDate.getTime() - lastCellStart.getTime()) / dateUtils.dateToMilliseconds('day'));
+
+ const deltaDays = daysAfterView > 0 ? daysAfterView : 0;
+
+ return daysCount - includedDays - deltaDays;
+ }
+
+ getColumnsCount() {
+ const { dateTableMap } = this.viewDataMap;
+ return dateTableMap
+ ? dateTableMap[0].length
+ : 0;
+ }
+
+ getViewEdgeIndices(isAllDayPanel) {
+ if (isAllDayPanel) {
+ return {
+ firstColumnIndex: 0,
+ lastColumnIndex: this.viewDataMap.allDayPanelMap.length - 1,
+ firstRowIndex: 0,
+ lastRowIndex: 0,
+ };
+ }
+
+ return {
+ firstColumnIndex: 0,
+ lastColumnIndex: this.viewDataMap.dateTableMap[0].length - 1,
+ firstRowIndex: 0,
+ lastRowIndex: this.viewDataMap.dateTableMap.length - 1,
+ };
+ }
+
+ getGroupEdgeIndices(groupIndex, isAllDay) {
+ const groupedDataMap = this.groupedDataMap.dateTableGroupedMap[groupIndex];
+ const cellsCount = groupedDataMap[0].length;
+ const rowsCount = groupedDataMap.length;
+
+ const firstColumnIndex = groupedDataMap[0][0].position.columnIndex;
+ const lastColumnIndex = groupedDataMap[0][cellsCount - 1].position.columnIndex;
+
+ if (isAllDay) {
+ return {
+ firstColumnIndex,
+ lastColumnIndex,
+ firstRowIndex: 0,
+ lastRowIndex: 0,
+ };
+ }
+
+ return {
+ firstColumnIndex,
+ lastColumnIndex,
+ firstRowIndex: groupedDataMap[0][0].position.rowIndex,
+ lastRowIndex: groupedDataMap[rowsCount - 1][0].position.rowIndex,
+ };
+ }
+
+ isSameCell(firstCellData, secondCellData) {
+ const {
+ startDate: firstStartDate,
+ groupIndex: firstGroupIndex,
+ allDay: firstAllDay,
+ index: firstIndex,
+ } = firstCellData;
+ const {
+ startDate: secondStartDate,
+ groupIndex: secondGroupIndex,
+ allDay: secondAllDay,
+ index: secondIndex,
+ } = secondCellData;
+
+ return (
+ firstStartDate.getTime() === secondStartDate.getTime()
&& firstGroupIndex === secondGroupIndex
&& firstAllDay === secondAllDay
&& firstIndex === secondIndex
- );
- }
+ );
+ }
- getLastViewDate() {
- const completeViewDataMap = this.completeViewDataMap;
- const rowsCount = completeViewDataMap.length - 1;
+ getLastViewDate() {
+ const { completeViewDataMap } = this;
+ const rowsCount = completeViewDataMap.length - 1;
- return completeViewDataMap[rowsCount][completeViewDataMap[rowsCount].length - 1].endDate;
- }
+ return completeViewDataMap[rowsCount][completeViewDataMap[rowsCount].length - 1].endDate;
+ }
- getStartViewDate() {
- return this._options.startViewDate;
- }
+ getStartViewDate() {
+ return this._options.startViewDate;
+ }
- getIntervalDuration(intervalCount) {
- return this.viewDataGenerator._getIntervalDuration(intervalCount);
- }
+ getIntervalDuration(intervalCount) {
+ return this.viewDataGenerator._getIntervalDuration(intervalCount);
+ }
- getLastCellEndDate() {
- return new Date(
- this.getLastViewDate().getTime() - dateUtils.dateToMilliseconds('minute')
- );
- }
+ getLastCellEndDate() {
+ return new Date(
+ this.getLastViewDate().getTime() - dateUtils.dateToMilliseconds('minute'),
+ );
+ }
- getLastViewDateByEndDayHour(endDayHour) {
- const lastCellEndDate = this.getLastCellEndDate();
- const endTime = dateUtils.dateTimeFromDecimal(endDayHour);
+ getLastViewDateByEndDayHour(endDayHour) {
+ const lastCellEndDate = this.getLastCellEndDate();
+ const endTime = dateUtils.dateTimeFromDecimal(endDayHour);
- const endDateOfLastViewCell = new Date(
- lastCellEndDate.setHours(
- endTime.hours,
- endTime.minutes
- )
- );
+ const endDateOfLastViewCell = new Date(
+ lastCellEndDate.setHours(
+ endTime.hours,
+ endTime.minutes,
+ ),
+ );
- return this._adjustEndDateByDaylightDiff(lastCellEndDate, endDateOfLastViewCell);
- }
+ return this._adjustEndDateByDaylightDiff(lastCellEndDate, endDateOfLastViewCell);
+ }
- _adjustEndDateByDaylightDiff(startDate, endDate) {
- const daylightDiff = timeZoneUtils.getDaylightOffsetInMs(startDate, endDate);
+ _adjustEndDateByDaylightDiff(startDate, endDate) {
+ const daylightDiff = timeZoneUtils.getDaylightOffsetInMs(startDate, endDate);
- const endDateOfLastViewCell = new Date(endDate.getTime() - daylightDiff);
+ const endDateOfLastViewCell = new Date(endDate.getTime() - daylightDiff);
- return new Date(endDateOfLastViewCell.getTime() - dateUtils.dateToMilliseconds('minute'));
- }
+ return new Date(endDateOfLastViewCell.getTime() - dateUtils.dateToMilliseconds('minute'));
+ }
- getCellCountInDay(startDayHour, endDayHour, hoursInterval) {
- return this.viewDataGenerator.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
- }
+ getCellCountInDay(startDayHour, endDayHour, hoursInterval) {
+ return this.viewDataGenerator.getCellCountInDay(startDayHour, endDayHour, hoursInterval);
+ }
- getCellCount(options) {
- return this.viewDataGenerator.getCellCount(options);
- }
+ getCellCount(options) {
+ return this.viewDataGenerator.getCellCount(options);
+ }
- getRowCount(options) {
- return this.viewDataGenerator.getRowCount(options);
- }
+ getRowCount(options) {
+ return this.viewDataGenerator.getRowCount(options);
+ }
- getVisibleDayDuration(startDayHour, endDayHour, hoursInterval) {
- return this.viewDataGenerator.getVisibleDayDuration(startDayHour, endDayHour, hoursInterval);
- }
+ getVisibleDayDuration(startDayHour, endDayHour, hoursInterval) {
+ return this.viewDataGenerator.getVisibleDayDuration(startDayHour, endDayHour, hoursInterval);
+ }
- _getRowCountWithAllDayRows() {
- const allDayRowCount = this._options.isAllDayPanelVisible ? 1 : 0;
+ _getRowCountWithAllDayRows() {
+ const allDayRowCount = this._options.isAllDayPanelVisible ? 1 : 0;
- return this.getRowCount(this._options) + allDayRowCount;
- }
+ return this.getRowCount(this._options) + allDayRowCount;
+ }
- getFirstDayOfWeek(firstDayOfWeekOption) {
- return this.viewDataGenerator.getFirstDayOfWeek(firstDayOfWeekOption);
- }
+ getFirstDayOfWeek(firstDayOfWeekOption) {
+ return this.viewDataGenerator.getFirstDayOfWeek(firstDayOfWeekOption);
+ }
- setViewOptions(options) {
- this._options = this._transformRenderOptions(options);
- }
+ setViewOptions(options) {
+ this._options = this._transformRenderOptions(options);
+ }
- getViewOptions() {
- return this._options;
- }
+ getViewOptions() {
+ return this._options;
+ }
- getViewPortGroupCount() {
- const { dateTableGroupedMap } = this.groupedDataMap;
- return dateTableGroupedMap?.length || 0;
- }
+ getViewPortGroupCount() {
+ const { dateTableGroupedMap } = this.groupedDataMap;
+ return dateTableGroupedMap?.length || 0;
+ }
}
diff --git a/packages/devextreme/js/ui/recurrence_editor.js b/packages/devextreme/js/ui/recurrence_editor.js
index 04d7276649de..d2d799d96e25 100644
--- a/packages/devextreme/js/ui/recurrence_editor.js
+++ b/packages/devextreme/js/ui/recurrence_editor.js
@@ -1,2 +1,19 @@
-import RecurrenceEditor from './scheduler/recurrence_editor';
+import RecurrenceEditor from '../__internal/scheduler/m_recurrence_editor';
export default RecurrenceEditor;
+
+/**
+ * @name dxRecurrenceEditorOptions.startDate
+ * @type Date
+ * @default new Date()
+ * @hidden
+ */
+
+
+/**
+ * @name dxRecurrenceEditorOptions.firstDayOfWeek
+ * @type Enums.FirstDayOfWeek
+ * @default undefined
+ * @hidden
+ */
+
+
diff --git a/packages/devextreme/js/ui/scheduler.js b/packages/devextreme/js/ui/scheduler.js
index cfcb5ea0f514..c4c714ea3824 100644
--- a/packages/devextreme/js/ui/scheduler.js
+++ b/packages/devextreme/js/ui/scheduler.js
@@ -1,3 +1,38 @@
import Scheduler from './scheduler/ui.scheduler';
+// STYLE scheduler
+
export default Scheduler;
+
+/**
+ * @name dxSchedulerOptions.activeStateEnabled
+ * @hidden
+ */
+
+/**
+ * @name dxSchedulerOptions.hoverStateEnabled
+ * @hidden
+ */
+
+/**
+ * @name dxScheduler.registerKeyHandler
+ * @publicName registerKeyHandler(key, handler)
+ * @hidden
+ */
+
+/**
+ * @hidden
+ * @name dxSchedulerOptions.indicatorTime
+ * @type Date
+ * @default undefined
+ */
+
+/**
+ * @hidden
+ * @name dxSchedulerOptions.appointmentPopupTemplate
+ * @type template|function
+ * @default "appointmentPopup"
+ * @type_function_param1 appointmentData:object
+ * @type_function_param2 contentElement:DxElement
+ * @type_function_return string|Element|jQuery
+ */
diff --git a/packages/devextreme/js/ui/scheduler/ui.scheduler.js b/packages/devextreme/js/ui/scheduler/ui.scheduler.js
new file mode 100644
index 000000000000..e384aa341abc
--- /dev/null
+++ b/packages/devextreme/js/ui/scheduler/ui.scheduler.js
@@ -0,0 +1,3 @@
+import Scheduler from '../../__internal/scheduler/m_scheduler';
+
+export default Scheduler;
diff --git a/packages/devextreme/js/ui/scheduler/utils.timeZone.js b/packages/devextreme/js/ui/scheduler/utils.timeZone.js
new file mode 100644
index 000000000000..5f6d89248586
--- /dev/null
+++ b/packages/devextreme/js/ui/scheduler/utils.timeZone.js
@@ -0,0 +1,3 @@
+import timezoneUtils from '../../__internal/scheduler/m_utils_time_zone';
+
+export default timezoneUtils;