Scheduler - Appointments Refactoring - Custom Templates#33158
Scheduler - Appointments Refactoring - Custom Templates#33158Tucchhaa merged 5 commits intoDevExpress:26_1from
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the new Scheduler appointments rendering pipeline to improve custom template support by passing a stable index into appointment templates and by enriching the appointment collector template model with the collected appointments’ data.
Changes:
- Pass an
indexthroughAppointments -> BaseAppointmentViewsoappointmentTemplatereceives the expected(model, index, container)arguments. - Change appointment collector inputs from a raw count to an
appointmentsDataarray and pass a richer{ appointmentCount, isCompact, items }model intoappointmentCollectorTemplate. - Add/adjust Jest coverage for template invocation and collector behavior (new
appointments_new.test.tsplus collector test updates).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/js/__internal/scheduler/appointments_new/appointments.ts | Wires template index into appointment rendering and passes collector items data instead of just a count. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointment/base_appointment.ts | Adds index to appointment view props and forwards it to template rendering. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointment_collector.ts | Updates collector API to accept appointmentsData and renders appointmentCollectorTemplate with the expected model. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointment_collector.test.ts | Updates unit tests for the new appointmentsData-based collector API and adds a count==2 case. |
| packages/devextreme/js/__internal/scheduler/appointments_new/mock/appointment_properties.ts | Updates appointment view mock props to include the new required index. |
| packages/devextreme/js/__internal/scheduler/tests/appointments_new.test.ts | Adds integration tests for appointment/collector templates (including view-specific templates and async template scenarios). |
packages/devextreme/js/__internal/scheduler/appointments_new/appointments.ts
Outdated
Show resolved
Hide resolved
packages/devextreme/js/__internal/scheduler/appointments_new/appointments.ts
Show resolved
Hide resolved
packages/devextreme/js/__internal/scheduler/__tests__/appointments_new.test.ts
Outdated
Show resolved
Hide resolved
packages/devextreme/js/__internal/scheduler/__tests__/appointments_new.test.ts
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| viewModelDiff.forEach((diffItem) => { | ||
| viewModelDiff.forEach((diffItem, index) => { |
There was a problem hiding this comment.
Passing index from diff may seem incorrect, but it is exactlye how the old implementation works:
To avoid making BC I have passed index too, but in general it seems that we need to remove passing index to appointmentTemplate function
| ? this.defaultAppointmentTemplate | ||
| : this.option().appointmentTemplate; | ||
|
|
||
| const $renderPromise = template.render({ |
There was a problem hiding this comment.
Turns out template.render doesn't return promise even if async template is passed. In the old impl onAppointmentRendered is called right after the templateFunction is called and it doesn't wait for the promise to complete (codepen)
There was a problem hiding this comment.
Because of that, there's no need to test async templates
| break; | ||
| case 'appointmentCollectorTemplate': | ||
| if (this.option('_newAppointments')) { | ||
| this._appointments.option('appointmentCollectorTemplate', this.getViewOption('appointmentCollectorTemplate')); |
There was a problem hiding this comment.
for newAppointments need only to update collector template, instead of the whole scheduler rerender, as collector template doesn't affect viewModel
| ? 'appointment' | ||
| : this.getViewOption('appointmentTemplate'); | ||
|
|
||
| const appointmentsConfig: Partial<AppointmentsProperties> = { |
There was a problem hiding this comment.
Moved compatibility normalization to appointments.ts:
https://github.com/DevExpress/DevExtreme/pull/33158/changes#diff-fe8d027bace8707fc88bc8c66b807f3d05219c21aff8edd3b187f70a08c1f641R109
No description provided.