@@ -25,12 +25,13 @@ import {
2525import CollectionWidget from '@js/ui/collection/ui.collection_widget.edit' ;
2626import { dateUtilsTs } from '@ts/core/utils/date' ;
2727
28+ import { APPOINTMENT_SETTINGS_KEY } from '../constants' ;
2829import { createAppointmentAdapter } from '../m_appointment_adapter' ;
2930import { APPOINTMENT_CONTENT_CLASSES , APPOINTMENT_DRAG_SOURCE_CLASS , APPOINTMENT_ITEM_CLASS } from '../m_classes' ;
30- import { APPOINTMENT_SETTINGS_KEY } from '../m_constants' ;
3131import { getRecurrenceProcessor } from '../m_recurrence' ;
3232import timeZoneUtils from '../m_utils_time_zone' ;
3333import { getPathToLeaf } from '../resources/m_utils' ;
34+ import type { AppointmentViewModel } from '../types' ;
3435import type { AppointmentDataAccessor } from '../utils' ;
3536import { getAppointmentTakesSeveralDays , sortAppointmentsByStartDate } from './data_provider/m_utils' ;
3637import { AgendaAppointment , Appointment } from './m_appointment' ;
@@ -43,6 +44,10 @@ const COMPONENT_CLASS = 'dx-scheduler-scrollable-appointments';
4344const DBLCLICK_EVENT_NAME = addNamespace ( dblclickEvent , 'dxSchedulerAppointment' ) ;
4445
4546const toMs = dateUtils . dateToMilliseconds ;
47+ const isAllDayAppointment = (
48+ appointment : AppointmentViewModel ,
49+ ) : boolean => Boolean ( appointment . settings [ 0 ] ?. allDay ) ;
50+
4651// @ts -expect-error
4752class SchedulerAppointments extends CollectionWidget {
4853 _virtualAppointments : any ;
@@ -179,7 +184,7 @@ class SchedulerAppointments extends CollectionWidget {
179184 _moveFocus ( ) { }
180185
181186 _focusTarget ( ) {
182- return ( this as any ) . _getNavigatableItems ( ) ;
187+ return this . _getNavigatableItems ( ) ;
183188 }
184189
185190 _renderFocusTarget ( ) {
@@ -259,67 +264,48 @@ class SchedulerAppointments extends CollectionWidget {
259264 }
260265 }
261266
262- _isAllDayAppointment ( appointment ) {
263- return appointment . settings . length && appointment . settings [ 0 ] . allDay || false ;
264- }
265-
266- _isRepaintAppointment ( appointment ) {
267- return ! isDefined ( appointment . needRepaint ) || appointment . needRepaint === true ;
268- }
269-
270- _isRepaintAll ( appointments ) {
271- if ( this . isAgendaView ) {
272- return true ;
273- }
274- for ( let i = 0 ; i < appointments . length ; i ++ ) {
275- if ( ! this . _isRepaintAppointment ( appointments [ i ] ) ) {
276- return false ;
277- }
278- }
279- return true ;
267+ _isRepaintAll ( appointments : AppointmentViewModel [ ] ) : boolean {
268+ return this . isAgendaView || appointments . every ( ( item ) => item . needRepaint ) ;
280269 }
281270
282- _applyFragment ( fragment , allDay ) {
271+ _applyFragment ( fragment : dxElementWrapper , allDay : boolean ) : void {
283272 if ( fragment . children ( ) . length > 0 ) {
284273 this . _getAppointmentContainer ( allDay ) . append ( fragment ) ;
285274 }
286275 }
287276
288- _onEachAppointment ( appointment , index , container , isRepaintAll ) {
289- const repaintAppointment = ( ) => {
290- appointment . needRepaint = false ;
291- this . _clearItem ( appointment ) ;
292- this . _renderItem ( index , appointment , container ) ;
293- } ;
294-
295- if ( appointment ?. needRemove === true ) {
296- this . _clearItem ( appointment ) ;
297- } else if ( isRepaintAll || this . _isRepaintAppointment ( appointment ) ) {
298- repaintAppointment ( ) ;
299- }
300- }
301-
302- _repaintAppointments ( appointments ) {
277+ _repaintAppointments ( appointments : AppointmentViewModel [ ] ) : void {
303278 this . _renderByFragments ( ( $commonFragment , $allDayFragment ) => {
304279 const isRepaintAll = this . _isRepaintAll ( appointments ) ;
305280
306281 if ( isRepaintAll ) {
307282 this . _getAppointmentContainer ( true ) . html ( '' ) ;
308283 this . _getAppointmentContainer ( false ) . html ( '' ) ;
309284 }
310-
311- ! appointments . length && this . _cleanItemContainer ( ) ;
285+ if ( ! appointments . length ) {
286+ this . _cleanItemContainer ( ) ;
287+ }
312288
313289 appointments . forEach ( ( appointment , index ) => {
314- const container = this . _isAllDayAppointment ( appointment )
290+ const container = isAllDayAppointment ( appointment )
315291 ? $allDayFragment
316292 : $commonFragment ;
317- this . _onEachAppointment ( appointment , index , container , isRepaintAll ) ;
293+
294+ if ( appointment . needRemove ) {
295+ this . _clearItem ( appointment ) ;
296+ } else if ( isRepaintAll || appointment . needRepaint ) {
297+ appointment . needRepaint = false ;
298+ this . _clearItem ( appointment ) ;
299+ this . _renderItem ( index , appointment , container ) ;
300+ }
318301 } ) ;
319302 } ) ;
320303 }
321304
322- _renderByFragments ( renderFunction ) {
305+ _renderByFragments ( renderFunction : (
306+ $commonFragment : dxElementWrapper ,
307+ $allDayFragment : dxElementWrapper ,
308+ ) => void ) : void {
323309 if ( this . isVirtualScrolling ) {
324310 const $commonFragment = $ ( domAdapter . createDocumentFragment ( ) as any ) ;
325311 const $allDayFragment = $ ( domAdapter . createDocumentFragment ( ) as any ) ;
@@ -351,7 +337,7 @@ class SchedulerAppointments extends CollectionWidget {
351337 ( this as any ) . _attachHoverEvents ( ) ;
352338 }
353339
354- _clearItem ( item ) {
340+ _clearItem ( item : AppointmentViewModel ) : void {
355341 const $items = this . _findItemElementByItem ( item . itemData ) ;
356342 if ( ! $items . length ) {
357343 return ;
@@ -526,9 +512,13 @@ class SchedulerAppointments extends CollectionWidget {
526512 this . notifyObserver ( 'showEditAppointmentPopup' , { data : appointmentData , target : $targetAppointment } ) ;
527513 }
528514
529- _renderItem ( index , item , container ) {
515+ _renderItem (
516+ index : number ,
517+ item : AppointmentViewModel ,
518+ container : dxElementWrapper ,
519+ ) : dxElementWrapper [ ] {
530520 const { itemData } = item ;
531- const $items : any = [ ] ;
521+ const $items : dxElementWrapper [ ] = [ ] ;
532522
533523 for ( let i = 0 ; i < item . settings . length ; i ++ ) {
534524 const setting = item . settings [ i ] ;
@@ -562,15 +552,11 @@ class SchedulerAppointments extends CollectionWidget {
562552 } ) ;
563553 }
564554
565- _getAppointmentContainer ( allDay ) {
555+ _getAppointmentContainer ( allDay : boolean ) : dxElementWrapper {
566556 const $allDayContainer = this . option ( 'allDayContainer' ) ;
567- let $container = ( this as any ) . itemsContainer ( ) . not ( $allDayContainer ) ;
568-
569- if ( allDay && $allDayContainer ) {
570- $container = $allDayContainer ;
571- }
557+ const $container = ( this as any ) . itemsContainer ( ) . not ( $allDayContainer ) ;
572558
573- return $container ;
559+ return allDay && $allDayContainer ? $allDayContainer : $container ;
574560 }
575561
576562 _postprocessRenderItem ( args ) {
0 commit comments