Skip to content

Commit a717460

Browse files
authored
T1282055: fix start and end date access in compact appointments (DevExpress#29330)
Co-authored-by: Vladimir Bushmanov <[email protected]>
1 parent aa926b0 commit a717460

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

packages/devextreme/js/__internal/scheduler/m_compact_appointments_helper.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,13 @@ export class CompactAppointmentsHelper {
201201
}
202202

203203
_getDateText(appointment) {
204-
const startDate = this._getStartDate(appointment);
205-
const endDate = this._getEndDate(appointment);
206-
const startDateText = startDate ? this._localizeDate(startDate) : '';
207-
const endDateText = endDate ? this._localizeDate(endDate) : '';
204+
const adapter = createAppointmentAdapter(
205+
appointment,
206+
this.instance._dataAccessors,
207+
this.instance.timeZoneCalculator,
208+
);
209+
const startDateText = adapter.startDate ? this._localizeDate(adapter.startDate) : '';
210+
const endDateText = adapter.endDate ? this._localizeDate(adapter.endDate) : '';
208211

209212
const dateText = startDateText === endDateText
210213
? `${startDateText}`

packages/devextreme/testing/tests/DevExpress.knockout/scheduler.tests.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,43 @@ QUnit[isRenovatedScheduler ? 'skip' : 'test']('Appointment DnD with disabled pro
9393
assert.equal($('.dx-scheduler-appointment-title').length, 1, 'title should be render once');
9494
assert.equal($('.dx-scheduler-appointment-content-details').length, 1, 'details should be render once');
9595
});
96+
97+
QUnit.test('T1282055: appointment collector renders correct', function(assert) {
98+
const markupText = `<div class='dx-viewport demo-container'>
99+
<div id='scheduler-demo'>
100+
<div data-bind='dxScheduler: schedulerOptions'></div>
101+
</div>
102+
</div>`;
103+
104+
const $element = $(markupText).appendTo('#qunit-fixture');
105+
106+
function PageViewModel() {
107+
this.schedulerOptions = {
108+
dataSource: [
109+
{
110+
text: 'Website Re-Design Plan',
111+
startDate: ko.observable('2021-06-01T16:30:00.000Z'),
112+
endDate: ko.observable('2021-06-01T18:30:00.000Z')
113+
},
114+
{
115+
text: 'Install New Router in Dev Room',
116+
startDate: ko.observable('2021-06-01T16:30:00.000Z'),
117+
endDate: ko.observable('2021-06-01T18:30:00.000Z')
118+
}
119+
],
120+
views: ['month'],
121+
currentView: 'month',
122+
currentDate: new Date('2021-06-01T16:30:00'),
123+
height: 300
124+
};
125+
}
126+
127+
ko.applyBindings(new PageViewModel(), $element.get(0));
128+
129+
assert.equal($('.dx-scheduler-appointment-collector').length, 1, 'appointment collector has rendered');
130+
assert.equal(
131+
$('.dx-scheduler-appointment-collector').attr('aria-roledescription'),
132+
'June 1, 2021',
133+
'appointment collector has correct a11y description'
134+
);
135+
});

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointmentCollector.tests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ module('Integration: Appointments Collector Base Tests', baseConfig, () => {
8989
_getAppointmentTemplate(template) {
9090
return this._getTemplateByOption(template);
9191
},
92+
_dataAccessors: {
93+
getter: {
94+
startDate: (obj) => obj.startDate,
95+
endDate: (obj) => obj.endDate,
96+
},
97+
},
9298
createAppointmentAdapter(date) {
9399
const schedulerMock = {
94100
fire: (methodName, fieldName, appointment) => appointment[fieldName]

0 commit comments

Comments
 (0)