@@ -46,6 +46,7 @@ import { getRecurrenceProcessor } from './m_recurrence';
4646import subscribes from './m_subscribes' ;
4747import { utils } from './m_utils' ;
4848import timeZoneUtils , { type TimezoneLabel } from './m_utils_time_zone' ;
49+ import { combineRemoteFilter } from './r1/filterting/remote' ;
4950import { createTimeZoneCalculator } from './r1/timezone_calculator/index' ;
5051import {
5152 excludeFromRecurrence ,
@@ -68,7 +69,7 @@ import { setAppointmentGroupValues } from './utils/resource_manager/appointment_
6869import { getLeafGroupValues } from './utils/resource_manager/group_utils' ;
6970import { createResourceEditorModel } from './utils/resource_manager/popup_utils' ;
7071import { ResourceManager } from './utils/resource_manager/resource_manager' ;
71- import { AppointmentDataProvider } from './view_model/generate_view_model/data_provider/m_appointment_data_provider ' ;
72+ import { AppointmentDataSource } from './view_model/generate_view_model/data_provider/m_appointment_data_source ' ;
7273import type {
7374 AppointmentAgendaViewModel ,
7475 AppointmentViewModelPlain ,
@@ -166,7 +167,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
166167
167168 _appointments : any ;
168169
169- appointmentDataProvider ! : AppointmentDataProvider ;
170+ appointmentDataSource ! : AppointmentDataSource ;
170171
171172 _dataSource : any ;
172173
@@ -234,9 +235,8 @@ class Scheduler extends SchedulerOptionsBaseWidget {
234235 // @ts -expect-error
235236 const resolveCallbacks = new Deferred ( ) ;
236237
237- whenLoaded . done ( ( groupsResources ) => {
238- this . option ( 'loadedResources' , groupsResources ) ;
239- resolveCallbacks . resolve ( groupsResources ) ;
238+ whenLoaded . done ( ( ) => {
239+ resolveCallbacks . resolve ( ) ;
240240 } ) ;
241241
242242 this . _postponeDataSourceLoading ( whenLoaded ) ;
@@ -274,7 +274,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
274274 this . _initDataSource ( ) ;
275275
276276 this . _postponeResourceLoading ( ) . done ( ( ) => {
277- this . appointmentDataProvider . setDataSource ( this . _dataSource ) ;
277+ this . appointmentDataSource . setDataSource ( this . _dataSource ) ;
278278 this . _filterAppointmentsByDate ( ) ;
279279 this . _updateOption ( 'workSpace' , 'showAllDayPanel' , this . option ( 'showAllDayPanel' ) ) ;
280280 } ) ;
@@ -334,7 +334,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
334334 case 'resources' :
335335 this . resourceManager ?. dispose ( ) ;
336336 this . resourceManager = new ResourceManager ( this . option ( 'resources' ) ) ;
337- this . updateInstances ( ) ;
337+ this . updateAppointmentDataSource ( ) ;
338338
339339 this . _postponeResourceLoading ( ) . done ( ( ) => {
340340 this . _appointments . option ( 'items' , [ ] ) ;
@@ -345,7 +345,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
345345 break ;
346346 case 'startDayHour' :
347347 case 'endDayHour' :
348- this . updateInstances ( ) ;
348+ this . updateAppointmentDataSource ( ) ;
349349
350350 this . _appointments . option ( 'items' , [ ] ) ;
351351 this . _updateOption ( 'workSpace' , name , value ) ;
@@ -357,7 +357,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
357357 // TODO Vinogradov refactoring: merge it with startDayHour / endDayHour
358358 case 'offset' :
359359
360- this . updateInstances ( ) ;
360+ this . updateAppointmentDataSource ( ) ;
361361
362362 this . _appointments . option ( 'items' , [ ] ) ;
363363 this . _updateOption ( 'workSpace' , 'viewOffset' , this . normalizeViewOffsetValue ( value ) ) ;
@@ -452,7 +452,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
452452 break ;
453453 }
454454 case 'showAllDayPanel' :
455- this . updateInstances ( ) ;
455+ this . updateAppointmentDataSource ( ) ;
456456 this . repaint ( ) ;
457457 break ;
458458 case 'showCurrentTimeIndicator' :
@@ -473,7 +473,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
473473 case 'recurrenceEditMode' :
474474 case 'remoteFiltering' :
475475 case 'timeZone' :
476- this . updateInstances ( ) ;
476+ this . updateAppointmentDataSource ( ) ;
477477 this . repaint ( ) ;
478478 break ;
479479 case 'dropDownAppointmentTemplate' :
@@ -499,8 +499,6 @@ class Scheduler extends SchedulerOptionsBaseWidget {
499499 case 'recurrenceExceptionExpr' :
500500 case 'disabledExpr' :
501501 this . _updateExpression ( name , value ) ;
502- this . appointmentDataProvider . updateDataAccessors ( this . _dataAccessors ) ;
503-
504502 this . _initAppointmentTemplate ( ) ;
505503 this . repaint ( ) ;
506504 break ;
@@ -514,7 +512,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
514512 this . _updateOption ( 'workSpace' , args . fullName , value ) ;
515513 break ;
516514 case 'allDayPanelMode' :
517- this . updateInstances ( ) ;
515+ this . updateAppointmentDataSource ( ) ;
518516 this . _updateOption ( 'workSpace' , args . fullName , value ) ;
519517 break ;
520518 case 'renovateRender' :
@@ -528,8 +526,6 @@ class Scheduler extends SchedulerOptionsBaseWidget {
528526 ? this . _header . onToolbarOptionChanged ( args . fullName , value )
529527 : this . repaint ( ) ;
530528 break ;
531- case 'loadedResources' :
532- break ;
533529 default :
534530 // @ts -expect-error
535531 super . _optionChanged ( args ) ;
@@ -585,14 +581,35 @@ class Scheduler extends SchedulerOptionsBaseWidget {
585581 const startDate = this . timeZoneCalculator . createDate ( dateRange [ 0 ] , 'fromGrid' ) ;
586582 const endDate = this . timeZoneCalculator . createDate ( dateRange [ 1 ] , 'fromGrid' ) ;
587583
588- this . appointmentDataProvider . filterByDate (
584+ this . setRemoteFilter (
589585 startDate ,
590586 endDate ,
591587 this . option ( 'remoteFiltering' ) ,
592588 this . option ( 'dateSerializationFormat' ) ,
593589 ) ;
594590 }
595591
592+ setRemoteFilter ( min , max , remoteFiltering = false , dateSerializationFormat ?) {
593+ const dataSource = this . _dataSource ;
594+ const dataAccessors = this . _dataAccessors ;
595+
596+ if ( ! dataSource || ! remoteFiltering ) {
597+ return ;
598+ }
599+
600+ const dataSourceFilter = dataSource . filter ( ) ;
601+ const filter = combineRemoteFilter ( {
602+ dataSourceFilter,
603+ dataAccessors,
604+ min,
605+ max,
606+ dateSerializationFormat,
607+ forceIsoDateParsing : config ( ) . forceIsoDateParsing ,
608+ } ) ;
609+
610+ dataSource . filter ( filter ) ;
611+ }
612+
596613 _reloadDataSource ( ) {
597614 // @ts -expect-error
598615 const result = new Deferred ( ) ;
@@ -729,7 +746,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
729746
730747 this . _initEditing ( ) ;
731748
732- this . updateInstances ( ) ;
749+ this . updateAppointmentDataSource ( ) ;
733750
734751 this . _initActions ( ) ;
735752
@@ -744,35 +761,16 @@ class Scheduler extends SchedulerOptionsBaseWidget {
744761 this . resourceManager = new ResourceManager ( this . option ( 'resources' ) ) ;
745762 }
746763
747- createAppointmentDataProvider ( ) {
748- this . appointmentDataProvider ?. destroy ( ) ;
749- this . appointmentDataProvider = new AppointmentDataProvider ( {
750- dataSource : this . _dataSource ,
751- dataAccessors : this . _dataAccessors ,
752- timeZoneCalculator : this . timeZoneCalculator ,
753- dateSerializationFormat : this . option ( 'dateSerializationFormat' ) ,
754- resources : this . option ( 'resources' ) ,
755- startDayHour : ( ) => this . getViewOption ( 'startDayHour' ) ,
756- endDayHour : ( ) => this . getViewOption ( 'endDayHour' ) ,
757- viewOffset : ( ) => this . getViewOffsetMs ( ) ,
758- allDayPanelMode : ( ) => this . getViewOption ( 'allDayPanelMode' ) ,
759- showAllDayPanel : ( ) => this . option ( 'showAllDayPanel' ) ,
760- getResourceManager : ( ) => this . resourceManager ,
761- getIsVirtualScrolling : ( ) => this . isVirtualScrolling ( ) ,
762- getSupportAllDayRow : ( ) => this . _workSpace . supportAllDayRow ( ) ,
763- getViewType : ( ) => this . _workSpace . type ,
764- getViewDirection : ( ) => this . _workSpace . viewDirection ,
765- getDateRange : ( ) => this . _workSpace . getDateRange ( ) ,
766- getGroupCount : ( ) => this . _workSpace . _getGroupCount ( ) ,
767- getViewDataProvider : ( ) => this . _workSpace . viewDataProvider ,
768- } ) ;
764+ createAppointmentDataSource ( ) {
765+ this . appointmentDataSource ?. destroy ( ) ;
766+ this . appointmentDataSource = new AppointmentDataSource ( this . _dataSource ) ;
769767 }
770768
771- updateInstances ( ) {
769+ updateAppointmentDataSource ( ) {
772770 this . _timeZoneCalculator = null ;
773771
774772 if ( this . getWorkSpace ( ) ) {
775- this . createAppointmentDataProvider ( ) ;
773+ this . createAppointmentDataSource ( ) ;
776774 }
777775 }
778776
@@ -875,7 +873,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
875873 : [ ] ;
876874
877875 this . _appointments . option ( 'items' , viewModel ) ;
878- this . appointmentDataProvider . cleanState ( ) ;
876+ this . appointmentDataSource . cleanState ( ) ;
879877 }
880878
881879 _getAppointmentsToRepaint ( ) : AppointmentViewModelPlain [ ] {
@@ -981,9 +979,8 @@ class Scheduler extends SchedulerOptionsBaseWidget {
981979 this . setAria ( { role : 'group' } ) ;
982980 }
983981
984- _initMarkupOnResourceLoaded ( groupsResources ) {
982+ _initMarkupOnResourceLoaded ( ) {
985983 if ( ! ( this as any ) . _disposed ) {
986- this . option ( 'loadedResources' , groupsResources ) ;
987984 this . _initMarkupCore ( ) ;
988985 this . _reloadDataSource ( ) ;
989986 }
@@ -1018,9 +1015,9 @@ class Scheduler extends SchedulerOptionsBaseWidget {
10181015
10191016 if ( groups ?. length ) {
10201017 this . resourceManager . loadGroupResources ( groups , true )
1021- . then ( ( groupsResources ) => this . _initMarkupOnResourceLoaded ( groupsResources ) ) ;
1018+ . then ( ( ) => this . _initMarkupOnResourceLoaded ( ) ) ;
10221019 } else {
1023- this . _initMarkupOnResourceLoaded ( [ ] ) ;
1020+ this . _initMarkupOnResourceLoaded ( ) ;
10241021 }
10251022 }
10261023 }
@@ -1166,7 +1163,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
11661163 } ) ;
11671164 this . _waitAsyncTemplate ( ( ) => this . _workSpaceRecalculation ?. resolve ( ) ) ;
11681165
1169- this . createAppointmentDataProvider ( ) ;
1166+ this . createAppointmentDataSource ( ) ;
11701167 this . _filterAppointmentsByDate ( ) ;
11711168 this . _validateKeyFieldIfAgendaExist ( ) ;
11721169 this . _updateA11yStatus ( ) ;
@@ -1228,7 +1225,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
12281225 getResourceManager : ( ) => this . resourceManager ,
12291226 getAppointmentColor : this . createGetAppointmentColor ( ) ,
12301227
1231- getAppointmentDataProvider : ( ) => this . appointmentDataProvider ,
1228+ getAppointmentDataSource : ( ) => this . appointmentDataSource ,
12321229 dataAccessors : this . _dataAccessors ,
12331230 observer : this ,
12341231 onItemRendered : this . _getAppointmentRenderedAction ( ) ,
@@ -1312,7 +1309,6 @@ class Scheduler extends SchedulerOptionsBaseWidget {
13121309 }
13131310
13141311 _workSpaceConfig ( currentViewOptions : NormalizedView ) {
1315- const groupsResources = this . option ( 'loadedResources' ) ;
13161312 const scrolling = this . getViewOption ( 'scrolling' ) ;
13171313 const isVirtualScrolling = scrolling . mode === 'virtual' ;
13181314 const horizontalVirtualScrollingAllowed = isVirtualScrolling
@@ -1371,7 +1367,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
13711367 } , currentViewOptions ) ;
13721368
13731369 result . observer = this ;
1374- result . groups = groupsResources ;
1370+ result . groups = this . resourceManager . groupResources ( ) ;
13751371 result . onCellClick = this . _createActionByOption ( 'onCellClick' ) ;
13761372 result . onCellContextMenu = this . _createActionByOption ( 'onCellContextMenu' ) ;
13771373 result . currentDate = this . getViewOption ( 'currentDate' ) ;
@@ -1381,7 +1377,6 @@ class Scheduler extends SchedulerOptionsBaseWidget {
13811377 result . timeCellTemplate = result . timeCellTemplate ? this . _getTemplate ( result . timeCellTemplate ) : null ;
13821378 result . resourceCellTemplate = result . resourceCellTemplate ? this . _getTemplate ( result . resourceCellTemplate ) : null ;
13831379 result . dateCellTemplate = result . dateCellTemplate ? this . _getTemplate ( result . dateCellTemplate ) : null ;
1384- result . getAppointmentDataProvider = ( ) => this . appointmentDataProvider ;
13851380
13861381 return result ;
13871382 }
@@ -1518,7 +1513,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
15181513 delete singleRawAppointment [ this . _dataAccessors . expr . recurrenceExceptionExpr ] ;
15191514 delete singleRawAppointment [ this . _dataAccessors . expr . recurrenceRuleExpr ] ;
15201515
1521- const keyPropertyName = this . appointmentDataProvider . keyName ;
1516+ const keyPropertyName = this . appointmentDataSource . keyName ;
15221517 delete singleRawAppointment [ keyPropertyName ] ;
15231518 /* eslint-enable @typescript-eslint/no-dynamic-delete */
15241519
@@ -1760,7 +1755,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
17601755 this . _expandAllDayPanel ( rawAppointment ) ;
17611756
17621757 try {
1763- deferred = this . appointmentDataProvider
1758+ deferred = this . appointmentDataSource
17641759 . update ( target , rawAppointment )
17651760 . done ( ( ) => {
17661761 dragEvent ?. cancel . resolve ( false ) ;
@@ -2072,7 +2067,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
20722067
20732068 this . _expandAllDayPanel ( serializedAppointment ) ;
20742069
2075- return this . appointmentDataProvider
2070+ return this . appointmentDataSource
20762071 . add ( serializedAppointment )
20772072 . always ( ( storeAppointment ) => this . _onDataPromiseCompleted ( StoreEventNames . ADDED , storeAppointment ) ) ;
20782073 } ) ;
@@ -2102,7 +2097,7 @@ class Scheduler extends SchedulerOptionsBaseWidget {
21022097 processDeleteAppointment ( rawAppointment , deletingOptions ) {
21032098 this . _processActionResult ( deletingOptions , function ( canceled ) {
21042099 if ( ! canceled ) {
2105- this . appointmentDataProvider
2100+ this . appointmentDataSource
21062101 . remove ( rawAppointment )
21072102 . always ( ( storeAppointment ) => this . _onDataPromiseCompleted (
21082103 StoreEventNames . DELETED ,
@@ -2153,12 +2148,12 @@ class Scheduler extends SchedulerOptionsBaseWidget {
21532148 }
21542149
21552150 _validateKeyFieldIfAgendaExist ( ) {
2156- if ( ! this . appointmentDataProvider . isDataSourceInit ) {
2151+ if ( ! this . appointmentDataSource . isDataSourceInit ) {
21572152 return ;
21582153 }
21592154
21602155 const hasAgendaView = this . hasAgendaView ( ) ;
2161- const isKeyNotExist = ! this . appointmentDataProvider . keyName ;
2156+ const isKeyNotExist = ! this . appointmentDataSource . keyName ;
21622157
21632158 if ( hasAgendaView && isKeyNotExist ) {
21642159 errors . log ( 'W1023' ) ;
0 commit comments