@@ -4,9 +4,11 @@ import messageLocalization from '@js/common/core/localization/message';
44import $ , { type dxElementWrapper } from '@js/core/renderer' ;
55import { FunctionTemplate } from '@js/core/templates/function_template' ;
66import Button from '@js/ui/button' ;
7+ import type { Appointment } from '@js/ui/scheduler' ;
78
89import { APPOINTMENT_SETTINGS_KEY , LIST_ITEM_CLASS , LIST_ITEM_DATA_KEY } from './constants' ;
9- import type { AppointmentTooltipItem , CompactAppointmentOptions } from './types' ;
10+ import type Scheduler from './m_scheduler' ;
11+ import type { AppointmentTooltipItem , CompactAppointmentOptions , TargetedAppointment } from './types' ;
1012
1113const APPOINTMENT_COLLECTOR_CLASS = 'dx-scheduler-appointment-collector' ;
1214const COMPACT_APPOINTMENT_COLLECTOR_CLASS = `${ APPOINTMENT_COLLECTOR_CLASS } -compact` ;
@@ -15,7 +17,10 @@ const APPOINTMENT_COLLECTOR_CONTENT_CLASS = `${APPOINTMENT_COLLECTOR_CLASS}-cont
1517export class CompactAppointmentsHelper {
1618 elements : any [ ] = [ ] ;
1719
18- constructor ( public instance ) {
20+ instance : Scheduler ;
21+
22+ constructor ( instance : Scheduler ) {
23+ this . instance = instance ;
1924 }
2025
2126 render ( options : CompactAppointmentOptions ) : dxElementWrapper {
@@ -43,6 +48,7 @@ export class CompactAppointmentsHelper {
4348 const $button = $ ( e . element ) ;
4449 this . instance . showAppointmentTooltipCore (
4550 $button ,
51+ // @ts -expect-error
4652 $button . data ( 'items' ) ,
4753 this . _getExtraOptionsForTooltip ( options , $button ) ,
4854 ) ;
@@ -96,6 +102,7 @@ export class CompactAppointmentsHelper {
96102 _createCompactButton ( template , options : CompactAppointmentOptions ) {
97103 const $button = this . _createCompactButtonElement ( options ) ;
98104
105+ // @ts -expect-error
99106 return this . instance . _createComponent ( $button , Button , {
100107 type : 'default' ,
101108 width : options . width ,
@@ -127,7 +134,10 @@ export class CompactAppointmentsHelper {
127134 _createCompactButtonElement ( {
128135 isCompact, $container, coordinates, sortedIndex, items,
129136 } : CompactAppointmentOptions ) {
130- const appointmentDate = this . _getDateText ( items [ 0 ] . appointment ) ;
137+ const appointmentDate = this . _getDateText (
138+ items [ 0 ] . appointment ,
139+ items [ 0 ] . targetedAppointment ,
140+ ) ;
131141 const result = $ ( '<div>' )
132142 . addClass ( APPOINTMENT_COLLECTOR_CLASS )
133143 . attr ( 'aria-roledescription' , appointmentDate )
@@ -177,26 +187,18 @@ export class CompactAppointmentsHelper {
177187 return `${ dateLocalization . format ( date , 'monthAndDay' ) } , ${ dateLocalization . format ( date , 'year' ) } ` ;
178188 }
179189
180- _getStartDate ( appointment ) {
181- const date = appointment . startDate ;
182- return date ? new Date ( date ) : null ;
183- }
184-
185- _getEndDate ( appointment ) {
186- const date = appointment . endDate ;
187- return date ? new Date ( date ) : null ;
188- }
190+ _getDateText (
191+ appointment : Appointment ,
192+ targetedAppointment : Appointment | TargetedAppointment | undefined ,
193+ ) : string {
194+ const startDate = targetedAppointment ?. displayStartDate ?? appointment . startDate ;
195+ const endDate = targetedAppointment ?. displayEndDate ?? appointment . endDate ;
189196
190- _getDateText ( appointment ) {
191- const startDate = this . instance . _dataAccessors . get ( 'startDate' , appointment ) ;
192- const endDate = this . instance . _dataAccessors . get ( 'endDate' , appointment ) ;
193- const startDateText = startDate ? this . _localizeDate ( startDate ) : '' ;
194- const endDateText = endDate ? this . _localizeDate ( endDate ) : '' ;
197+ const startDateText = this . _localizeDate ( startDate ) ;
198+ const endDateText = this . _localizeDate ( endDate ) ;
195199
196- const dateText = startDateText === endDateText
197- ? ` ${ startDateText } `
200+ return startDateText === endDateText
201+ ? startDateText
198202 : `${ startDateText } - ${ endDateText } ` ;
199-
200- return `${ dateText } ` ;
201203 }
202204}
0 commit comments