Enables all-day event conversion on column hover
Allows users to convert all-day events to timed events by dragging them over a day column. This implementation adds logic to the DragDropManager to detect when an all-day event is dragged over a column. It then emits a new event, 'drag:mouseenter-column', carrying the event data and target column information. The event rendering service handles this event.
This commit is contained in:
parent
7a79297854
commit
78ca23c07a
5 changed files with 69 additions and 125 deletions
|
|
@ -289,46 +289,6 @@ export class SwpEventElement extends BaseSwpEventElement {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to convert an all-day HTML element to a timed SwpEventElement
|
||||
*/
|
||||
public static fromAllDayElement(allDayElement: HTMLElement): SwpEventElement {
|
||||
const eventId = allDayElement.dataset.eventId || '';
|
||||
const title = allDayElement.dataset.title || allDayElement.textContent || 'Untitled';
|
||||
const type = allDayElement.dataset.type || 'work';
|
||||
const startStr = allDayElement.dataset.start;
|
||||
const endStr = allDayElement.dataset.end;
|
||||
const durationStr = allDayElement.dataset.duration;
|
||||
|
||||
if (!startStr || !endStr) {
|
||||
throw new Error('All-day element missing start/end dates');
|
||||
}
|
||||
|
||||
const originalStart = new Date(startStr);
|
||||
const duration = durationStr ? parseInt(durationStr) : 60;
|
||||
|
||||
const now = new Date();
|
||||
const startDate = new Date(originalStart);
|
||||
startDate.setHours(now.getHours() || 9, now.getMinutes() || 0, 0, 0);
|
||||
|
||||
const endDate = new Date(startDate);
|
||||
endDate.setMinutes(endDate.getMinutes() + duration);
|
||||
|
||||
const calendarEvent: CalendarEvent = {
|
||||
id: eventId,
|
||||
title: title,
|
||||
start: startDate,
|
||||
end: endDate,
|
||||
type: type,
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: {
|
||||
duration: duration.toString()
|
||||
}
|
||||
};
|
||||
|
||||
return SwpEventElement.fromCalendarEvent(calendarEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue