Refactor event handling with SwpEvent wrapper
Introduces SwpEvent class to centralize event element data and calculations Improves drag and resize event handling by extracting common logic Simplifies calculation of event start/end times from element positions Enhances type safety and reduces code complexity in event managers Removes direct pixel/minute calculations from multiple managers
This commit is contained in:
parent
9e568fbd8e
commit
f670598e7a
7 changed files with 132 additions and 62 deletions
|
|
@ -59,7 +59,7 @@ export class EventRenderer {
|
|||
private handleDragEnd(payload: IDragEndPayload): void {
|
||||
if (payload.target === 'header') {
|
||||
// Event was dropped in header drawer - remove from grid
|
||||
const element = this.container?.querySelector(`swp-content-viewport swp-event[data-event-id="${payload.eventId}"]`);
|
||||
const element = this.container?.querySelector(`swp-content-viewport swp-event[data-event-id="${payload.swpEvent.eventId}"]`);
|
||||
element?.remove();
|
||||
}
|
||||
}
|
||||
|
|
@ -284,8 +284,11 @@ export class EventRenderer {
|
|||
private createEventElement(event: ICalendarEvent): HTMLElement {
|
||||
const element = document.createElement('swp-event');
|
||||
|
||||
// Only essential data attribute (eventId for DragDropManager compatibility)
|
||||
// Data attributes for SwpEvent compatibility
|
||||
element.dataset.eventId = event.id;
|
||||
if (event.resourceId) {
|
||||
element.dataset.resourceId = event.resourceId;
|
||||
}
|
||||
|
||||
// Calculate position
|
||||
const position = calculateEventPosition(event.start, event.end, this.gridConfig);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue