Skip to content

Commit d3f9ff4

Browse files
committed
refactor: make isHorizontalGroupedWorkSpace
getCellCount getGroupCount protected
1 parent ebb777c commit d3f9ff4

5 files changed

Lines changed: 36 additions & 24 deletions

File tree

packages/devextreme/js/__internal/scheduler/shaders/current_time_shader.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class CurrentTimeShader {
1515
constructor(protected workSpace: SchedulerWorkSpace) {
1616
}
1717

18-
render(): void {
18+
render(isHorizontalGroupedWorkSpace: boolean, groupCount: number, cellCount: number): void {
1919
this.initShaderElements();
2020

21-
this.renderShader();
21+
this.renderShader(isHorizontalGroupedWorkSpace, groupCount, cellCount);
2222

2323
this.shader.forEach((shader) => {
2424
this.$container.append(shader);
@@ -31,7 +31,8 @@ class CurrentTimeShader {
3131
this.shader.push(this.$shader);
3232
}
3333

34-
renderShader(): void {}
34+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
35+
renderShader(isHorizontalGroupedWorkSpace: boolean, groupCount: number, cellCount: number):void {}
3536

3637
createShader(): dxElementWrapper {
3738
return $('<div>').addClass(DATE_TIME_SHADER_CLASS);

packages/devextreme/js/__internal/scheduler/shaders/current_time_shader_horizontal.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ import { setWidth } from '@js/core/utils/size';
55
import CurrentTimeShader from './current_time_shader';
66

77
class HorizontalCurrentTimeShader extends CurrentTimeShader {
8-
renderShader(): void {
9-
const groupCount = this.workSpace.isHorizontalGroupedWorkSpace()
10-
? this.workSpace.getGroupCount()
11-
: 1;
8+
renderShader(isHorizontalGroupedWorkSpace: boolean, groupCount: number, cellCount: number): void {
9+
const effectiveGroupCount = isHorizontalGroupedWorkSpace ? groupCount : 1;
1210

13-
for (let i = 0; i < groupCount; i += 1) {
11+
for (let i = 0; i < effectiveGroupCount; i += 1) {
1412
const isFirstShader = i === 0;
1513
const $shader = isFirstShader ? this.$shader : this.createShader();
1614

1715
if (this.workSpace.isGroupedByDate()) {
18-
this.customizeGroupedByDateShader($shader, i);
16+
this.customizeGroupedByDateShader($shader, i, groupCount, cellCount);
1917
} else {
20-
this.customizeShader($shader, i);
18+
this.customizeShader($shader, i, cellCount);
2119
}
2220

2321
if (!isFirstShader) {
@@ -26,15 +24,19 @@ class HorizontalCurrentTimeShader extends CurrentTimeShader {
2624
}
2725
}
2826

29-
private customizeShader($shader: dxElementWrapper, groupIndex: number): void {
27+
private customizeShader(
28+
$shader: dxElementWrapper,
29+
groupIndex: number,
30+
dateTableCellCount: number,
31+
): void {
3032
// @ts-expect-error
3133
const shaderWidth = this.workSpace.getIndicationWidth() as number;
3234

3335
this.applyShaderWidth($shader, shaderWidth);
3436

3537
if (groupIndex >= 1) {
3638
const { workSpace } = this;
37-
const indicationWidth = workSpace.getCellCount() * workSpace.getCellWidth();
39+
const indicationWidth = dateTableCellCount * workSpace.getCellWidth();
3840
$shader.css('left', indicationWidth);
3941
} else {
4042
$shader.css('left', 0);
@@ -48,11 +50,16 @@ class HorizontalCurrentTimeShader extends CurrentTimeShader {
4850
}
4951
}
5052

51-
private customizeGroupedByDateShader($shader: dxElementWrapper, groupIndex: number): void {
53+
private customizeGroupedByDateShader(
54+
$shader: dxElementWrapper,
55+
groupIndex: number,
56+
shaderGroupCount: number,
57+
dateTableCellCount: number,
58+
): void {
5259
// @ts-expect-error
53-
const cellCount = this.workSpace.getIndicationCellCount() as number;
54-
const integerPart = Math.floor(cellCount);
55-
const fractionPart = cellCount - integerPart;
60+
const indicationCellCount = this.workSpace.getIndicationCellCount() as number;
61+
const integerPart = Math.floor(indicationCellCount);
62+
const fractionPart = indicationCellCount - integerPart;
5663
const isFirstShaderPart = groupIndex === 0;
5764
const { workSpace } = this;
5865
const shaderWidth = isFirstShaderPart
@@ -64,9 +71,9 @@ class HorizontalCurrentTimeShader extends CurrentTimeShader {
6471
this.applyShaderWidth($shader, shaderWidth);
6572

6673
if (isFirstShaderPart) {
67-
shaderLeft = workSpace.getCellCount() * workSpace.getCellWidth() * groupIndex;
74+
shaderLeft = dateTableCellCount * workSpace.getCellWidth() * groupIndex;
6875
} else {
69-
shaderLeft = workSpace.getCellWidth() * integerPart * workSpace.getGroupCount()
76+
shaderLeft = workSpace.getCellWidth() * integerPart * shaderGroupCount
7077
+ groupIndex * workSpace.getCellWidth();
7178
}
7279

packages/devextreme/js/__internal/scheduler/shaders/current_time_shader_vertical.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class VerticalCurrentTimeShader extends CurrentTimeShader {
1515

1616
private $allDayIndicator!: dxElementWrapper;
1717

18-
renderShader(): void {
18+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
19+
renderShader(isHorizontalGroupedWorkSpace: boolean, groupCount: number, cellCount: number): void {
1920
let shaderHeight = this.getShaderHeight();
2021
const maxHeight = this.getShaderMaxHeight();
2122
const isSolidShader = shaderHeight > maxHeight;
@@ -25,7 +26,6 @@ class VerticalCurrentTimeShader extends CurrentTimeShader {
2526
}
2627

2728
setHeight(this.$shader, shaderHeight);
28-
const groupCount = this.workSpace.getGroupCount() || 1;
2929

3030
if (this.workSpace.isGroupedByDate()) {
3131
this.renderGroupedByDateShaderParts(groupCount, shaderHeight, maxHeight, isSolidShader);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
635635
return Boolean(this.option('groups')?.length) && this.option('groupOrientation') === 'vertical';
636636
}
637637

638-
isHorizontalGroupedWorkSpace() {
638+
protected isHorizontalGroupedWorkSpace() {
639639
return Boolean(this.option('groups')?.length) && this.option('groupOrientation') === 'horizontal';
640640
}
641641

@@ -821,7 +821,7 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
821821
});
822822
}
823823

824-
getCellCount() {
824+
protected getCellCount() {
825825
return this.viewDataProvider.getCellCount({
826826
intervalCount: this.option('intervalCount'),
827827
currentDate: this.option('currentDate'),
@@ -1163,7 +1163,7 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
11631163
);
11641164
}
11651165

1166-
getGroupCount() {
1166+
protected getGroupCount() {
11671167
return this.resourceManager.groupCount();
11681168
}
11691169

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ class SchedulerWorkSpaceIndicator extends SchedulerWorkSpace {
287287
}
288288

289289
if (this.option('shadeUntilCurrentTime')) {
290-
this.shader.render();
290+
this.shader.render(
291+
this.isHorizontalGroupedWorkSpace(),
292+
this.getGroupCount() || 1,
293+
this.getCellCount(),
294+
);
291295
}
292296

293297
if (!this.isIndicationOnView() || !this.isIndicatorVisible()) {

0 commit comments

Comments
 (0)