@@ -78,7 +78,7 @@ import { macroTaskArray } from './utils/index';
7878import { isAgendaWorkspaceComponent } from './utils/is_agenda_workpace_component' ;
7979import { VIEWS } from './utils/options/constants_view' ;
8080import type { NormalizedView } from './utils/options/types' ;
81- import { setAppointmentGroupValues } from './utils/resource_manager/appointment_groups_utils' ;
81+ import { getAppointmentGroupValues , setAppointmentGroupValues } from './utils/resource_manager/appointment_groups_utils' ;
8282import { ResourceManager } from './utils/resource_manager/resource_manager' ;
8383import AppointmentLayoutManager from './view_model/appointments_layout_manager' ;
8484import { AppointmentDataSource } from './view_model/m_appointment_data_source' ;
@@ -1169,13 +1169,31 @@ class Scheduler extends SchedulerOptionsBaseWidget {
11691169 addAppointment : ( appointment ) => this . addAppointment ( appointment ) ,
11701170 updateAppointment : ( sourceAppointment , updatedAppointment ) => this . updateAppointment ( sourceAppointment , updatedAppointment ) ,
11711171
1172- updateScrollPosition : ( startDate , appointmentGroupValues , inAllDayRow ) => {
1173- this . _workSpace . updateScrollPosition ( startDate , appointmentGroupValues , inAllDayRow ) ;
1174- } ,
11751172 } ;
11761173 return new AppointmentPopup ( scheduler , form ) ;
11771174 }
11781175
1176+ private scrollToAppointment ( appointment : Record < string , unknown > ) : void {
1177+ const adapter = new AppointmentAdapter ( appointment , this . _dataAccessors ) ;
1178+ const { startDate, endDate, allDay } = adapter ;
1179+
1180+ if ( ! startDate ) {
1181+ return ;
1182+ }
1183+
1184+ const startTime = startDate . getTime ( ) ;
1185+ const endTime = endDate ? endDate . getTime ( ) : startTime ;
1186+ const dayInMs = toMs ( 'day' ) ;
1187+
1188+ const inAllDayRow = allDay || ( endTime - startTime ) >= dayInMs ;
1189+ const appointmentGroupValues = getAppointmentGroupValues (
1190+ appointment ,
1191+ this . resourceManager . resources ,
1192+ ) ;
1193+
1194+ this . _workSpace . updateScrollPosition ( startDate , appointmentGroupValues , inAllDayRow ) ;
1195+ }
1196+
11791197 private getAppointmentTooltipOptions ( ) {
11801198 const that = this ;
11811199 return {
@@ -1638,7 +1656,8 @@ class Scheduler extends SchedulerOptionsBaseWidget {
16381656 this . appointmentPopup . show ( singleRawAppointment , {
16391657 onSave : ( newAppointment ) => {
16401658 this . updateAppointment ( rawAppointment , appointment . source ) ;
1641- return this . addAppointment ( newAppointment ) ;
1659+ return when ( this . addAppointment ( newAppointment ) )
1660+ . done ( ( ) => this . scrollToAppointment ( newAppointment ) ) ;
16421661 } ,
16431662 title : messageLocalization . format ( 'dxScheduler-editPopupTitle' ) ,
16441663 readOnly : Boolean ( appointment . source ) && appointment . disabled ,
@@ -2012,7 +2031,8 @@ class Scheduler extends SchedulerOptionsBaseWidget {
20122031 delete this . editAppointmentData ; // TODO
20132032 if ( this . editing . allowAdding ) {
20142033 this . appointmentPopup . show ( rawAppointment , {
2015- onSave : ( appointment ) => this . addAppointment ( appointment ) ,
2034+ onSave : ( appointment ) => when ( this . addAppointment ( appointment ) )
2035+ . done ( ( ) => this . scrollToAppointment ( appointment ) ) ,
20162036 title : messageLocalization . format ( 'dxScheduler-newPopupTitle' ) ,
20172037 readOnly : false ,
20182038 } ) ;
@@ -2028,7 +2048,8 @@ class Scheduler extends SchedulerOptionsBaseWidget {
20282048 const readOnly = isDisabled || ! this . editing . allowUpdating ;
20292049
20302050 this . appointmentPopup . show ( rawAppointment , {
2031- onSave : ( appointment ) => this . updateAppointment ( rawAppointment , appointment ) ,
2051+ onSave : ( appointment ) => when ( this . updateAppointment ( rawAppointment , appointment ) )
2052+ . done ( ( ) => this . scrollToAppointment ( appointment ) ) ,
20322053 title : messageLocalization . format ( 'dxScheduler-editPopupTitle' ) ,
20332054 readOnly,
20342055 } ) ;
0 commit comments