Skip to content

Commit 5ee9e58

Browse files
Scheduler — Replace underscore-prefixed: Workspace group (agenda, timeline, month, indicator) (#32938)
1 parent 9a742dd commit 5ee9e58

File tree

13 files changed

+158
-189
lines changed

13 files changed

+158
-189
lines changed

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
@@ -58,12 +58,12 @@ describe('scheduler workspace', () => {
5858
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
5959
});
6060

61-
it(`should clear cache on _cleanView call, view: ${currentView}`, () => {
61+
it(`should clear cache on cleanView call, view: ${currentView}`, () => {
6262
const workspace = createWorkspace(WorkSpace, currentView);
6363
jest.spyOn(workspace.cache, 'clear');
6464

6565
workspace.cache.memo('test', () => 'value');
66-
workspace._cleanView();
66+
(workspace as any).cleanView();
6767

6868
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
6969
expect(workspace.cache.size).toBe(0);

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

Lines changed: 53 additions & 59 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: any;
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 {
@@ -59,7 +59,7 @@ class SchedulerAgenda extends WorkSpace {
5959
get renderingStrategy() { return (this.invoke as any)('getLayoutManager').getRenderingStrategyInstance(); }
6060

6161
getStartViewDate() {
62-
return this._startViewDate;
62+
return this.startViewDate;
6363
}
6464

6565
_init() {
@@ -84,7 +84,7 @@ class SchedulerAgenda extends WorkSpace {
8484
break;
8585
case 'noDataText':
8686
case 'rowHeight':
87-
this._recalculateAgenda(this._rows);
87+
this.recalculateAgenda(this.rows);
8888
break;
8989
case 'groups':
9090
if (!value?.length) {
@@ -94,7 +94,7 @@ class SchedulerAgenda extends WorkSpace {
9494
this.detachGroupCountClass();
9595
}
9696
} else if (!this._$groupTable) {
97-
this._initGroupTable();
97+
this.initGroupTable();
9898
this._dateTableScrollable.$content().prepend(this._$groupTable);
9999
}
100100
super._optionChanged(args);
@@ -122,7 +122,7 @@ class SchedulerAgenda extends WorkSpace {
122122
return AGENDA_CLASS;
123123
}
124124

125-
_calculateStartViewDate() {
125+
private calculateStartViewDate() {
126126
return agendaUtils.calculateStartViewDate(this.option('currentDate') as any, this.option('startDayHour') as any);
127127
}
128128

@@ -142,42 +142,40 @@ class SchedulerAgenda extends WorkSpace {
142142

143143
protected override updateAllDayVisibility() { return noop(); }
144144

145-
_updateAllDayHeight() { return noop(); }
146-
147145
protected override initWorkSpaceUnits() {
148-
this._initGroupTable();
146+
this.initGroupTable();
149147
this._$timePanel = $('<table>').attr('aria-hidden', true).addClass(TIME_PANEL_CLASS);
150148
this._$dateTable = $('<table>').attr('aria-hidden', true).addClass(DATE_TABLE_CLASS);
151149
this._$dateTableScrollableContent = $('<div>').addClass('dx-scheduler-date-table-scrollable-content');
152150
this._$dateTableContainer = $('<div>').addClass('dx-scheduler-date-table-container');
153151
}
154152

155-
_initGroupTable() {
153+
private initGroupTable() {
156154
const groups = this.option('groups');
157155
if (groups?.length) {
158156
this._$groupTable = $('<table>').attr('aria-hidden', true).addClass(GROUP_TABLE_CLASS);
159157
}
160158
}
161159

162160
protected override renderView() {
163-
this._startViewDate = this._calculateStartViewDate();
164-
this._rows = [];
161+
this.startViewDate = this.calculateStartViewDate();
162+
this.rows = [];
165163
this.initPositionHelper();
166164
}
167165

168-
_recalculateAgenda(rows) {
166+
private recalculateAgenda(rows) {
169167
let cellTemplates = [];
170-
this._cleanView();
168+
this.cleanView();
171169

172-
if (this._rowsIsEmpty(rows)) {
173-
this._renderNoData();
170+
if (this.rowsIsEmpty(rows)) {
171+
this.renderNoData();
174172
return;
175173
}
176-
this._rows = rows;
174+
this.rows = rows;
177175

178176
if (this._$groupTable) {
179177
cellTemplates = this.renderGroupHeader();
180-
this._setGroupHeaderCellsHeight();
178+
this.setGroupHeaderCellsHeight();
181179
}
182180

183181
this.renderTimePanel();
@@ -187,35 +185,35 @@ class SchedulerAgenda extends WorkSpace {
187185
this._dateTableScrollable.update();
188186
}
189187

190-
_renderNoData() {
191-
this._$noDataContainer = $('<div>').addClass(NODATA_CONTAINER_CLASS)
188+
private renderNoData() {
189+
this.$noDataContainer = $('<div>').addClass(NODATA_CONTAINER_CLASS)
192190
.html(this.option('noDataText') as any);
193191

194-
this._dateTableScrollable.$content().append(this._$noDataContainer);
192+
this._dateTableScrollable.$content().append(this.$noDataContainer);
195193
}
196194

197195
protected override setTableSizes() { return noop(); }
198196

199197
protected override toggleHorizontalScrollClass() { return noop(); }
200198

201199
// eslint-disable-next-line @typescript-eslint/no-unused-vars
202-
_createCrossScrollingConfig(argument?: any) { return noop(); }
200+
protected override createCrossScrollingConfig(argument?: any) { return noop(); }
203201

204-
_setGroupHeaderCellsHeight() {
202+
private setGroupHeaderCellsHeight() {
205203
const $cells = this.getGroupHeaderCells().filter((_, element) => !element.getAttribute('rowSpan'));
206-
const rows = this._removeEmptyRows(this._rows);
204+
const rows = this.removeEmptyRows(this.rows);
207205

208206
if (!rows.length) {
209207
return;
210208
}
211209

212210
for (let i = 0; i < $cells.length; i++) {
213211
const $cellContent = $cells.eq(i).find('.dx-scheduler-group-header-content');
214-
setOuterHeight($cellContent, this._getGroupRowHeight(rows[i]));
212+
setOuterHeight($cellContent, this.getGroupRowHeight(rows[i]));
215213
}
216214
}
217215

218-
_rowsIsEmpty(rows) {
216+
private rowsIsEmpty(rows) {
219217
let result = true;
220218

221219
for (let i = 0; i < rows.length; i++) {
@@ -237,7 +235,7 @@ class SchedulerAgenda extends WorkSpace {
237235
(this.$element() as any).addClass(className);
238236
}
239237

240-
_removeEmptyRows(rows) {
238+
private removeEmptyRows(rows) {
241239
const result: any[] = [];
242240
const isEmpty = function (data) {
243241
return !data.some((value) => value > 0);
@@ -312,19 +310,19 @@ class SchedulerAgenda extends WorkSpace {
312310
};
313311
}
314312

315-
_cleanView() {
313+
protected override cleanView() {
316314
this._$dateTable.empty();
317315
this._$timePanel.empty();
318316

319317
if (this._$groupTable) {
320318
this._$groupTable.empty();
321319
}
322320

323-
if (this._$noDataContainer) {
324-
this._$noDataContainer.empty();
325-
this._$noDataContainer.remove();
321+
if (this.$noDataContainer) {
322+
this.$noDataContainer.empty();
323+
this.$noDataContainer.remove();
326324

327-
delete this._$noDataContainer;
325+
delete this.$noDataContainer;
328326
}
329327
}
330328

@@ -356,13 +354,11 @@ class SchedulerAgenda extends WorkSpace {
356354

357355
protected override attachEvents() { return noop(); }
358356

359-
_cleanCellDataCache() { return noop(); }
360-
361357
isIndicationAvailable() {
362358
return false;
363359
}
364360

365-
_prepareCellTemplateOptions(text, date, rowIndex, $cell) {
361+
private prepareCellTemplateOptions(text, date, rowIndex, $cell) {
366362
const leaf = this.resourceManager.groupsLeafs[rowIndex];
367363
const groups = leaf?.grouped ?? {};
368364
const groupIndex = leaf?.groupIndex;
@@ -384,7 +380,7 @@ class SchedulerAgenda extends WorkSpace {
384380
const cellTemplates: any[] = [];
385381
const cellTemplateOpt = options.cellTemplate;
386382

387-
this._$rows = [];
383+
this.$rows = [];
388384
let i;
389385

390386
const fillTableBody = function (rowIndex, rowSize) {
@@ -394,7 +390,7 @@ class SchedulerAgenda extends WorkSpace {
394390
let cellDayName;
395391
const $row = $('<tr>');
396392
const $td = $('<td>');
397-
setHeight($td, this._getRowHeight(rowSize));
393+
setHeight($td, this.getRowHeight(rowSize));
398394

399395
if (options.getStartDate) {
400396
date = options.getStartDate?.(rowIndex);
@@ -403,7 +399,7 @@ class SchedulerAgenda extends WorkSpace {
403399
}
404400

405401
if (cellTemplateOpt?.render) {
406-
const templateOptions = this._prepareCellTemplateOptions(`${cellDateNumber} ${cellDayName}`, date, i, $td);
402+
const templateOptions = this.prepareCellTemplateOptions(`${cellDateNumber} ${cellDayName}`, date, i, $td);
407403

408404
cellTemplates.push(cellTemplateOpt.render.bind(cellTemplateOpt, templateOptions));
409405
} else if (cellDateNumber && cellDayName) {
@@ -419,22 +415,22 @@ class SchedulerAgenda extends WorkSpace {
419415
}
420416

421417
$row.append($td);
422-
this._$rows.push($row);
418+
this.$rows.push($row);
423419
}
424420
}.bind(this);
425421

426-
for (i = 0; i < this._rows.length; i++) {
427-
each(this._rows[i], fillTableBody);
428-
this._setLastRowClass();
422+
for (i = 0; i < this.rows.length; i++) {
423+
each(this.rows[i], fillTableBody);
424+
this.setLastRowClass();
429425
}
430426

431-
$(options.container).append($('<tbody>').append(this._$rows));
427+
$(options.container).append($('<tbody>').append(this.$rows));
432428
this.applyCellTemplates(cellTemplates);
433429
}
434430

435-
_setLastRowClass() {
436-
if (this._rows.length > 1 && this._$rows.length) {
437-
const $lastRow = this._$rows[this._$rows.length - 1];
431+
private setLastRowClass() {
432+
if (this.rows.length > 1 && this.$rows.length) {
433+
const $lastRow = this.$rows[this.$rows.length - 1];
438434

439435
$lastRow.addClass(LAST_ROW_CLASS);
440436
}
@@ -448,39 +444,39 @@ class SchedulerAgenda extends WorkSpace {
448444
rowClass: TIME_PANEL_ROW_CLASS,
449445
cellClass: TIME_PANEL_CELL_CLASS,
450446
cellTemplate: this.option('dateCellTemplate'),
451-
getStartDate: this._getTimePanelStartDate.bind(this),
447+
getStartDate: this.getTimePanelStartDate.bind(this),
452448
});
453449
}
454450

455-
_getTimePanelStartDate(rowIndex) {
451+
private getTimePanelStartDate(rowIndex) {
456452
const current = new Date(this.option('currentDate') as any);
457453
const cellDate = new Date(current.setDate(current.getDate() + rowIndex));
458454

459455
return cellDate;
460456
}
461457

462-
_getRowHeight(rowSize) {
458+
private getRowHeight(rowSize) {
463459
const baseHeight = this.option('rowHeight') as any;
464460
const innerOffset = (rowSize - 1) * INNER_CELL_MARGIN;
465461

466462
return rowSize ? (baseHeight * rowSize) + innerOffset + OUTER_CELL_MARGIN : 0;
467463
}
468464

469-
_getGroupRowHeight(groupRows) {
465+
private getGroupRowHeight(groupRows) {
470466
if (!groupRows) {
471467
return;
472468
}
473469

474470
let result = 0;
475471

476472
for (let i = 0; i < groupRows.length; i++) {
477-
result += this._getRowHeight(groupRows[i]);
473+
result += this.getRowHeight(groupRows[i]);
478474
}
479475

480476
return result;
481477
}
482478

483-
_calculateRows(appointments?: SafeAppointment[]) {
479+
private calculateRows(appointments?: SafeAppointment[]) {
484480
return this.renderingStrategy.calculateRows(
485481
appointments,
486482
this.option('agendaDuration'),
@@ -493,8 +489,8 @@ class SchedulerAgenda extends WorkSpace {
493489

494490
this.renderView();
495491

496-
const rows = this._calculateRows(appointments);
497-
this._recalculateAgenda(rows);
492+
const rows = this.calculateRows(appointments);
493+
this.recalculateAgenda(rows);
498494
}
499495

500496
getAgendaVerticalStepHeight() {
@@ -549,9 +545,7 @@ class SchedulerAgenda extends WorkSpace {
549545

550546
renovatedRenderSupported() { return false; }
551547

552-
_setSelectedCellsByCellData() {}
553-
554-
_getIntervalDuration() {
548+
protected override getTotalViewDuration() {
555549
return dateUtils.dateToMilliseconds('day') * (this.option('intervalCount') as any);
556550
}
557551

0 commit comments

Comments
 (0)