@@ -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' ;
@@ -42,6 +43,10 @@ const COMPONENT_CLASS = 'dx-scheduler-scrollable-appointments';
4243const DBLCLICK_EVENT_NAME = addNamespace ( dblclickEvent , 'dxSchedulerAppointment' ) ;
4344
4445const toMs = dateUtils . dateToMilliseconds ;
46+ const isAllDayAppointment = (
47+ appointment : AppointmentViewModel ,
48+ ) : boolean => Boolean ( appointment . settings [ 0 ] ?. allDay ) ;
49+
4550// @ts -expect-error
4651class SchedulerAppointments extends CollectionWidget {
4752 _virtualAppointments : any ;
@@ -174,7 +179,7 @@ class SchedulerAppointments extends CollectionWidget {
174179 _moveFocus ( ) { }
175180
176181 _focusTarget ( ) {
177- return ( this as any ) . _getNavigatableItems ( ) ;
182+ return this . _getNavigatableItems ( ) ;
178183 }
179184
180185 _renderFocusTarget ( ) {
@@ -254,67 +259,48 @@ class SchedulerAppointments extends CollectionWidget {
254259 }
255260 }
256261
257- _isAllDayAppointment ( appointment ) {
258- return appointment . settings . length && appointment . settings [ 0 ] . allDay || false ;
259- }
260-
261- _isRepaintAppointment ( appointment ) {
262- return ! isDefined ( appointment . needRepaint ) || appointment . needRepaint === true ;
263- }
264-
265- _isRepaintAll ( appointments ) {
266- if ( this . isAgendaView ) {
267- return true ;
268- }
269- for ( let i = 0 ; i < appointments . length ; i ++ ) {
270- if ( ! this . _isRepaintAppointment ( appointments [ i ] ) ) {
271- return false ;
272- }
273- }
274- return true ;
262+ _isRepaintAll ( appointments : AppointmentViewModel [ ] ) : boolean {
263+ return this . isAgendaView || appointments . every ( ( item ) => item . needRepaint ) ;
275264 }
276265
277- _applyFragment ( fragment , allDay ) {
266+ _applyFragment ( fragment : dxElementWrapper , allDay : boolean ) : void {
278267 if ( fragment . children ( ) . length > 0 ) {
279268 this . _getAppointmentContainer ( allDay ) . append ( fragment ) ;
280269 }
281270 }
282271
283- _onEachAppointment ( appointment , index , container , isRepaintAll ) {
284- const repaintAppointment = ( ) => {
285- appointment . needRepaint = false ;
286- this . _clearItem ( appointment ) ;
287- this . _renderItem ( index , appointment , container ) ;
288- } ;
289-
290- if ( appointment ?. needRemove === true ) {
291- this . _clearItem ( appointment ) ;
292- } else if ( isRepaintAll || this . _isRepaintAppointment ( appointment ) ) {
293- repaintAppointment ( ) ;
294- }
295- }
296-
297- _repaintAppointments ( appointments ) {
272+ _repaintAppointments ( appointments : AppointmentViewModel [ ] ) : void {
298273 this . _renderByFragments ( ( $commonFragment , $allDayFragment ) => {
299274 const isRepaintAll = this . _isRepaintAll ( appointments ) ;
300275
301276 if ( isRepaintAll ) {
302277 this . _getAppointmentContainer ( true ) . html ( '' ) ;
303278 this . _getAppointmentContainer ( false ) . html ( '' ) ;
304279 }
305-
306- ! appointments . length && this . _cleanItemContainer ( ) ;
280+ if ( ! appointments . length ) {
281+ this . _cleanItemContainer ( ) ;
282+ }
307283
308284 appointments . forEach ( ( appointment , index ) => {
309- const container = this . _isAllDayAppointment ( appointment )
285+ const container = isAllDayAppointment ( appointment )
310286 ? $allDayFragment
311287 : $commonFragment ;
312- this . _onEachAppointment ( appointment , index , container , isRepaintAll ) ;
288+
289+ if ( appointment . needRemove ) {
290+ this . _clearItem ( appointment ) ;
291+ } else if ( isRepaintAll || appointment . needRepaint ) {
292+ appointment . needRepaint = false ;
293+ this . _clearItem ( appointment ) ;
294+ this . _renderItem ( index , appointment , container ) ;
295+ }
313296 } ) ;
314297 } ) ;
315298 }
316299
317- _renderByFragments ( renderFunction ) {
300+ _renderByFragments ( renderFunction : (
301+ $commonFragment : dxElementWrapper ,
302+ $allDayFragment : dxElementWrapper ,
303+ ) => void ) : void {
318304 if ( this . isVirtualScrolling ) {
319305 const $commonFragment = $ ( domAdapter . createDocumentFragment ( ) as any ) ;
320306 const $allDayFragment = $ ( domAdapter . createDocumentFragment ( ) as any ) ;
@@ -346,7 +332,7 @@ class SchedulerAppointments extends CollectionWidget {
346332 ( this as any ) . _attachHoverEvents ( ) ;
347333 }
348334
349- _clearItem ( item ) {
335+ _clearItem ( item : AppointmentViewModel ) : void {
350336 const $items = this . _findItemElementByItem ( item . itemData ) ;
351337 if ( ! $items . length ) {
352338 return ;
@@ -521,9 +507,13 @@ class SchedulerAppointments extends CollectionWidget {
521507 this . notifyObserver ( 'showEditAppointmentPopup' , { data : appointmentData , target : $targetAppointment } ) ;
522508 }
523509
524- _renderItem ( index , item , container ) {
510+ _renderItem (
511+ index : number ,
512+ item : AppointmentViewModel ,
513+ container : dxElementWrapper ,
514+ ) : dxElementWrapper [ ] {
525515 const { itemData } = item ;
526- const $items : any = [ ] ;
516+ const $items : dxElementWrapper [ ] = [ ] ;
527517
528518 for ( let i = 0 ; i < item . settings . length ; i ++ ) {
529519 const setting = item . settings [ i ] ;
@@ -557,15 +547,11 @@ class SchedulerAppointments extends CollectionWidget {
557547 } ) ;
558548 }
559549
560- _getAppointmentContainer ( allDay ) {
550+ _getAppointmentContainer ( allDay : boolean ) : dxElementWrapper {
561551 const $allDayContainer = this . option ( 'allDayContainer' ) ;
562- let $container = ( this as any ) . itemsContainer ( ) . not ( $allDayContainer ) ;
563-
564- if ( allDay && $allDayContainer ) {
565- $container = $allDayContainer ;
566- }
552+ const $container = ( this as any ) . itemsContainer ( ) . not ( $allDayContainer ) ;
567553
568- return $container ;
554+ return allDay && $allDayContainer ? $allDayContainer : $container ;
569555 }
570556
571557 _postprocessRenderItem ( args ) {
0 commit comments