@@ -31,16 +31,15 @@ import { custom as customDialog } from '@js/ui/dialog';
3131import type { Appointment , AppointmentTooltipShowingEvent } from '@js/ui/scheduler' ;
3232import errors from '@js/ui/widget/ui.errors' ;
3333import { dateUtilsTs } from '@ts/core/utils/date' ;
34+ import { AppointmentDataProvider } from '@ts/scheduler/view_model/generate_view_model/data_provider/m_appointment_data_provider' ;
3435
3536import { createA11yStatusContainer } from './a11y_status/a11y_status_render' ;
3637import { getA11yStatusText } from './a11y_status/a11y_status_text' ;
3738import { AppointmentForm } from './appointment_popup/m_form' ;
3839import { ACTION_TO_APPOINTMENT , AppointmentPopup } from './appointment_popup/m_popup' ;
39- import { AppointmentDataProvider } from './appointments/data_provider/m_appointment_data_provider' ;
4040import AppointmentCollection from './appointments/m_appointment_collection' ;
4141import { SchedulerHeader } from './header/m_header' ;
4242import type { HeaderOptions } from './header/types' ;
43- import AppointmentLayoutManager from './m_appointments_layout_manager' ;
4443import { CompactAppointmentsHelper } from './m_compact_appointments_helper' ;
4544import { AppointmentTooltipInfo } from './m_data_structures' ;
4645import { hide as hideLoading , show as showLoading } from './m_loading' ;
@@ -51,7 +50,6 @@ import timeZoneUtils, { type TimezoneLabel } from './m_utils_time_zone';
5150import { createTimeZoneCalculator } from './r1/timezone_calculator/index' ;
5251import {
5352 excludeFromRecurrence ,
54- getAppointmentDataItems ,
5553 getToday ,
5654 isAppointmentTakesAllDay ,
5755 isDateAndTimeView ,
@@ -60,11 +58,7 @@ import {
6058import { SchedulerOptionsBaseWidget } from './scheduler_options_base_widget' ;
6159import { DesktopTooltipStrategy } from './tooltip_strategies/m_desktop_tooltip_strategy' ;
6260import { MobileTooltipStrategy } from './tooltip_strategies/m_mobile_tooltip_strategy' ;
63- import type {
64- AppointmentDataItem ,
65- AppointmentViewModel ,
66- SafeAppointment ,
67- } from './types' ;
61+ import type { AppointmentViewModel } from './types' ;
6862import { AppointmentAdapter } from './utils/appointment_adapter/appointment_adapter' ;
6963import { AppointmentDataAccessor } from './utils/data_accessor/appointment_data_accessor' ;
7064import type { IFieldExpr } from './utils/index' ;
@@ -76,6 +70,7 @@ import { setAppointmentGroupValues } from './utils/resource_manager/appointment_
7670import { getLeafGroupValues } from './utils/resource_manager/group_utils' ;
7771import { createResourceEditorModel } from './utils/resource_manager/popup_utils' ;
7872import { ResourceManager } from './utils/resource_manager/resource_manager' ;
73+ import AppointmentLayoutManager from './view_model/m_appointments_layout_manager' ;
7974import SchedulerAgenda from './workspaces/m_agenda' ;
8075import SchedulerTimelineDay from './workspaces/m_timeline_day' ;
8176import SchedulerTimelineMonth from './workspaces/m_timeline_month' ;
@@ -156,10 +151,6 @@ const RECURRENCE_EDITING_MODE = {
156151class Scheduler extends SchedulerOptionsBaseWidget {
157152 // NOTE: Do not initialize variables here, because `_initMarkup` function runs before constructor,
158153 // and initialization in constructor will erase the data
159- filteredItems ! : SafeAppointment [ ] ;
160-
161- preparedItems ! : AppointmentDataItem [ ] ;
162-
163154 _timeZoneCalculator ! : any ;
164155
165156 postponedOperations : any ;
@@ -204,7 +195,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
204195
205196 _recurrenceDialog : any ;
206197
207- _layoutManager : any ;
198+ _layoutManager ! : AppointmentLayoutManager ;
208199
209200 _appointmentForm : any ;
210201
@@ -558,7 +549,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
558549 }
559550
560551 _isAgenda ( ) {
561- return this . getLayoutManager ( ) . appointmentRenderingStrategyName === 'agenda' ;
552+ return this . _layoutManager . appointmentRenderingStrategyName === 'agenda' ;
562553 }
563554
564555 _allowDragging ( ) {
@@ -578,10 +569,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
578569 }
579570
580571 _isAllDayExpanded ( ) {
581- return this . option ( 'showAllDayPanel' ) && this . appointmentDataProvider . hasAllDayAppointments (
582- this . filteredItems ,
583- this . preparedItems ,
584- ) ;
572+ return this . option ( 'showAllDayPanel' ) && this . _layoutManager . hasAllDayAppointments ( ) ;
585573 }
586574
587575 _filterAppointmentsByDate ( ) {
@@ -661,14 +649,14 @@ class Scheduler extends SchedulerOptionsBaseWidget {
661649
662650 if (
663651 ! this . _isAgenda ( )
664- && this . filteredItems
652+ && this . _layoutManager
665653 && workspace
666654 && ! isAgendaWorkspaceComponent ( workspace )
667655 ) {
668656 if ( isForce || ( ! isFixedHeight || ! isFixedWidth ) ) {
669657 workspace . option ( 'allDayExpanded' , this . _isAllDayExpanded ( ) ) ;
670658 workspace . _dimensionChanged ( ) ;
671- const appointments = this . getLayoutManager ( ) . createAppointmentsMap ( this . filteredItems ) ;
659+ const appointments = this . _layoutManager . createAppointmentsMap ( ) ;
672660
673661 this . _appointments . option ( 'items' , appointments ) ;
674662 }
@@ -849,22 +837,13 @@ class Scheduler extends SchedulerOptionsBaseWidget {
849837 this . _renderContentImpl ( ) ;
850838 }
851839
852- _updatePreparedItems ( items ?: Appointment [ ] ) : void {
853- this . preparedItems = getAppointmentDataItems (
854- items ,
855- this . _dataAccessors ,
856- this . getViewOption ( 'cellDuration' ) ,
857- this . timeZoneCalculator ,
858- ) ;
859- }
860-
861840 _dataSourceChangedHandler ( result ?: Appointment [ ] ) {
862841 if ( this . _readyToRenderAppointments ) {
863842 this . _workSpaceRecalculation . done ( ( ) => {
864- this . _updatePreparedItems ( result ) ;
843+ this . _layoutManager . prepareItems ( result ) ;
865844 this . _renderAppointments ( ) ;
866845 this . _updateA11yStatus ( ) ;
867- this . getWorkSpace ( ) . onDataSourceChanged ( this . filteredItems ) ;
846+ this . getWorkSpace ( ) . onDataSourceChanged ( this . _layoutManager . filteredItems ) ;
868847 } ) ;
869848 }
870849 }
@@ -881,13 +860,9 @@ class Scheduler extends SchedulerOptionsBaseWidget {
881860 return scrolling ?. mode === 'virtual' ;
882861 }
883862
884- _filterAppointments ( ) {
885- this . filteredItems = this . appointmentDataProvider . filter ( this . preparedItems ) ;
886- }
887-
888863 _renderAppointments ( ) {
889864 const workspace = this . getWorkSpace ( ) ;
890- this . _filterAppointments ( ) ;
865+ this . _layoutManager . filterAppointments ( ) ;
891866
892867 workspace . option ( 'allDayExpanded' , this . _isAllDayExpanded ( ) ) ;
893868
@@ -901,11 +876,9 @@ class Scheduler extends SchedulerOptionsBaseWidget {
901876 }
902877
903878 _getAppointmentsToRepaint ( ) : AppointmentViewModel [ ] {
904- const layoutManager = this . getLayoutManager ( ) ;
905-
906- const appointmentsMap = layoutManager . createAppointmentsMap ( this . filteredItems ) ;
879+ const appointmentsMap = this . _layoutManager . createAppointmentsMap ( ) ;
907880
908- return layoutManager . getRepaintedAppointments (
881+ return this . _layoutManager . getRepaintedAppointments (
909882 appointmentsMap ,
910883 this . getAppointmentsInstance ( ) . option ( 'items' ) ,
911884 ) ;
@@ -1183,8 +1156,6 @@ class Scheduler extends SchedulerOptionsBaseWidget {
11831156 }
11841157
11851158 _initMarkupCore ( ) {
1186- this . filteredItems = [ ] ;
1187- this . preparedItems = [ ] ;
11881159 this . _readyToRenderAppointments = hasWindow ( ) ;
11891160
11901161 this . _workSpace && this . _cleanWorkspace ( ) ;
@@ -1357,7 +1328,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
13571328 const result = extend ( {
13581329 resources : this . option ( 'resources' ) ,
13591330 getResourceManager : ( ) => this . resourceManager ,
1360- getFilteredItems : ( ) => this . filteredItems ,
1331+ getFilteredItems : ( ) => this . _layoutManager . filteredItems ,
13611332
13621333 noDataText : this . option ( 'noDataText' ) ,
13631334 firstDayOfWeek : this . option ( 'firstDayOfWeek' ) ,
@@ -1868,7 +1839,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
18681839 }
18691840
18701841 getRenderingStrategyInstance ( ) {
1871- return this . getLayoutManager ( ) . getRenderingStrategyInstance ( ) ;
1842+ return this . _layoutManager . getRenderingStrategyInstance ( ) ;
18721843 }
18731844
18741845 getActions ( ) {
@@ -1924,7 +1895,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
19241895 if ( groups ?. length ) {
19251896 const { resourceById, groupsLeafs } = this . resourceManager ;
19261897 const appointmentSettings = this . _isAgenda ( )
1927- ? this . getLayoutManager ( ) . _positionMap [ appointmentIndex ] [ 0 ]
1898+ ? this . _layoutManager . _positionMap [ appointmentIndex ] [ 0 ]
19281899 : utils . dataAccessors . getAppointmentSettings ( element ) || { } ;
19291900 const cellGroups = getLeafGroupValues ( groupsLeafs , appointmentSettings . groupIndex ) ;
19301901
0 commit comments