@@ -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 { GroupedStrategyConfig } from './work_space_grouped_strategy_config' ;
1313
1414class HorizontalGroupedStrategy {
15- constructor ( private readonly workspace : SchedulerWorkSpace ) { }
15+ constructor ( private readonly config : GroupedStrategyConfig ) { }
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,26 @@ 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 ( this . config . getElement ( ) ) . width ;
7871 return workSpaceElementWidth
79- - this . workspace . getTimePanelWidth ( )
72+ - this . config . getTimePanelWidth ( )
8073 - 2 * WORK_SPACE_BORDER_PX ;
8174 }
8275
8376 getAllDayOffset ( ) : number {
84- return this . workspace . getAllDayHeight ( ) ;
77+ return this . config . getAllDayHeight ( ) ;
8578 }
8679
8780 // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -90,7 +83,7 @@ class HorizontalGroupedStrategy {
9083 }
9184
9285 getLeftOffset ( ) : number {
93- return this . workspace . getTimePanelWidth ( ) ;
86+ return this . config . getTimePanelWidth ( ) ;
9487 }
9588
9689 private createGroupBoundOffset (
@@ -130,11 +123,11 @@ class HorizontalGroupedStrategy {
130123 coordinates : { top : number ; left : number ; groupIndex ?: number } ,
131124 groupedDataMap : { dateTableGroupedMap : CellInfo [ ] [ ] [ ] } ,
132125 ) : GroupBoundsOffset {
133- if ( this . workspace . isGroupedByDate ( ) ) {
126+ if ( this . config . isGroupedByDate ( ) ) {
134127 return this . getGroupedByDateBoundOffset ( $cells , cellWidth ) ;
135128 }
136129
137- const cellIndex = this . workspace . getCellIndexByCoordinates ( coordinates ) ;
130+ const cellIndex = this . config . getCellIndexByCoordinates ( coordinates ) ;
138131 const groupIndex = coordinates . groupIndex ?? Math . floor ( cellIndex / cellCount ) ;
139132
140133 const currentCellGroup = groupedDataMap . dateTableGroupedMap [ groupIndex ] ;
@@ -168,37 +161,33 @@ class HorizontalGroupedStrategy {
168161 }
169162
170163 private getIndicatorOffset ( groupIndex : number ) : number {
171- const groupByDay = this . workspace . isGroupedByDate ( ) ;
164+ const groupByDay = this . config . isGroupedByDate ( ) ;
172165
173166 return groupByDay
174167 ? this . calculateGroupByDateOffset ( groupIndex )
175168 : this . calculateOffset ( groupIndex ) ;
176169 }
177170
178171 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 ;
172+ const indicatorStartPosition = this . config . getIndicatorOffset ( ) ;
173+ const offset = this . config . getCellCount ( ) * this . config . getCellWidth ( ) * groupIndex ;
183174
184175 return indicatorStartPosition + offset ;
185176 }
186177
187178 private calculateGroupByDateOffset ( groupIndex : number ) : number {
188- // @ts -expect-error
189- return this . workspace . getIndicatorOffset ( 0 ) * this . workspace . getGroupCount ( )
190- + this . workspace . getCellWidth ( ) * groupIndex ;
179+ return this . config . getIndicatorOffset ( ) * this . config . getGroupCount ( )
180+ + this . config . getCellWidth ( ) * groupIndex ;
191181 }
192182
193183 getShaderOffset ( i : number , width : number ) : number {
194- // @ts -expect-error
195- const offset = this . workspace . getCellCount ( ) * this . workspace . getCellWidth ( ) * i ;
184+ const offset = this . config . getCellCount ( ) * this . config . getCellWidth ( ) * i ;
196185
197- if ( this . workspace . option ( ' rtlEnabled' ) ) {
186+ if ( this . config . rtlEnabled ( ) ) {
198187 const containerWidth = getBoundingRect (
199- this . workspace . getScrollable ( ) . $content ( ) . get ( 0 ) ,
188+ this . config . getScrollableContentElement ( ) ,
200189 ) . width ;
201- return containerWidth - offset - this . workspace . getTimePanelWidth ( ) - width ;
190+ return containerWidth - offset - this . config . getTimePanelWidth ( ) - width ;
202191 }
203192
204193 return offset ;
@@ -209,21 +198,19 @@ class HorizontalGroupedStrategy {
209198 }
210199
211200 getShaderHeight ( ) : number {
212- // @ts -expect-error
213- return this . workspace . getIndicationHeight ( ) as number ;
201+ return this . config . getIndicationHeight ( ) ;
214202 }
215203
216204 getShaderMaxHeight ( ) : number {
217- return ( getBoundingRect ( this . workspace . getScrollable ( ) . $content ( ) . get ( 0 ) ) as DOMRect ) . height ;
205+ return ( getBoundingRect ( this . config . getScrollableContentElement ( ) ) as DOMRect ) . height ;
218206 }
219207
220208 getShaderWidth ( ) : number {
221- // @ts -expect-error
222- return this . workspace . getIndicationWidth ( ) as number ;
209+ return this . config . getIndicationWidth ( ) ;
223210 }
224211
225212 getScrollableScrollTop ( allDay : boolean ) : number {
226- return ! allDay ? this . workspace . getScrollable ( ) . scrollTop ( ) : 0 ;
213+ return ! allDay ? this . config . getScrollableScrollTop ( ) : 0 ;
227214 }
228215
229216 // ---------------
@@ -251,15 +238,13 @@ class HorizontalGroupedStrategy {
251238 return `${ cellClass } ${ LAST_GROUP_CELL_CLASS } ` ;
252239 }
253240
254- const groupByDate = this . workspace . isGroupedByDate ( ) ;
241+ const groupByDate = this . config . isGroupedByDate ( ) ;
255242
256243 if ( groupByDate ) {
257- // @ts -expect-error
258- if ( index % this . workspace . getGroupCount ( ) === 0 ) {
244+ if ( index % this . config . getGroupCount ( ) === 0 ) {
259245 return `${ cellClass } ${ LAST_GROUP_CELL_CLASS } ` ;
260246 }
261- // @ts -expect-error
262- } else if ( index % this . workspace . getCellCount ( ) === 0 ) {
247+ } else if ( index % this . config . getCellCount ( ) === 0 ) {
263248 return `${ cellClass } ${ LAST_GROUP_CELL_CLASS } ` ;
264249 }
265250
@@ -275,15 +260,13 @@ class HorizontalGroupedStrategy {
275260 return `${ cellClass } ${ FIRST_GROUP_CELL_CLASS } ` ;
276261 }
277262
278- const groupByDate = this . workspace . isGroupedByDate ( ) ;
263+ const groupByDate = this . config . isGroupedByDate ( ) ;
279264
280265 if ( groupByDate ) {
281- // @ts -expect-error
282- if ( ( index - 1 ) % this . workspace . getGroupCount ( ) === 0 ) {
266+ if ( ( index - 1 ) % this . config . getGroupCount ( ) === 0 ) {
283267 return `${ cellClass } ${ FIRST_GROUP_CELL_CLASS } ` ;
284268 }
285- // @ts -expect-error
286- } else if ( ( index - 1 ) % this . workspace . getCellCount ( ) === 0 ) {
269+ } else if ( ( index - 1 ) % this . config . getCellCount ( ) === 0 ) {
287270 return `${ cellClass } ${ FIRST_GROUP_CELL_CLASS } ` ;
288271 }
289272
0 commit comments