Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ describe('scheduler workspace', () => {
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
});

it(`should clear cache on _cleanView call, view: ${currentView}`, () => {
it(`should clear cache on cleanView call, view: ${currentView}`, () => {
const { workspace } = createWorkspace(WorkSpace, currentView);
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);
Expand Down
106 changes: 53 additions & 53 deletions packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -57,7 +57,7 @@ class SchedulerAgenda extends WorkSpace {
get type() { return VIEWS.AGENDA; }

getStartViewDate() {
return this._startViewDate;
return this.startViewDate;
}

_init() {
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -136,41 +136,41 @@ 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 = $('<table>').attr('aria-hidden', true).addClass(TIME_PANEL_CLASS);
this._$dateTable = $('<table>').attr('aria-hidden', true).addClass(DATE_TABLE_CLASS);
this._$dateTableScrollableContent = $('<div>').addClass('dx-scheduler-date-table-scrollable-content');
this._$dateTableContainer = $('<div>').addClass('dx-scheduler-date-table-container');
}

_initGroupTable() {
private initGroupTable() {
const groups = this.option('groups');
if (groups?.length) {
this._$groupTable = $('<table>').attr('aria-hidden', true).addClass(GROUP_TABLE_CLASS);
}
}

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();
Expand All @@ -179,35 +179,35 @@ class SchedulerAgenda extends WorkSpace {
this._dateTableScrollable.update();
}

_renderNoData() {
this._$noDataContainer = $('<div>').addClass(NODATA_CONTAINER_CLASS)
private renderNoData() {
this.$noDataContainer = $('<div>').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(); }

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;
}

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++) {
Expand All @@ -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);
Expand Down Expand Up @@ -304,19 +304,19 @@ class SchedulerAgenda extends WorkSpace {
};
}

_cleanView() {
protected override cleanView() {
this._$dateTable.empty();
this._$timePanel.empty();

if (this._$groupTable) {
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;
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -386,7 +386,7 @@ class SchedulerAgenda extends WorkSpace {
let cellDayName;
const $row = $('<tr>');
const $td = $('<td>');
setHeight($td, this._getRowHeight(rowSize));
setHeight($td, this.getRowHeight(rowSize));

if (options.getStartDate) {
date = options.getStartDate?.(rowIndex);
Expand All @@ -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) {
Expand All @@ -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($('<tbody>').append(this._$rows));
$(options.container).append($('<tbody>').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);
}
Expand All @@ -440,33 +440,33 @@ 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;
}

let result = 0;

for (let i = 0; i < groupRows.length; i++) {
result += this._getRowHeight(groupRows[i]);
result += this.getRowHeight(groupRows[i]);
}

return result;
Expand All @@ -481,7 +481,7 @@ class SchedulerAgenda extends WorkSpace {
this.getStartViewDate(),
this.resourceManager.groupCount(),
);
this._recalculateAgenda(rows);
this.recalculateAgenda(rows);
}

getAgendaVerticalStepHeight() {
Expand Down Expand Up @@ -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);
}

Expand Down
Loading
Loading