@@ -11,12 +11,10 @@ import $ from '@js/core/renderer';
1111import dateUtils from '@js/core/utils/date' ;
1212import dateSerialization from '@js/core/utils/date_serialization' ;
1313import { extend } from '@js/core/utils/extend' ;
14- import type AbstractStore from '@js/data/abstract_store' ;
1514import Form from '@js/ui/form' ;
1615import { current , isFluent } from '@js/ui/themes' ;
1716
1817import { createAppointmentAdapter } from '../m_appointment_adapter' ;
19- import type { TimezoneLabel } from '../m_utils_time_zone' ;
2018import timeZoneUtils from '../m_utils_time_zone' ;
2119
2220const SCREEN_SIZE_OF_SINGLE_COLUMN = 600 ;
@@ -41,10 +39,11 @@ const E2E_TEST_CLASSES = {
4139 recurrenceSwitch : 'e2e-dx-scheduler-form-recurrence-switch' ,
4240} ;
4341
44- const DEFAULT_TIMEZONE_EDITOR_DATA_SOURCE_OPTIONS = {
42+ const createTimeZoneDataSource = ( ) => new DataSource ( {
43+ store : timeZoneUtils . getTimeZonesCache ( ) ,
4544 paginate : true ,
4645 pageSize : 10 ,
47- } ;
46+ } ) ;
4847
4948const getStylingModeFunc = ( ) : string | undefined => ( isFluent ( current ( ) ) ? 'filled' : undefined ) ;
5049
@@ -193,6 +192,7 @@ export class AppointmentForm {
193192 valueExpr : 'id' ,
194193 placeholder : noTzTitle ,
195194 searchEnabled : true ,
195+ dataSource : createTimeZoneDataSource ( ) ,
196196 onValueChanged : ( args ) => {
197197 const { form } = this ;
198198 const secondTimezoneEditor = form . getEditor ( secondTimeZoneExpr ) ;
@@ -428,59 +428,6 @@ export class AppointmentForm {
428428 editor && this . form . itemOption ( editorPath , 'editorOptions' , extend ( { } , editor . editorOptions , options ) ) ;
429429 }
430430
431- private scheduleTimezoneEditorDataSourceUpdate (
432- editorName : string ,
433- dataSource : { store : ( ) => AbstractStore ; reload : ( ) => void } ,
434- selectedTimezoneLabel : TimezoneLabel | null ,
435- date : Date ,
436- ) : void {
437- timeZoneUtils . getTimeZoneLabelsAsyncBatch ( date )
438- . catch ( ( ) => [ ] as TimezoneLabel [ ] )
439- . then ( async ( timezones ) => {
440- const store = dataSource . store ( ) ;
441-
442- await store . remove ( selectedTimezoneLabel ?. id ) ;
443-
444- // NOTE: Unfortunately, our store not support bulk operations
445- // So, we update it record-by-record
446- const insertPromises = timezones . reduce < Promise < void > [ ] > ( ( result , timezone ) => {
447- result . push ( store . insert ( timezone ) ) ;
448- return result ;
449- } , [ ] ) ;
450-
451- // NOTE: We should wait for all insertions before reload
452- await Promise . all ( insertPromises ) ;
453-
454- dataSource . reload ( ) ;
455- // NOTE: We should re-assign dataSource to the editor
456- // to repaint this editor after dataSource update
457- this . setEditorOptions ( editorName , 'Main' , { dataSource } ) ;
458- } ) . catch ( ( ) => { } ) ;
459- }
460-
461- private setupTimezoneEditorDataSource (
462- editorName : string ,
463- selectedTimezoneId : string | null ,
464- date : Date ,
465- ) : void {
466- const selectedTimezoneLabel = selectedTimezoneId
467- ? timeZoneUtils . getTimeZoneLabel ( selectedTimezoneId , date )
468- : null ;
469-
470- const dataSource = new DataSource ( {
471- ...DEFAULT_TIMEZONE_EDITOR_DATA_SOURCE_OPTIONS ,
472- store : selectedTimezoneLabel ? [ selectedTimezoneLabel ] : [ ] ,
473- } ) ;
474-
475- this . setEditorOptions ( editorName , 'Main' , { dataSource } ) ;
476- this . scheduleTimezoneEditorDataSourceUpdate (
477- editorName ,
478- dataSource ,
479- selectedTimezoneLabel ,
480- date ,
481- ) ;
482- }
483-
484431 updateFormData ( formData : Record < string , any > ) : void {
485432 this . isFormUpdating = true ;
486433 this . form . option ( 'formData' , formData ) ;
@@ -489,16 +436,9 @@ export class AppointmentForm {
489436 const { expr } = dataAccessors ;
490437
491438 const rawStartDate = dataAccessors . get ( 'startDate' , formData ) ;
492- const rawEndDate = dataAccessors . get ( 'endDate' , formData ) ;
493- const startDateTimezone = dataAccessors . get ( 'startDateTimeZone' , formData ) ?? null ;
494- const endDateTimezone = dataAccessors . get ( 'endDateTimeZone' , formData ) ?? null ;
495439
496440 const allDay = dataAccessors . get ( 'allDay' , formData ) ;
497441 const startDate = new Date ( rawStartDate ) ;
498- const endDate = new Date ( rawEndDate ) ;
499-
500- this . setupTimezoneEditorDataSource ( expr . startDateTimeZoneExpr , startDateTimezone , startDate ) ;
501- this . setupTimezoneEditorDataSource ( expr . endDateTimeZoneExpr , endDateTimezone , endDate ) ;
502442
503443 this . updateRecurrenceEditorStartDate ( startDate , expr . recurrenceRuleExpr ) ;
504444
0 commit comments