diff --git a/packages/devextreme/js/__internal/scheduler/__tests__/__mock__/m_mock_scheduler.ts b/packages/devextreme/js/__internal/scheduler/__tests__/__mock__/m_mock_scheduler.ts index 90a9c4a623cc..7fb76ab65d0b 100644 --- a/packages/devextreme/js/__internal/scheduler/__tests__/__mock__/m_mock_scheduler.ts +++ b/packages/devextreme/js/__internal/scheduler/__tests__/__mock__/m_mock_scheduler.ts @@ -19,7 +19,7 @@ export const setupSchedulerTestEnvironment = ({ }: SetupSchedulerTestEnvironmentOptions = {}): void => { jest.spyOn(logger, 'warn').mockImplementation(() => {}); DOMComponent.prototype._isVisible = jest.fn((): boolean => true); - SchedulerWorkSpace.prototype._createCrossScrollingConfig = (): { + (SchedulerWorkSpace.prototype as any).createCrossScrollingConfig = (): { direction: string; onScroll: jest.Mock; onEnd: jest.Mock; diff --git a/packages/devextreme/js/__internal/scheduler/__tests__/workspace.base.test.ts b/packages/devextreme/js/__internal/scheduler/__tests__/workspace.base.test.ts index 886ace2cc3f2..c14941889a7f 100644 --- a/packages/devextreme/js/__internal/scheduler/__tests__/workspace.base.test.ts +++ b/packages/devextreme/js/__internal/scheduler/__tests__/workspace.base.test.ts @@ -94,7 +94,7 @@ describe('scheduler workspace', () => { jest.spyOn(workspace.cache, 'clear'); workspace.cache.memo('test', () => 'value'); - workspace._cleanView(); + (workspace as any).cleanView(); expect(workspace.cache.clear).toHaveBeenCalledTimes(1); expect(workspace.cache.size).toBe(0); diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts index 30d29dc5ec48..e883f8758dc7 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts @@ -41,13 +41,13 @@ const INNER_CELL_MARGIN = 5; const OUTER_CELL_MARGIN = 20; class SchedulerAgenda extends WorkSpace { - _startViewDate: any; + private startViewDate: any; - _rows: number[][] = []; + private rows: number[][] = []; - _$rows: any; + private $rows: any; - _$noDataContainer: any; + private $noDataContainer: any; // eslint-disable-next-line class-methods-use-this protected _activeStateUnit(): string { @@ -57,7 +57,7 @@ class SchedulerAgenda extends WorkSpace { get type() { return VIEWS.AGENDA; } getStartViewDate() { - return this._startViewDate; + return this.startViewDate; } _init() { @@ -82,7 +82,7 @@ class SchedulerAgenda extends WorkSpace { break; case 'noDataText': case 'rowHeight': - this._recalculateAgenda(this._rows); + this.recalculateAgenda(this.rows); break; case 'groups': if (!value?.length) { @@ -92,7 +92,7 @@ class SchedulerAgenda extends WorkSpace { this.detachGroupCountClass(); } } else if (!this._$groupTable) { - this._initGroupTable(); + this.initGroupTable(); this._dateTableScrollable.$content().prepend(this._$groupTable); } super._optionChanged(args); @@ -136,17 +136,17 @@ class SchedulerAgenda extends WorkSpace { protected override updateAllDayVisibility() { return noop(); } - _updateAllDayHeight() { return noop(); } + private updateAllDayHeight() { return noop(); } protected override initWorkSpaceUnits() { - this._initGroupTable(); + this.initGroupTable(); this._$timePanel = $('').attr('aria-hidden', true).addClass(TIME_PANEL_CLASS); this._$dateTable = $('
').attr('aria-hidden', true).addClass(DATE_TABLE_CLASS); this._$dateTableScrollableContent = $('
').addClass('dx-scheduler-date-table-scrollable-content'); this._$dateTableContainer = $('
').addClass('dx-scheduler-date-table-container'); } - _initGroupTable() { + private initGroupTable() { const groups = this.option('groups'); if (groups?.length) { this._$groupTable = $('
').attr('aria-hidden', true).addClass(GROUP_TABLE_CLASS); @@ -154,23 +154,23 @@ class SchedulerAgenda extends WorkSpace { } protected override renderView() { - this._startViewDate = agendaUtils.calculateStartViewDate(this.option('currentDate') as any, this.option('startDayHour') as any); - this._rows = []; + this.startViewDate = agendaUtils.calculateStartViewDate(this.option('currentDate') as any, this.option('startDayHour') as any); + this.rows = []; } - _recalculateAgenda(rows) { + private recalculateAgenda(rows) { let cellTemplates = []; - this._cleanView(); + this.cleanView(); - if (this._rowsIsEmpty(rows)) { - this._renderNoData(); + if (this.rowsIsEmpty(rows)) { + this.renderNoData(); return; } - this._rows = rows; + this.rows = rows; if (this._$groupTable) { cellTemplates = this.renderGroupHeader(); - this._setGroupHeaderCellsHeight(); + this.setGroupHeaderCellsHeight(); } this.renderTimePanel(); @@ -179,11 +179,11 @@ class SchedulerAgenda extends WorkSpace { this._dateTableScrollable.update(); } - _renderNoData() { - this._$noDataContainer = $('
').addClass(NODATA_CONTAINER_CLASS) + private renderNoData() { + this.$noDataContainer = $('
').addClass(NODATA_CONTAINER_CLASS) .html(this.option('noDataText') as any); - this._dateTableScrollable.$content().append(this._$noDataContainer); + this._dateTableScrollable.$content().append(this.$noDataContainer); } protected override setTableSizes() { return noop(); } @@ -191,11 +191,11 @@ class SchedulerAgenda extends WorkSpace { protected override toggleHorizontalScrollClass() { return noop(); } // eslint-disable-next-line @typescript-eslint/no-unused-vars - _createCrossScrollingConfig(argument?: any) { return noop(); } + protected override createCrossScrollingConfig(argument?: any) { return noop(); } - _setGroupHeaderCellsHeight() { + private setGroupHeaderCellsHeight() { const $cells = this.getGroupHeaderCells().filter((_, element) => !element.getAttribute('rowSpan')); - const rows = this._removeEmptyRows(this._rows); + const rows = this.removeEmptyRows(this.rows); if (!rows.length) { return; @@ -203,11 +203,11 @@ class SchedulerAgenda extends WorkSpace { for (let i = 0; i < $cells.length; i++) { const $cellContent = $cells.eq(i).find('.dx-scheduler-group-header-content'); - setOuterHeight($cellContent, this._getGroupRowHeight(rows[i])); + setOuterHeight($cellContent, this.getGroupRowHeight(rows[i])); } } - _rowsIsEmpty(rows) { + private rowsIsEmpty(rows) { let result = true; for (let i = 0; i < rows.length; i++) { @@ -229,7 +229,7 @@ class SchedulerAgenda extends WorkSpace { (this.$element() as any).addClass(className); } - _removeEmptyRows(rows) { + private removeEmptyRows(rows) { const result: any[] = []; const isEmpty = function (data) { return !data.some((value) => value > 0); @@ -304,7 +304,7 @@ class SchedulerAgenda extends WorkSpace { }; } - _cleanView() { + protected override cleanView() { this._$dateTable.empty(); this._$timePanel.empty(); @@ -312,11 +312,11 @@ class SchedulerAgenda extends WorkSpace { this._$groupTable.empty(); } - if (this._$noDataContainer) { - this._$noDataContainer.empty(); - this._$noDataContainer.remove(); + if (this.$noDataContainer) { + this.$noDataContainer.empty(); + this.$noDataContainer.remove(); - delete this._$noDataContainer; + delete this.$noDataContainer; } } @@ -348,13 +348,13 @@ class SchedulerAgenda extends WorkSpace { protected override attachEvents() { return noop(); } - _cleanCellDataCache() { return noop(); } + private cleanCellDataCache() { return noop(); } isIndicationAvailable() { return false; } - _prepareCellTemplateOptions(text, date, rowIndex, $cell) { + private prepareCellTemplateOptions(text, date, rowIndex, $cell) { const leaf = this.resourceManager.groupsLeafs[rowIndex]; const groups = leaf?.grouped ?? {}; const groupIndex = leaf?.groupIndex; @@ -376,7 +376,7 @@ class SchedulerAgenda extends WorkSpace { const cellTemplates: any[] = []; const cellTemplateOpt = options.cellTemplate; - this._$rows = []; + this.$rows = []; let i; const fillTableBody = function (rowIndex, rowSize) { @@ -386,7 +386,7 @@ class SchedulerAgenda extends WorkSpace { let cellDayName; const $row = $('
'); const $td = $('').append(this._$rows)); + $(options.container).append($('').append(this.$rows)); this.applyCellTemplates(cellTemplates); } - _setLastRowClass() { - if (this._rows.length > 1 && this._$rows.length) { - const $lastRow = this._$rows[this._$rows.length - 1]; + private setLastRowClass() { + if (this.rows.length > 1 && this.$rows.length) { + const $lastRow = this.$rows[this.$rows.length - 1]; $lastRow.addClass(LAST_ROW_CLASS); } @@ -440,25 +440,25 @@ class SchedulerAgenda extends WorkSpace { rowClass: TIME_PANEL_ROW_CLASS, cellClass: TIME_PANEL_CELL_CLASS, cellTemplate: this.option('dateCellTemplate'), - getStartDate: this._getTimePanelStartDate.bind(this), + getStartDate: this.getTimePanelStartDate.bind(this), }); } - _getTimePanelStartDate(rowIndex) { + private getTimePanelStartDate(rowIndex) { const current = new Date(this.option('currentDate') as any); const cellDate = new Date(current.setDate(current.getDate() + rowIndex)); return cellDate; } - _getRowHeight(rowSize) { + private getRowHeight(rowSize) { const baseHeight = this.option('rowHeight') as any; const innerOffset = (rowSize - 1) * INNER_CELL_MARGIN; return rowSize ? (baseHeight * rowSize) + innerOffset + OUTER_CELL_MARGIN : 0; } - _getGroupRowHeight(groupRows) { + private getGroupRowHeight(groupRows) { if (!groupRows) { return; } @@ -466,7 +466,7 @@ class SchedulerAgenda extends WorkSpace { let result = 0; for (let i = 0; i < groupRows.length; i++) { - result += this._getRowHeight(groupRows[i]); + result += this.getRowHeight(groupRows[i]); } return result; @@ -481,7 +481,7 @@ class SchedulerAgenda extends WorkSpace { this.getStartViewDate(), this.resourceManager.groupCount(), ); - this._recalculateAgenda(rows); + this.recalculateAgenda(rows); } getAgendaVerticalStepHeight() { @@ -536,9 +536,9 @@ class SchedulerAgenda extends WorkSpace { renovatedRenderSupported() { return false; } - _setSelectedCellsByCellData() {} + private setSelectedCellsByCellData() {} - _getIntervalDuration() { + protected override getTotalViewDuration() { return dateUtils.dateToMilliseconds('day') * (this.option('intervalCount') as any); } diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline.ts index ebe1827e9bb2..b72ba95ee23c 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline.ts @@ -59,7 +59,7 @@ class SchedulerTimeline extends SchedulerWorkSpace { return 'shorttime'; } - _getWorkSpaceHeight() { + private getWorkSpaceHeight() { if (this.option('crossScrollingEnabled') && hasWindow()) { return getBoundingRect(this._$dateTable.get(0)).height; } @@ -103,22 +103,24 @@ class SchedulerTimeline extends SchedulerWorkSpace { return false; } - _needRenderWeekHeader() { + // Overridden in SchedulerTimelineDay, SchedulerTimelineWeek + needRenderWeekHeader() { return false; } - _incrementDate(date) { + // Overridden in SchedulerTimelineWeek, SchedulerTimelineWorkWeek + incrementDate(date) { date.setDate(date.getDate() + 1); } getIndicationCellCount() { - const timeDiff = this._getTimeDiff(); - return this._calculateDurationInCells(timeDiff); + const timeDiff = this.getTimeDiff(); + return this.calculateDurationInCells(timeDiff); } - _getTimeDiff() { - let today = this._getToday(); - const date = this._getIndicationFirstViewDate(); + private getTimeDiff() { + let today = this.getToday(); + const date = this.getIndicationFirstViewDate(); const startViewDate = this.getStartViewDate(); const dayLightOffset = timezoneUtils.getDaylightOffsetInMs(startViewDate, today); @@ -130,8 +132,9 @@ class SchedulerTimeline extends SchedulerWorkSpace { return today.getTime() - date.getTime(); } - _calculateDurationInCells(timeDiff) { - const today = this._getToday(); + // Overridden in SchedulerTimelineMonth + calculateDurationInCells(timeDiff) { + const today = this.getToday(); const differenceInDays = Math.floor(timeDiff / toMs('day')); let duration = (timeDiff - differenceInDays * toMs('day') - (this.option('startDayHour') as any) * toMs('hour')) / this.getCellDuration(); @@ -156,26 +159,26 @@ class SchedulerTimeline extends SchedulerWorkSpace { return this.getIndicationCellCount() * this.getCellWidth(); } - _isVerticalShader() { + isVerticalShader() { return false; } - _isCurrentTimeHeaderCell() { + isCurrentTimeHeaderCell() { return false; } protected override setTableSizes() { super.setTableSizes(); - const minHeight = this._getWorkSpaceMinHeight(); + const minHeight = this.getWorkSpaceMinHeight(); setHeight(this._$sidebarTable, minHeight); setHeight(this._$dateTable, minHeight); this.virtualScrollingDispatcher.updateDimensions(); } - _getWorkSpaceMinHeight() { - let minHeight = this._getWorkSpaceHeight(); + private getWorkSpaceMinHeight() { + let minHeight = this.getWorkSpaceHeight(); const workspaceContainerHeight = getOuterHeight(this._$flexContainer, true); @@ -193,7 +196,7 @@ class SchedulerTimeline extends SchedulerWorkSpace { }; } - _getCellByCoordinates(cellCoordinates, groupIndex) { + protected override getCellElementByPosition(cellCoordinates, groupIndex) { const indexes = this._groupedStrategy.prepareCellIndexes(cellCoordinates, groupIndex); return this._$dateTable @@ -207,7 +210,7 @@ class SchedulerTimeline extends SchedulerWorkSpace { return getOuterWidth(this._$dateTable, true); } - _getIndicationFirstViewDate() { + private getIndicationFirstViewDate() { return dateUtils.trimTime(new Date(this.getStartViewDate())); } @@ -291,7 +294,7 @@ class SchedulerTimeline extends SchedulerWorkSpace { return { ...options, - isGenerateWeekDaysHeaderData: this._needRenderWeekHeader(), + isGenerateWeekDaysHeaderData: this.needRenderWeekHeader(), getDateForHeaderText: timelineWeekUtils.getDateForHeaderText, }; } @@ -328,7 +331,7 @@ class SchedulerTimeline extends SchedulerWorkSpace { protected override updateAllDayVisibility() { return noop(); } - _updateAllDayHeight() { return noop(); } + private updateAllDayHeight() { return noop(); } protected override getDateHeaderTemplate() { return this.option('timeCellTemplate'); @@ -366,9 +369,9 @@ class SchedulerTimeline extends SchedulerWorkSpace { .find(`.${HEADER_PANEL_CELL_CLASS}:not(.${HEADER_PANEL_WEEK_CELL_CLASS})`); } - _getCurrentTimePanelCellIndices() { + getCurrentTimePanelCellIndices() { const columnCountPerGroup = this._getCellCount(); - const today = this._getToday(); + const today = this.getToday(); const index = this.getCellIndexByDate(today); const { columnIndex: currentTimeColumnIndex } = this.getCellCoordinatesByIndex(index); @@ -396,7 +399,7 @@ class SchedulerTimeline extends SchedulerWorkSpace { protected override renderDateHeader() { const $headerRow = super.renderDateHeader(); - if (this._needRenderWeekHeader()) { + if (this.needRenderWeekHeader()) { const firstViewDate = new Date(this.getStartViewDate()); let currentDate = new Date(firstViewDate); @@ -445,7 +448,7 @@ class SchedulerTimeline extends SchedulerWorkSpace { if ((templateIndex % cellsInGroup) === (cellsInGroup - 1)) { currentDate = new Date(firstViewDate); } else { - this._incrementDate(currentDate); + this.incrementDate(currentDate); } } @@ -454,18 +457,18 @@ class SchedulerTimeline extends SchedulerWorkSpace { } } - _renderIndicator(height, rtlOffset, $container, groupCount) { + renderIndicator(height, rtlOffset, $container, groupCount) { let $indicator; const width = this.getIndicationWidth(); if (this.option('groupOrientation') === 'vertical') { - $indicator = this._createIndicator($container); + $indicator = this.createIndicator($container); setHeight($indicator, getBoundingRect($container.get(0)).height); $indicator.css('left', rtlOffset ? rtlOffset - width : width); } else { for (let i = 0; i < groupCount; i++) { const offset = this.isGroupedByDate() ? i * this.getCellWidth() : this._getCellCount() * this.getCellWidth() * i; - $indicator = this._createIndicator($container); + $indicator = this.createIndicator($container); setHeight($indicator, getBoundingRect($container.get(0)).height); $indicator.css('left', rtlOffset ? rtlOffset - width - offset : width + offset); @@ -495,16 +498,16 @@ class SchedulerTimeline extends SchedulerWorkSpace { // Old render methods. // TODO Old render: delete these methods with the old render. - _setCurrentTimeCells(): void { + setCurrentTimeCells(): void { const timePanelCells = this.getTimePanelCells(); - const currentTimeCellIndices = this._getCurrentTimePanelCellIndices(); + const currentTimeCellIndices = this.getCurrentTimePanelCellIndices(); currentTimeCellIndices.forEach((timePanelCellIndex) => { timePanelCells.eq(timePanelCellIndex) .addClass(HEADER_CURRENT_TIME_CELL_CLASS); }); } - _cleanCurrentTimeCells(): void { + cleanCurrentTimeCells(): void { (this.$element() as any) .find(`.${HEADER_CURRENT_TIME_CELL_CLASS}`) .removeClass(HEADER_CURRENT_TIME_CELL_CLASS); diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_day.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_day.ts index f27ec597212c..3b1a722f38ba 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_day.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_day.ts @@ -12,7 +12,7 @@ class SchedulerTimelineDay extends SchedulerTimeline { return TIMELINE_CLASS; } - _needRenderWeekHeader() { + needRenderWeekHeader() { return this.isWorkSpaceWithCount(); } } diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_month.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_month.ts index 25a9f16bf3a8..e33852e97549 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_month.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_month.ts @@ -30,7 +30,7 @@ class SchedulerTimelineMonth extends SchedulerTimeline { return this.option('dateCellTemplate'); } - _calculateDurationInCells(timeDiff) { + calculateDurationInCells(timeDiff) { return timeDiff / this.getCellDuration(); } diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_week.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_week.ts index 8e03bf0018d4..cf895a955608 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_week.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_week.ts @@ -17,11 +17,11 @@ export default class SchedulerTimelineWeek extends SchedulerTimeline { return getBoundingRect($headerRow.children().first().get(0)).width; } - _needRenderWeekHeader() { + needRenderWeekHeader() { return true; } - _incrementDate(date) { + incrementDate(date) { date.setDate(date.getDate() + 1); } } diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_work_week.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_work_week.ts index 4c89a5f5abaa..4cf716529122 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_work_week.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_work_week.ts @@ -23,12 +23,12 @@ class SchedulerTimelineWorkWeek extends SchedulerTimelineWeek { return TIMELINE_CLASS; } - _incrementDate(date) { + incrementDate(date) { const day = date.getDay(); if (day === LAST_DAY_WEEK_INDEX) { date.setDate(date.getDate() + 2); } - super._incrementDate(date); + super.incrementDate(date); } } diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts index a6d09b578a4d..5927452aa596 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts @@ -224,7 +224,7 @@ class SchedulerWorkSpace extends Widget { _disposed: any; - _getToday: any; + protected getToday?(): Date; _$allDayPanel: any; @@ -688,7 +688,7 @@ class SchedulerWorkSpace extends Widget { }; if (this.needCreateCrossScrolling()) { - config = extend(config, this._createCrossScrollingConfig(config)); + config = extend(config, this.createCrossScrollingConfig(config)); } if (this.isVirtualScrolling() @@ -708,8 +708,7 @@ class SchedulerWorkSpace extends Widget { return config; } - // TODO: make it private. Being used as public method by external code. - _createCrossScrollingConfig({ onScroll }): any { + protected createCrossScrollingConfig({ onScroll }): any { return { direction: 'both', onScroll: (event) => { @@ -823,7 +822,8 @@ class SchedulerWorkSpace extends Widget { }); } - // TODO: make it private. Being used as public method by external code. + // TODO: rename to getCellCount — used externally via workSpace reference: + // m_work_space_grouped_strategy_horizontal.ts (7 usages), m_work_space_grouped_strategy_vertical.ts, shaders/current_time_shader_horizontal.ts _getCellCount() { return this.viewDataProvider.getCellCount({ intervalCount: this.option('intervalCount'), @@ -878,7 +878,7 @@ class SchedulerWorkSpace extends Widget { startRowIndex: 0, startCellIndex: 0, groupOrientation, - today: this._getToday?.(), + today: this.getToday?.(), getResourceManager: this.option('getResourceManager'), isProvideVirtualCellsWidth, isAllDayPanelVisible: this.isAllDayPanelVisible, @@ -949,12 +949,12 @@ class SchedulerWorkSpace extends Widget { return getViewStartByOptions( this.option('startDate'), this.option('currentDate'), - this._getIntervalDuration(), + this.getTotalViewDuration(), this.option('startDate') ? this.calculateViewStartDate() : undefined, ); } - protected _getIntervalDuration() { + protected getTotalViewDuration() { return this.viewDataProvider.getIntervalDuration(this.option('intervalCount')); } @@ -1348,7 +1348,7 @@ class SchedulerWorkSpace extends Widget { }); } - protected _getCellByCoordinates(cellCoordinates, groupIndex, inAllDayRow) { + protected getCellElementByPosition(cellCoordinates, groupIndex, inAllDayRow) { const indexes = this._groupedStrategy.prepareCellIndexes(cellCoordinates, groupIndex, inAllDayRow); return this.dom_getDateCell(indexes); } @@ -2314,7 +2314,7 @@ class SchedulerWorkSpace extends Widget { this.cleanWorkSpace(); break; case 'groups': - this._cleanView(); + this.cleanView(); this.removeAllDayElements(); this.initGrouping(); this.repaint(); @@ -2328,7 +2328,7 @@ class SchedulerWorkSpace extends Widget { break; case 'showAllDayPanel': if (this.isVerticalGroupedWorkSpace()) { - this._cleanView(); + this.cleanView(); this.removeAllDayElements(); this.initGrouping(); this.repaint(); @@ -2424,7 +2424,7 @@ class SchedulerWorkSpace extends Widget { } protected cleanWorkSpace() { - this._cleanView(); + this.cleanView(); this.toggleGroupedClass(); this.toggleWorkSpaceWithOddCells(); @@ -2822,8 +2822,7 @@ class SchedulerWorkSpace extends Widget { this._$allDayTitle?.remove(); } - // TODO: make it private. Being used as public method by external code. - _cleanView(): void { + protected cleanView(): void { this.cache.clear(); this.cleanTableWidths(); this.cellsSelectionState.clearSelectedAndFocusedCells(); diff --git a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_indicator.ts b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_indicator.ts index 52bc78e97f5b..52007e4baea8 100644 --- a/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_indicator.ts +++ b/packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_indicator.ts @@ -18,10 +18,9 @@ const SCHEDULER_DATE_TIME_INDICATOR_CLASS = 'dx-scheduler-date-time-indicator'; const TIME_PANEL_CURRENT_TIME_CELL_CLASS = 'dx-scheduler-time-panel-current-time-cell'; class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { - _indicatorInterval: any; + private indicatorInterval: any; - // @ts-expect-error - _getToday() { + protected getToday(): Date { const viewOffset = this.option('viewOffset') as number; const today = getToday(this.option('indicatorTime') as Date, this.timeZoneCalculator); return dateUtilsTs.addOffsets(today, -viewOffset); @@ -29,7 +28,7 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { isIndicationOnView(): boolean { if (this.option('showCurrentTimeIndicator')) { - const today = this._getToday(); + const today = this.getToday(); const endViewDate = dateUtils.trimTime(this.getEndViewDate()); return dateUtils.dateInRange(today, this.getStartViewDate(), new Date(endViewDate.getTime() + toMs('day'))); @@ -42,13 +41,13 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { return false; } - const today = this._getToday(); + const today = this.getToday(); return today >= dateUtils.trimTime(new Date(this.getStartViewDate())); } isIndicatorVisible() { - const today = this._getToday(); + const today = this.getToday(); // Subtracts 1 ms from the real endViewDate instead of 1 minute const endViewDate = new Date(this.getEndViewDate().getTime() + toMs('minute') - 1); @@ -59,11 +58,12 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { return dateUtils.dateInRange(today, firstViewDate, endViewDate); } - _renderIndicator(height, rtlOffset, $container, groupCount) { + // Overridden in SchedulerTimeline + 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); + const $indicator = this.createIndicator($container); setWidth( $indicator, @@ -73,14 +73,14 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { } } - _createIndicator($container) { + protected createIndicator($container) { const $indicator = $('
').addClass(SCHEDULER_DATE_TIME_INDICATOR_CLASS); $container.append($indicator); return $indicator; } - _getRtlOffset(width) { + private getRtlOffset(width) { return this.option('rtlEnabled') ? getBoundingRect(this._dateTableScrollable.$content().get(0)).width - this.getTimePanelWidth() - width : 0; } @@ -89,27 +89,28 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { return; } - this._clearIndicatorUpdateInterval(); + this.clearIndicatorUpdateInterval(); - this._indicatorInterval = setInterval(() => { + this.indicatorInterval = setInterval(() => { this.renderCurrentDateTimeIndication(); }, this.option('indicatorUpdateInterval')); } - _clearIndicatorUpdateInterval() { - if (this._indicatorInterval) { - clearInterval(this._indicatorInterval); - delete this._indicatorInterval; + private clearIndicatorUpdateInterval() { + if (this.indicatorInterval) { + clearInterval(this.indicatorInterval); + delete this.indicatorInterval; } } - _isVerticalShader() { + // Overridden in SchedulerTimeline + isVerticalShader() { return true; } getIndicationWidth() { const cellCount = this._getCellCount(); - const cellSpan = Math.min(this._getIndicatorDaysSpan(), cellCount); + const cellSpan = Math.min(this.getIndicatorDaysSpan(), cellCount); const width = cellSpan * this.getCellWidth(); const maxWidth = this.getCellWidth() * cellCount; @@ -117,14 +118,14 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { } getIndicatorOffset() { - const cellSpan = this._getIndicatorDaysSpan() - 1; + const cellSpan = this.getIndicatorDaysSpan() - 1; const offset = cellSpan * this.getCellWidth(); return offset; } - _getIndicatorDaysSpan(): number { - const today = this._getToday(); + private getIndicatorDaysSpan(): number { + const today = this.getToday(); const viewStartTime = this.getStartViewDate().getTime(); let timeDiff = today.getTime() - viewStartTime; @@ -137,7 +138,7 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { } getIndicationHeight() { - const today = timezoneUtils.getDateWithoutTimezoneChange(this._getToday()); + const today = timezoneUtils.getDateWithoutTimezoneChange(this.getToday()); const cellHeight = this.getCellHeight(); const date = new Date(this.getStartViewDate()); @@ -152,7 +153,7 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { } _dispose() { - this._clearIndicatorUpdateInterval(); + this.clearIndicatorUpdateInterval(); super._dispose.apply(this, arguments as any); } @@ -171,17 +172,18 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { } renderCurrentDateTimeLineAndShader(): void { - this._cleanDateTimeIndicator(); + this.cleanDateTimeIndicator(); this._shader?.clean(); this.renderDateTimeIndication(); } - _isCurrentTimeHeaderCell(headerIndex: number): boolean { + // Overridden in SchedulerTimeline + isCurrentTimeHeaderCell(headerIndex: number): boolean { if (this.isIndicationOnView()) { const { completeDateHeaderMap } = this.viewDataProvider; const date = completeDateHeaderMap[completeDateHeaderMap.length - 1][headerIndex].startDate; - return dateUtils.sameDate(date, this._getToday()); + return dateUtils.sameDate(date, this.getToday()); } return false; @@ -190,17 +192,17 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { protected override getHeaderPanelCellClass(i) { const cellClass = super.getHeaderPanelCellClass(i); - if (this._isCurrentTimeHeaderCell(i)) { + if (this.isCurrentTimeHeaderCell(i)) { return `${cellClass} ${HEADER_CURRENT_TIME_CELL_CLASS}`; } return cellClass; } - _cleanView() { - super._cleanView(); + protected override cleanView() { + super.cleanView(); - this._cleanDateTimeIndicator(); + this.cleanDateTimeIndicator(); } _dimensionChanged() { @@ -209,7 +211,7 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { this.renderCurrentDateTimeLineAndShader(); } - _cleanDateTimeIndicator() { + private cleanDateTimeIndicator() { (this.$element() as any).find(`.${SCHEDULER_DATE_TIME_INDICATOR_CLASS}`).remove(); } @@ -252,9 +254,10 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { }); } - _getCurrentTimePanelCellIndices() { + // Overridden in SchedulerTimeline + getCurrentTimePanelCellIndices() { const rowCountPerGroup = this.getTimePanelRowCount(); - const today = this._getToday(); + const today = this.getToday(); const index = this.getCellIndexByDate(today); const { rowIndex: currentTimeRowIndex } = this.getCellCoordinatesByIndex(index); @@ -298,28 +301,30 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace { const groupCount = this._getGroupCount() || 1; const $container = this._dateTableScrollable.$content(); const height = this.getIndicationHeight(); - const rtlOffset = this._getRtlOffset(this.getCellWidth()); + const rtlOffset = this.getRtlOffset(this.getCellWidth()); - this._renderIndicator(height, rtlOffset, $container, groupCount); + this.renderIndicator(height, rtlOffset, $container, groupCount); // TODO Old render: delete this code with the old render. if (!this.isRenovatedRender()) { - this._setCurrentTimeCells(); + this.setCurrentTimeCells(); } } // Temporary new render methods. // TODO Old render: replace base call methods by these after the deleting of the old render. - protected _setCurrentTimeCells(): void { + // Overridden in SchedulerTimeline + setCurrentTimeCells(): void { const timePanelCells = this.getTimePanelCells(); - const currentTimeCellIndices = this._getCurrentTimePanelCellIndices(); + const currentTimeCellIndices = this.getCurrentTimePanelCellIndices(); currentTimeCellIndices.forEach((timePanelCellIndex) => { timePanelCells.eq(timePanelCellIndex) .addClass(TIME_PANEL_CURRENT_TIME_CELL_CLASS); }); } - protected _cleanCurrentTimeCells(): void { + // Overridden in SchedulerTimeline + cleanCurrentTimeCells(): void { (this.$element() as any) .find(`.${TIME_PANEL_CURRENT_TIME_CELL_CLASS}`) .removeClass(TIME_PANEL_CURRENT_TIME_CELL_CLASS); 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 8494c3fe1cd0..89b9bd44ea5d 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 @@ -156,7 +156,7 @@ class SchedulerWorkSpaceMonth extends SchedulerWorkSpace { protected override updateAllDayVisibility() { return noop(); } - _updateAllDayHeight() { return noop(); } + private updateAllDayHeight() { return noop(); } // -------------- // These methods should be deleted when we get rid of old render @@ -166,7 +166,7 @@ class SchedulerWorkSpaceMonth extends SchedulerWorkSpace { protected override renderAllDayPanel() { return noop(); } - _setMonthClassesToCell($cell, data) { + private setMonthClassesToCell($cell, data) { $cell .toggleClass(DATE_TABLE_CURRENT_DATE_CLASS, data.isCurrentDate) .toggleClass(DATE_TABLE_FIRST_OF_MONTH_CLASS, data.isFirstDayMonthHighlighting) @@ -182,7 +182,7 @@ class SchedulerWorkSpaceMonth extends SchedulerWorkSpace { return monthUtils.getCellText(date, this.option('intervalCount') as any); }; options.getCellTextClass = DATE_TABLE_CELL_TEXT_CLASS; - options.setAdditionalClasses = this._setMonthClassesToCell.bind(this); + options.setAdditionalClasses = this.setMonthClassesToCell.bind(this); super.renderTableBody(options); } diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/agenda.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/agenda.tests.js index 4272aaad4367..d326f8bdb558 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/agenda.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/agenda.tests.js @@ -33,7 +33,7 @@ module('Agenda', {}, () => { const config = { onContentReady: e => { e.component.renderView(); - e.component._recalculateAgenda(rows); + e.component.recalculateAgenda(rows); }, getResourceManager: getEmptyResourceManager, }; @@ -61,11 +61,11 @@ module('Agenda', {}, () => { assert.deepEqual(firstViewDate, new Date(2016, 1, 17, 2), 'The first view date is OK'); }); - test('_removeEmptyRows method', async function(assert) { + test('removeEmptyRows method', async function(assert) { const rows = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 0, 1]]; const instance = createInstance(); - const resultRows = instance._removeEmptyRows(rows); + const resultRows = instance.removeEmptyRows(rows); assert.deepEqual(resultRows, [[0, 0, 0, 0, 1], [1, 1, 1, 0, 1]], 'The empty rows was removed'); }); @@ -140,7 +140,7 @@ module('Agenda', {}, () => { test('Agenda should be recalculated after rowHeight changed', async function(assert) { const instance = createInstance(); - const recalculateStub = sinon.stub(instance, '_recalculateAgenda'); + const recalculateStub = sinon.stub(instance, 'recalculateAgenda'); instance.option('rowHeight', 100); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.agenda.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.agenda.tests.js index d37ed230f5f5..bf9e6e10f6f9 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.agenda.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.agenda.tests.js @@ -786,7 +786,7 @@ module('Integration: Agenda', moduleConfig, () => { const rowHeight = 77; const $element = instance.$element(); const expectedWidth = getOuterWidth($element.find('.dx-scheduler-date-table')); - const agendaStub = sinon.stub(agenda, '_getRowHeight').returns(rowHeight); + const agendaStub = sinon.stub(agenda, 'getRowHeight').returns(rowHeight); try { instance.option('dataSource', [ @@ -1565,7 +1565,7 @@ module('Integration: Agenda', moduleConfig, () => { instance.option('dataSource', data); await waitAsync(0); - const calculatedRows = agendaWorkspace._rows[0]; + const calculatedRows = agendaWorkspace.rows[0]; assert.equal(calculatedRows.length, 65, 'Rows are OK'); $.each(calculatedRows, function(index, item) { @@ -1606,7 +1606,7 @@ module('Integration: Agenda', moduleConfig, () => { instance.option('dataSource', data); await waitAsync(0); - const calculatedRows = agendaWorkspace._rows; + const calculatedRows = agendaWorkspace.rows; assert.deepEqual(calculatedRows, [[1, 2, 2, 2, 2]], 'Rows are OK'); } finally { endViewDateStub.restore(); @@ -1640,7 +1640,7 @@ module('Integration: Agenda', moduleConfig, () => { instance.option('dataSource', data); await waitAsync(0); - const calculatedRows = agendaWorkspace._rows; + const calculatedRows = agendaWorkspace.rows; assert.deepEqual(calculatedRows, [[0, 1, 1, 1, 0]], 'Rows are OK'); } finally { endViewDateStub.restore(); @@ -1671,7 +1671,7 @@ module('Integration: Agenda', moduleConfig, () => { instance.option('dataSource', data); await waitAsync(0); - const calculatedRows = agendaWorkspace._rows; + const calculatedRows = agendaWorkspace.rows; assert.deepEqual(calculatedRows, [[1, 1, 1, 1, 0]], 'Rows are OK'); } finally { endViewDateStub.restore(); @@ -1709,7 +1709,7 @@ module('Integration: Agenda', moduleConfig, () => { instance.option('dataSource', data); await waitAsync(0); - const calculatedRows = agendaWorkspace._rows; + const calculatedRows = agendaWorkspace.rows; assert.deepEqual(calculatedRows, [[0, 1, 1, 0, 1, 1, 0]], 'Rows are OK'); } finally { endViewDateStub.restore();
'); - setHeight($td, this._getRowHeight(rowSize)); + setHeight($td, this.getRowHeight(rowSize)); if (options.getStartDate) { date = options.getStartDate?.(rowIndex); @@ -395,7 +395,7 @@ class SchedulerAgenda extends WorkSpace { } if (cellTemplateOpt?.render) { - const templateOptions = this._prepareCellTemplateOptions(`${cellDateNumber} ${cellDayName}`, date, i, $td); + const templateOptions = this.prepareCellTemplateOptions(`${cellDateNumber} ${cellDayName}`, date, i, $td); cellTemplates.push(cellTemplateOpt.render.bind(cellTemplateOpt, templateOptions)); } else if (cellDateNumber && cellDayName) { @@ -411,22 +411,22 @@ class SchedulerAgenda extends WorkSpace { } $row.append($td); - this._$rows.push($row); + this.$rows.push($row); } }.bind(this); - for (i = 0; i < this._rows.length; i++) { - each(this._rows[i], fillTableBody); - this._setLastRowClass(); + for (i = 0; i < this.rows.length; i++) { + each(this.rows[i], fillTableBody); + this.setLastRowClass(); } - $(options.container).append($('