Skip to content

Commit ca9bf68

Browse files
Ambrozyalexslavr
andauthored
T1261511: AppointmentCollectorTemplate provides appointments data (DevExpress#29538)
Co-authored-by: Vladimir Bushmanov <[email protected]> Co-authored-by: alexlavrov <[email protected]>
1 parent 69b0db0 commit ca9bf68

File tree

5 files changed

+103
-3
lines changed

5 files changed

+103
-3
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { ClientFunction } from 'testcafe';
2+
import { createWidget } from '../../../../helpers/createWidget';
3+
import url from '../../../../helpers/getPageUrl';
4+
5+
fixture.disablePageReloads`Appointment Editing`
6+
.page(url(__dirname, '../../../container.html'));
7+
8+
const dataSource = [{
9+
text: 'appointment1',
10+
startDate: new Date('2021-04-02T07:30:00.000Z'),
11+
endDate: new Date('2021-04-02T09:00:00.000Z'),
12+
}, {
13+
text: 'appointment2',
14+
startDate: new Date('2021-04-02T07:35:00.000Z'),
15+
endDate: new Date('2021-04-02T09:05:00.000Z'),
16+
}];
17+
const config = {
18+
dataSource,
19+
timeZone: 'America/Los_Angeles',
20+
currentDate: new Date(2021, 3, 2),
21+
maxAppointmentsPerCell: 1,
22+
};
23+
24+
['day', 'week', 'month', 'timelineDay', 'timelineWeek', 'timelineMonth'].forEach((view) => {
25+
test(`appointmentCollectorTemplate should render with appointments data on ${view} view`, async (t) => {
26+
const renderedData = await ClientFunction(() => (window as any).appointmentCollectorArgsData)();
27+
28+
await t.expect(renderedData).eql({
29+
appointmentCount: 1,
30+
isCompact: ['day', 'week'].includes(view),
31+
items: [dataSource[1]],
32+
});
33+
})
34+
.before(async () => createWidget('dxScheduler', {
35+
...config,
36+
dataSource,
37+
views: [view],
38+
currentView: view,
39+
appointmentCollectorTemplate(data: any) {
40+
(window as any).appointmentCollectorArgsData = data;
41+
return document.createElement('div');
42+
},
43+
}))
44+
.after(() => ClientFunction(() => {
45+
(window as any).appointmentCollectorArgsData = undefined;
46+
})());
47+
48+
test(`appointmentCollectorTemplate in view config should render with appointments data on ${view} view`, async (t) => {
49+
const renderedData = await ClientFunction(() => (window as any).appointmentCollectorArgsData)();
50+
51+
await t.expect(renderedData).eql({
52+
appointmentCount: 1,
53+
isCompact: ['day', 'week'].includes(view),
54+
items: [dataSource[1]],
55+
});
56+
})
57+
.before(async () => createWidget('dxScheduler', {
58+
...config,
59+
dataSource,
60+
views: [{
61+
type: view,
62+
appointmentCollectorTemplate(data: any) {
63+
(window as any).appointmentCollectorArgsData = data;
64+
return document.createElement('div');
65+
},
66+
}],
67+
currentView: view,
68+
}))
69+
.after(() => ClientFunction(() => {
70+
(window as any).appointmentCollectorArgsData = undefined;
71+
})());
72+
});

packages/devextreme-react/src/scheduler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dxScheduler, {
88
import { Component as BaseComponent, IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
99
import NestedOption from "./core/nested-option";
1010

11-
import type { ViewType, AppointmentAddedEvent, AppointmentAddingEvent, AppointmentClickEvent, AppointmentContextMenuEvent, AppointmentDblClickEvent, AppointmentDeletedEvent, AppointmentDeletingEvent, AppointmentFormOpeningEvent, AppointmentRenderedEvent, AppointmentTooltipShowingEvent, AppointmentUpdatedEvent, AppointmentUpdatingEvent, CellClickEvent, CellContextMenuEvent, ContentReadyEvent, DisposingEvent, InitializedEvent, AllDayPanelMode, AppointmentTemplateData, AppointmentTooltipTemplateData, CellAppointmentsLimit, dxSchedulerScrolling } from "devextreme/ui/scheduler";
11+
import type { ViewType, AppointmentAddedEvent, AppointmentAddingEvent, AppointmentClickEvent, AppointmentContextMenuEvent, AppointmentDblClickEvent, AppointmentDeletedEvent, AppointmentDeletingEvent, AppointmentFormOpeningEvent, AppointmentRenderedEvent, AppointmentTooltipShowingEvent, AppointmentUpdatedEvent, AppointmentUpdatingEvent, CellClickEvent, CellContextMenuEvent, ContentReadyEvent, DisposingEvent, InitializedEvent, AllDayPanelMode, AppointmentCollectorTemplateData, AppointmentTemplateData, AppointmentTooltipTemplateData, CellAppointmentsLimit, dxSchedulerScrolling } from "devextreme/ui/scheduler";
1212
import type { event } from "devextreme/events/events.types";
1313
import type { DataSourceOptions } from "devextreme/data/data_source";
1414
import type { Store } from "devextreme/data/store";
@@ -258,7 +258,7 @@ const Scrolling = Object.assign<typeof _componentScrolling, NestedComponentMeta>
258258
type IViewProps = React.PropsWithChildren<{
259259
agendaDuration?: number;
260260
allDayPanelMode?: AllDayPanelMode;
261-
appointmentCollectorTemplate?: ((data: { appointmentCount: number, isCompact: boolean }, collectorElement: any) => string | any) | template;
261+
appointmentCollectorTemplate?: ((data: AppointmentCollectorTemplateData, collectorElement: any) => string | any) | template;
262262
appointmentTemplate?: ((model: AppointmentTemplateData | { appointmentData: Record<string, any>, targetedAppointmentData: Record<string, any> }, itemIndex: number, contentElement: any) => string | any) | template;
263263
appointmentTooltipTemplate?: ((model: AppointmentTooltipTemplateData | { appointmentData: Record<string, any>, targetedAppointmentData: Record<string, any> }, itemIndex: number, contentElement: any) => string | any) | template;
264264
cellDuration?: number;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export class CompactAppointmentsHelper {
159159
return new (FunctionTemplate as any)((options) => template.render({
160160
model: {
161161
appointmentCount: items.data.length,
162+
items: items.data,
162163
isCompact,
163164
},
164165
container: options.container,

packages/devextreme/js/ui/scheduler.d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,23 @@ export type AppointmentTooltipTemplateData = TargetedAppointmentInfo & {
391391
readonly isButtonClicked: boolean;
392392
};
393393

394-
/** @public */
394+
/**
395+
* @docid
396+
* @public
397+
*/
395398
export type AppointmentCollectorTemplateData = {
399+
/**
400+
* @docid
401+
*/
396402
readonly appointmentCount: number;
403+
/**
404+
* @docid
405+
* @type Array<dxSchedulerAppointment>
406+
*/
407+
readonly items: Appointment[];
408+
/**
409+
* @docid
410+
*/
397411
readonly isCompact: boolean;
398412
};
399413

packages/devextreme/ts/dx.all.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24382,8 +24382,21 @@ declare module DevExpress.ui {
2438224382
*/
2438324383
readonly appointmentElement: DevExpress.core.DxElement;
2438424384
};
24385+
/**
24386+
* [descr:AppointmentCollectorTemplateData]
24387+
*/
2438524388
export type AppointmentCollectorTemplateData = {
24389+
/**
24390+
* [descr:AppointmentCollectorTemplateData.appointmentCount]
24391+
*/
2438624392
readonly appointmentCount: number;
24393+
/**
24394+
* [descr:AppointmentCollectorTemplateData.items]
24395+
*/
24396+
readonly items: Appointment[];
24397+
/**
24398+
* [descr:AppointmentCollectorTemplateData.isCompact]
24399+
*/
2438724400
readonly isCompact: boolean;
2438824401
};
2438924402
/**

0 commit comments

Comments
 (0)