@@ -6,51 +6,46 @@ import type {
66 GroupBoundsOffset ,
77} from '@ts/scheduler/types' ;
88import { WORK_SPACE_BORDER_PX } from '@ts/scheduler/workspaces/const' ;
9- import type SchedulerWorkSpace from '@ts/scheduler/workspaces/m_work_space' ;
109
1110import { FIRST_GROUP_CELL_CLASS , LAST_GROUP_CELL_CLASS } from '../classes' ;
1211import type { ResourceLoader } from '../utils/loader/resource_loader' ;
12+ import type { WorkspaceGroupedStrategyConfig } from './types' ;
1313
1414class HorizontalGroupedStrategy {
15- constructor ( private readonly workspace : SchedulerWorkSpace ) { }
15+ constructor ( private readonly config : WorkspaceGroupedStrategyConfig ) { }
1616
1717 prepareCellIndexes (
1818 cellCoordinates : CellPositionData ,
1919 groupIndex : number ,
2020 // eslint-disable-next-line @typescript-eslint/no-unused-vars
2121 inAllDay ?: boolean ,
2222 ) : CellPositionData {
23- const groupByDay = this . workspace . isGroupedByDate ( ) ;
23+ const groupByDay = this . config . isGroupedByDate ( ) ;
2424
2525 if ( ! groupByDay ) {
2626 return {
2727 rowIndex : cellCoordinates . rowIndex ,
28- // @ts -expect-error
29- columnIndex : cellCoordinates . columnIndex + groupIndex * this . workspace . getCellCount ( ) ,
28+ columnIndex : cellCoordinates . columnIndex + groupIndex * this . config . getCellCount ( ) ,
3029 } ;
3130 }
3231 return {
3332 rowIndex : cellCoordinates . rowIndex ,
34- // @ts -expect-error
35- columnIndex : cellCoordinates . columnIndex * this . workspace . getGroupCount ( ) + groupIndex ,
33+ columnIndex : cellCoordinates . columnIndex * this . config . getGroupCount ( ) + groupIndex ,
3634 } ;
3735 }
3836
3937 getGroupIndex ( rowIndex : number , columnIndex : number ) : number {
40- const groupByDay = this . workspace . isGroupedByDate ( ) ;
41- // @ts -expect-error
42- const groupCount = this . workspace . getGroupCount ( ) ;
38+ const groupByDay = this . config . isGroupedByDate ( ) ;
39+ const groupCount = this . config . getGroupCount ( ) ;
4340
4441 if ( groupByDay ) {
4542 return columnIndex % groupCount ;
4643 }
47- // @ts -expect-error
48- return Math . floor ( columnIndex / this . workspace . getCellCount ( ) ) ;
44+ return Math . floor ( columnIndex / this . config . getCellCount ( ) ) ;
4945 }
5046
5147 calculateHeaderCellRepeatCount ( ) : number {
52- // @ts -expect-error
53- return this . workspace . getGroupCount ( ) || 1 ;
48+ return this . config . getGroupCount ( ) || 1 ;
5449 }
5550
5651 insertAllDayRowsIntoDateTable ( ) : boolean {
@@ -60,28 +55,28 @@ class HorizontalGroupedStrategy {
6055 getTotalCellCount ( groupCount : number ) : number {
6156 const effectiveGroupCount = groupCount || 1 ;
6257
63- // @ts -expect-error
64- return this . workspace . getCellCount ( ) * effectiveGroupCount ;
58+ return this . config . getCellCount ( ) * effectiveGroupCount ;
6559 }
6660
6761 getTotalRowCount ( ) : number {
68- // @ts -expect-error
69- return this . workspace . getRowCount ( ) ;
62+ return this . config . getRowCount ( ) ;
7063 }
7164
7265 calculateTimeCellRepeatCount ( ) : number {
7366 return 1 ;
7467 }
7568
7669 getWorkSpaceMinWidth ( ) : number {
77- const workSpaceElementWidth = getBoundingRect ( this . workspace . $element ( ) . get ( 0 ) ) . width ;
70+ const workSpaceElementWidth = getBoundingRect (
71+ this . config . getElement ( ) ,
72+ ) . width ;
7873 return workSpaceElementWidth
79- - this . workspace . getTimePanelWidth ( )
74+ - this . config . getTimePanelWidth ( )
8075 - 2 * WORK_SPACE_BORDER_PX ;
8176 }
8277
8378 getAllDayOffset ( ) : number {
84- return this . workspace . getAllDayHeight ( ) ;
79+ return this . config . getAllDayHeight ( ) ;
8580 }
8681
8782 // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -90,7 +85,7 @@ class HorizontalGroupedStrategy {
9085 }
9186
9287 getLeftOffset ( ) : number {
93- return this . workspace . getTimePanelWidth ( ) ;
88+ return this . config . getTimePanelWidth ( ) ;
9489 }
9590
9691 private createGroupBoundOffset (
@@ -130,11 +125,11 @@ class HorizontalGroupedStrategy {
130125 coordinates : { top : number ; left : number ; groupIndex ?: number } ,
131126 groupedDataMap : { dateTableGroupedMap : CellInfo [ ] [ ] [ ] } ,
132127 ) : GroupBoundsOffset {
133- if ( this . workspace . isGroupedByDate ( ) ) {
128+ if ( this . config . isGroupedByDate ( ) ) {
134129 return this . getGroupedByDateBoundOffset ( $cells , cellWidth ) ;
135130 }
136131
137- const cellIndex = this . workspace . getCellIndexByCoordinates ( coordinates ) ;
132+ const cellIndex = this . config . getCellIndexByCoordinates ( coordinates ) ;
138133 const groupIndex = coordinates . groupIndex ?? Math . floor ( cellIndex / cellCount ) ;
139134
140135 const currentCellGroup = groupedDataMap . dateTableGroupedMap [ groupIndex ] ;
@@ -168,37 +163,33 @@ class HorizontalGroupedStrategy {
168163 }
169164
170165 private getIndicatorOffset ( groupIndex : number ) : number {
171- const groupByDay = this . workspace . isGroupedByDate ( ) ;
166+ const groupByDay = this . config . isGroupedByDate ( ) ;
172167
173168 return groupByDay
174169 ? this . calculateGroupByDateOffset ( groupIndex )
175170 : this . calculateOffset ( groupIndex ) ;
176171 }
177172
178173 private calculateOffset ( groupIndex : number ) : number {
179- // @ts -expect-error
180- const indicatorStartPosition = this . workspace . getIndicatorOffset ( groupIndex ) as number ;
181- // @ts -expect-error
182- const offset = this . workspace . getCellCount ( ) * this . workspace . getCellWidth ( ) * groupIndex ;
174+ const indicatorStartPosition = this . config . getIndicatorOffset ( groupIndex ) ;
175+ const offset = this . config . getCellCount ( ) * this . config . getCellWidth ( ) * groupIndex ;
183176
184177 return indicatorStartPosition + offset ;
185178 }
186179
187180 private calculateGroupByDateOffset ( groupIndex : number ) : number {
188- // @ts -expect-error
189- return this . workspace . getIndicatorOffset ( 0 ) * this . workspace . getGroupCount ( )
190- + this . workspace . getCellWidth ( ) * groupIndex ;
181+ return this . config . getIndicatorOffset ( 0 ) * this . config . getGroupCount ( )
182+ + this . config . getCellWidth ( ) * groupIndex ;
191183 }
192184
193185 getShaderOffset ( i : number , width : number ) : number {
194- // @ts -expect-error
195- const offset = this . workspace . getCellCount ( ) * this . workspace . getCellWidth ( ) * i ;
186+ const offset = this . config . getCellCount ( ) * this . config . getCellWidth ( ) * i ;
196187
197- if ( this . workspace . option ( 'rtlEnabled' ) ) {
188+ if ( this . config . isRtlEnabled ( ) ) {
198189 const containerWidth = getBoundingRect (
199- this . workspace . getScrollable ( ) . $content ( ) . get ( 0 ) ,
190+ this . config . getScrollableContentElement ( ) ,
200191 ) . width ;
201- return containerWidth - offset - this . workspace . getTimePanelWidth ( ) - width ;
192+ return containerWidth - offset - this . config . getTimePanelWidth ( ) - width ;
202193 }
203194
204195 return offset ;
@@ -209,21 +200,21 @@ class HorizontalGroupedStrategy {
209200 }
210201
211202 getShaderHeight ( ) : number {
212- // @ts -expect-error
213- return this . workspace . getIndicationHeight ( ) as number ;
203+ return this . config . getIndicationHeight ( ) ;
214204 }
215205
216206 getShaderMaxHeight ( ) : number {
217- return ( getBoundingRect ( this . workspace . getScrollable ( ) . $content ( ) . get ( 0 ) ) as DOMRect ) . height ;
207+ return ( getBoundingRect (
208+ this . config . getScrollableContentElement ( ) ,
209+ ) as DOMRect ) . height ;
218210 }
219211
220212 getShaderWidth ( ) : number {
221- // @ts -expect-error
222- return this . workspace . getIndicationWidth ( ) as number ;
213+ return this . config . getIndicationWidth ( ) ;
223214 }
224215
225216 getScrollableScrollTop ( allDay : boolean ) : number {
226- return ! allDay ? this . workspace . getScrollable ( ) . scrollTop ( ) : 0 ;
217+ return ! allDay ? this . config . getScrollableScrollTop ( ) : 0 ;
227218 }
228219
229220 // ---------------
@@ -251,15 +242,13 @@ class HorizontalGroupedStrategy {
251242 return `${ cellClass } ${ LAST_GROUP_CELL_CLASS } ` ;
252243 }
253244
254- const groupByDate = this . workspace . isGroupedByDate ( ) ;
245+ const groupByDate = this . config . isGroupedByDate ( ) ;
255246
256247 if ( groupByDate ) {
257- // @ts -expect-error
258- if ( index % this . workspace . getGroupCount ( ) === 0 ) {
248+ if ( index % this . config . getGroupCount ( ) === 0 ) {
259249 return `${ cellClass } ${ LAST_GROUP_CELL_CLASS } ` ;
260250 }
261- // @ts -expect-error
262- } else if ( index % this . workspace . getCellCount ( ) === 0 ) {
251+ } else if ( index % this . config . getCellCount ( ) === 0 ) {
263252 return `${ cellClass } ${ LAST_GROUP_CELL_CLASS } ` ;
264253 }
265254
@@ -275,15 +264,13 @@ class HorizontalGroupedStrategy {
275264 return `${ cellClass } ${ FIRST_GROUP_CELL_CLASS } ` ;
276265 }
277266
278- const groupByDate = this . workspace . isGroupedByDate ( ) ;
267+ const groupByDate = this . config . isGroupedByDate ( ) ;
279268
280269 if ( groupByDate ) {
281- // @ts -expect-error
282- if ( ( index - 1 ) % this . workspace . getGroupCount ( ) === 0 ) {
270+ if ( ( index - 1 ) % this . config . getGroupCount ( ) === 0 ) {
283271 return `${ cellClass } ${ FIRST_GROUP_CELL_CLASS } ` ;
284272 }
285- // @ts -expect-error
286- } else if ( ( index - 1 ) % this . workspace . getCellCount ( ) === 0 ) {
273+ } else if ( ( index - 1 ) % this . config . getCellCount ( ) === 0 ) {
287274 return `${ cellClass } ${ FIRST_GROUP_CELL_CLASS } ` ;
288275 }
289276
0 commit comments