Skip to content

Commit fc2c76d

Browse files
authored
Scheduler - Appointments refactoring - Drag-n-Drop (#33690)
1 parent f0976fb commit fc2c76d

15 files changed

Lines changed: 1487 additions & 94 deletions

File tree

packages/devextreme/js/__internal/scheduler/__tests__/__mock__/model/appointment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface AppointmentModel<T = HTMLDivElement> {
1313
getColor: (view: string) => string | undefined;
1414
getSnapshot: () => object;
1515
isFocused: () => boolean;
16+
isDragSource: () => boolean;
1617
}
1718

1819
const getColor = (appointment: HTMLDivElement): string => appointment.style.backgroundColor;
@@ -68,4 +69,5 @@ export const createAppointmentModel = <T extends HTMLDivElement | null>(
6869
...getGeometry(element),
6970
}),
7071
isFocused: () => element?.classList.contains('dx-state-focused') ?? false,
72+
isDragSource: () => element?.classList.contains('dx-scheduler-appointment-drag-source') ?? false,
7173
});

packages/devextreme/js/__internal/scheduler/__tests__/__mock__/model/scheduler.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ export class SchedulerModel {
5454
return appointments.map((element) => createAppointmentModel(element as HTMLDivElement));
5555
}
5656

57+
getDraggedAppointment(): AppointmentModel | null {
58+
const draggableContainer = this.container.querySelector('.dx-scheduler-draggable-container');
59+
const dragClone = draggableContainer?.querySelector('.dx-scheduler-appointment');
60+
61+
return dragClone ? createAppointmentModel(dragClone as HTMLDivElement) : null;
62+
}
63+
5764
getTooltipAppointment(index = 0): HTMLElement | null {
5865
return this.tooltip.getAppointmentItem(index);
5966
}

packages/devextreme/js/__internal/scheduler/__tests__/__mock__/model/tooltip.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import $ from '@js/core/renderer';
33
import type dxTooltip from '@js/ui/tooltip';
44
import { within } from '@testing-library/dom';
55

6+
const TOOLTIP_WIDGET_SELECTOR = `
7+
.dx-scheduler-appointment-tooltip-wrapper.dx-tooltip.dx-widget
8+
`;
69
const TOOLTIP_WRAPPER_SELECTOR = `
7-
.dx-overlay-wrapper.dx-scheduler-overlay-panel,
8-
.dx-overlay-wrapper.dx-scheduler-appointment-tooltip-wrapper
10+
.dx-scheduler-appointment-tooltip-wrapper.dx-tooltip-wrapper,
11+
.dx-scheduler-overlay-panel.dx-overlay-wrapper
912
`;
1013

1114
export class TooltipModel {
@@ -15,7 +18,7 @@ export class TooltipModel {
1518

1619
get dxTooltip(): dxTooltip {
1720
// @ts-expect-error
18-
return $('.dx-tooltip.dx-widget').dxTooltip('instance') as dxTooltip;
21+
return $(TOOLTIP_WIDGET_SELECTOR).dxTooltip('instance') as dxTooltip;
1922
}
2023

2124
get target(): Element | null {
@@ -31,6 +34,18 @@ export class TooltipModel {
3134
return this.element?.querySelector('.dx-scrollable .dx-scrollview-content') ?? null;
3235
}
3336

37+
getList(): Element {
38+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
39+
const tooltipContent = (this.dxTooltip as any)?.$content().get(0);
40+
const list = tooltipContent?.querySelector('.dx-list.dx-widget');
41+
42+
if (!list) {
43+
throw new Error('Tooltip list not found');
44+
}
45+
46+
return list as Element;
47+
}
48+
3449
getDeleteButtons(): HTMLElement[] {
3550
return this.element
3651
? within(this.element).queryAllByRole('button').filter(

0 commit comments

Comments
 (0)