Skip to content

Commit 9682398

Browse files
Scheduler — Replace underscore-prefixed: Workspace group (agenda, timeline, month, indicator) (#32938)
1 parent 83a014e commit 9682398

13 files changed

Lines changed: 155 additions & 186 deletions

File tree

packages/devextreme/js/__internal/scheduler/__tests__/__mock__/m_mock_scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const setupSchedulerTestEnvironment = ({
1919
}: SetupSchedulerTestEnvironmentOptions = {}): void => {
2020
jest.spyOn(logger, 'warn').mockImplementation(() => {});
2121
DOMComponent.prototype._isVisible = jest.fn((): boolean => true);
22-
SchedulerWorkSpace.prototype._createCrossScrollingConfig = (): {
22+
(SchedulerWorkSpace.prototype as any).createCrossScrollingConfig = (): {
2323
direction: string;
2424
onScroll: jest.Mock;
2525
onEnd: jest.Mock;

packages/devextreme/js/__internal/scheduler/__tests__/workspace.base.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ describe('scheduler workspace', () => {
8989
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
9090
});
9191

92-
it(`should clear cache on _cleanView call, view: ${currentView}`, () => {
92+
it(`should clear cache on cleanView call, view: ${currentView}`, () => {
9393
const { workspace } = createWorkspace(WorkSpace, currentView);
9494
jest.spyOn(workspace.cache, 'clear');
9595

9696
workspace.cache.memo('test', () => 'value');
97-
workspace._cleanView();
97+
(workspace as any).cleanView();
9898

9999
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
100100
expect(workspace.cache.size).toBe(0);

packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ const INNER_CELL_MARGIN = 5;
4141
const OUTER_CELL_MARGIN = 20;
4242

4343
class SchedulerAgenda extends WorkSpace {
44-
_startViewDate: any;
44+
private startViewDate: any;
4545

46-
_rows: number[][] = [];
46+
private rows: number[][] = [];
4747

48-
_$rows: any;
48+
private $rows: any;
4949

50-
_$noDataContainer: any;
50+
private $noDataContainer: any;
5151

5252
// eslint-disable-next-line class-methods-use-this
5353
protected _activeStateUnit(): string {
@@ -57,7 +57,7 @@ class SchedulerAgenda extends WorkSpace {
5757
get type() { return VIEWS.AGENDA; }
5858

5959
getStartViewDate() {
60-
return this._startViewDate;
60+
return this.startViewDate;
6161
}
6262

6363
_init() {
@@ -82,7 +82,7 @@ class SchedulerAgenda extends WorkSpace {
8282
break;
8383
case 'noDataText':
8484
case 'rowHeight':
85-
this._recalculateAgenda(this._rows);
85+
this.recalculateAgenda(this.rows);
8686
break;
8787
case 'groups':
8888
if (!value?.length) {
@@ -92,7 +92,7 @@ class SchedulerAgenda extends WorkSpace {
9292
this.detachGroupCountClass();
9393
}
9494
} else if (!this._$groupTable) {
95-
this._initGroupTable();
95+
this.initGroupTable();
9696
this._dateTableScrollable.$content().prepend(this._$groupTable);
9797
}
9898
super._optionChanged(args);
@@ -136,41 +136,39 @@ class SchedulerAgenda extends WorkSpace {
136136

137137
protected override updateAllDayVisibility() { return noop(); }
138138

139-
_updateAllDayHeight() { return noop(); }
140-
141139
protected override initWorkSpaceUnits() {
142-
this._initGroupTable();
140+
this.initGroupTable();
143141
this._$timePanel = $('<table>').attr('aria-hidden', true).addClass(TIME_PANEL_CLASS);
144142
this._$dateTable = $('<table>').attr('aria-hidden', true).addClass(DATE_TABLE_CLASS);
145143
this._$dateTableScrollableContent = $('<div>').addClass('dx-scheduler-date-table-scrollable-content');
146144
this._$dateTableContainer = $('<div>').addClass('dx-scheduler-date-table-container');
147145
}
148146

149-
_initGroupTable() {
147+
private initGroupTable() {
150148
const groups = this.option('groups');
151149
if (groups?.length) {
152150
this._$groupTable = $('<table>').attr('aria-hidden', true).addClass(GROUP_TABLE_CLASS);
153151
}
154152
}
155153

156154
protected override renderView() {
157-
this._startViewDate = agendaUtils.calculateStartViewDate(this.option('currentDate') as any, this.option('startDayHour') as any);
158-
this._rows = [];
155+
this.startViewDate = agendaUtils.calculateStartViewDate(this.option('currentDate') as any, this.option('startDayHour') as any);
156+
this.rows = [];
159157
}
160158

161-
_recalculateAgenda(rows) {
159+
private recalculateAgenda(rows) {
162160
let cellTemplates = [];
163-
this._cleanView();
161+
this.cleanView();
164162

165-
if (this._rowsIsEmpty(rows)) {
166-
this._renderNoData();
163+
if (this.rowsIsEmpty(rows)) {
164+
this.renderNoData();
167165
return;
168166
}
169-
this._rows = rows;
167+
this.rows = rows;
170168

171169
if (this._$groupTable) {
172170
cellTemplates = this.renderGroupHeader();
173-
this._setGroupHeaderCellsHeight();
171+
this.setGroupHeaderCellsHeight();
174172
}
175173

176174
this.renderTimePanel();
@@ -179,35 +177,35 @@ class SchedulerAgenda extends WorkSpace {
179177
this._dateTableScrollable.update();
180178
}
181179

182-
_renderNoData() {
183-
this._$noDataContainer = $('<div>').addClass(NODATA_CONTAINER_CLASS)
180+
private renderNoData() {
181+
this.$noDataContainer = $('<div>').addClass(NODATA_CONTAINER_CLASS)
184182
.html(this.option('noDataText') as any);
185183

186-
this._dateTableScrollable.$content().append(this._$noDataContainer);
184+
this._dateTableScrollable.$content().append(this.$noDataContainer);
187185
}
188186

189187
protected override setTableSizes() { return noop(); }
190188

191189
protected override toggleHorizontalScrollClass() { return noop(); }
192190

193191
// eslint-disable-next-line @typescript-eslint/no-unused-vars
194-
_createCrossScrollingConfig(argument?: any) { return noop(); }
192+
protected override createCrossScrollingConfig(argument?: any) { return noop(); }
195193

196-
_setGroupHeaderCellsHeight() {
194+
private setGroupHeaderCellsHeight() {
197195
const $cells = this.getGroupHeaderCells().filter((_, element) => !element.getAttribute('rowSpan'));
198-
const rows = this._removeEmptyRows(this._rows);
196+
const rows = this.removeEmptyRows(this.rows);
199197

200198
if (!rows.length) {
201199
return;
202200
}
203201

204202
for (let i = 0; i < $cells.length; i++) {
205203
const $cellContent = $cells.eq(i).find('.dx-scheduler-group-header-content');
206-
setOuterHeight($cellContent, this._getGroupRowHeight(rows[i]));
204+
setOuterHeight($cellContent, this.getGroupRowHeight(rows[i]));
207205
}
208206
}
209207

210-
_rowsIsEmpty(rows) {
208+
private rowsIsEmpty(rows) {
211209
let result = true;
212210

213211
for (let i = 0; i < rows.length; i++) {
@@ -229,7 +227,7 @@ class SchedulerAgenda extends WorkSpace {
229227
(this.$element() as any).addClass(className);
230228
}
231229

232-
_removeEmptyRows(rows) {
230+
private removeEmptyRows(rows) {
233231
const result: any[] = [];
234232
const isEmpty = function (data) {
235233
return !data.some((value) => value > 0);
@@ -304,19 +302,19 @@ class SchedulerAgenda extends WorkSpace {
304302
};
305303
}
306304

307-
_cleanView() {
305+
protected override cleanView() {
308306
this._$dateTable.empty();
309307
this._$timePanel.empty();
310308

311309
if (this._$groupTable) {
312310
this._$groupTable.empty();
313311
}
314312

315-
if (this._$noDataContainer) {
316-
this._$noDataContainer.empty();
317-
this._$noDataContainer.remove();
313+
if (this.$noDataContainer) {
314+
this.$noDataContainer.empty();
315+
this.$noDataContainer.remove();
318316

319-
delete this._$noDataContainer;
317+
delete this.$noDataContainer;
320318
}
321319
}
322320

@@ -348,13 +346,11 @@ class SchedulerAgenda extends WorkSpace {
348346

349347
protected override attachEvents() { return noop(); }
350348

351-
_cleanCellDataCache() { return noop(); }
352-
353349
isIndicationAvailable() {
354350
return false;
355351
}
356352

357-
_prepareCellTemplateOptions(text, date, rowIndex, $cell) {
353+
private prepareCellTemplateOptions(text, date, rowIndex, $cell) {
358354
const leaf = this.resourceManager.groupsLeafs[rowIndex];
359355
const groups = leaf?.grouped ?? {};
360356
const groupIndex = leaf?.groupIndex;
@@ -376,7 +372,7 @@ class SchedulerAgenda extends WorkSpace {
376372
const cellTemplates: any[] = [];
377373
const cellTemplateOpt = options.cellTemplate;
378374

379-
this._$rows = [];
375+
this.$rows = [];
380376
let i;
381377

382378
const fillTableBody = function (rowIndex, rowSize) {
@@ -386,7 +382,7 @@ class SchedulerAgenda extends WorkSpace {
386382
let cellDayName;
387383
const $row = $('<tr>');
388384
const $td = $('<td>');
389-
setHeight($td, this._getRowHeight(rowSize));
385+
setHeight($td, this.getRowHeight(rowSize));
390386

391387
if (options.getStartDate) {
392388
date = options.getStartDate?.(rowIndex);
@@ -395,7 +391,7 @@ class SchedulerAgenda extends WorkSpace {
395391
}
396392

397393
if (cellTemplateOpt?.render) {
398-
const templateOptions = this._prepareCellTemplateOptions(`${cellDateNumber} ${cellDayName}`, date, i, $td);
394+
const templateOptions = this.prepareCellTemplateOptions(`${cellDateNumber} ${cellDayName}`, date, i, $td);
399395

400396
cellTemplates.push(cellTemplateOpt.render.bind(cellTemplateOpt, templateOptions));
401397
} else if (cellDateNumber && cellDayName) {
@@ -411,22 +407,22 @@ class SchedulerAgenda extends WorkSpace {
411407
}
412408

413409
$row.append($td);
414-
this._$rows.push($row);
410+
this.$rows.push($row);
415411
}
416412
}.bind(this);
417413

418-
for (i = 0; i < this._rows.length; i++) {
419-
each(this._rows[i], fillTableBody);
420-
this._setLastRowClass();
414+
for (i = 0; i < this.rows.length; i++) {
415+
each(this.rows[i], fillTableBody);
416+
this.setLastRowClass();
421417
}
422418

423-
$(options.container).append($('<tbody>').append(this._$rows));
419+
$(options.container).append($('<tbody>').append(this.$rows));
424420
this.applyCellTemplates(cellTemplates);
425421
}
426422

427-
_setLastRowClass() {
428-
if (this._rows.length > 1 && this._$rows.length) {
429-
const $lastRow = this._$rows[this._$rows.length - 1];
423+
private setLastRowClass() {
424+
if (this.rows.length > 1 && this.$rows.length) {
425+
const $lastRow = this.$rows[this.$rows.length - 1];
430426

431427
$lastRow.addClass(LAST_ROW_CLASS);
432428
}
@@ -440,33 +436,33 @@ class SchedulerAgenda extends WorkSpace {
440436
rowClass: TIME_PANEL_ROW_CLASS,
441437
cellClass: TIME_PANEL_CELL_CLASS,
442438
cellTemplate: this.option('dateCellTemplate'),
443-
getStartDate: this._getTimePanelStartDate.bind(this),
439+
getStartDate: this.getTimePanelStartDate.bind(this),
444440
});
445441
}
446442

447-
_getTimePanelStartDate(rowIndex) {
443+
private getTimePanelStartDate(rowIndex) {
448444
const current = new Date(this.option('currentDate') as any);
449445
const cellDate = new Date(current.setDate(current.getDate() + rowIndex));
450446

451447
return cellDate;
452448
}
453449

454-
_getRowHeight(rowSize) {
450+
private getRowHeight(rowSize) {
455451
const baseHeight = this.option('rowHeight') as any;
456452
const innerOffset = (rowSize - 1) * INNER_CELL_MARGIN;
457453

458454
return rowSize ? (baseHeight * rowSize) + innerOffset + OUTER_CELL_MARGIN : 0;
459455
}
460456

461-
_getGroupRowHeight(groupRows) {
457+
private getGroupRowHeight(groupRows) {
462458
if (!groupRows) {
463459
return;
464460
}
465461

466462
let result = 0;
467463

468464
for (let i = 0; i < groupRows.length; i++) {
469-
result += this._getRowHeight(groupRows[i]);
465+
result += this.getRowHeight(groupRows[i]);
470466
}
471467

472468
return result;
@@ -481,7 +477,7 @@ class SchedulerAgenda extends WorkSpace {
481477
this.getStartViewDate(),
482478
this.resourceManager.groupCount(),
483479
);
484-
this._recalculateAgenda(rows);
480+
this.recalculateAgenda(rows);
485481
}
486482

487483
getAgendaVerticalStepHeight() {
@@ -536,9 +532,7 @@ class SchedulerAgenda extends WorkSpace {
536532

537533
renovatedRenderSupported() { return false; }
538534

539-
_setSelectedCellsByCellData() {}
540-
541-
_getIntervalDuration() {
535+
protected override getTotalViewDuration() {
542536
return dateUtils.dateToMilliseconds('day') * (this.option('intervalCount') as any);
543537
}
544538

0 commit comments

Comments
 (0)