Refactors event creation date handling
Updates event creation to correctly use the date from the calendar column, removing unnecessary time manipulation. Simplifies duration handling by directly using the dataset value. Removes unused all-day event drag and drop conversion functions.
This commit is contained in:
parent
17b9b563a4
commit
d087e333fe
1 changed files with 2 additions and 49 deletions
|
|
@ -603,7 +603,7 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
|
|||
// Find the parent column to get the actual date
|
||||
const columnElement = element.closest('swp-day-column') as HTMLElement;
|
||||
if (columnElement && columnElement.dataset.date) {
|
||||
const columnDate = new Date(columnElement.dataset.date + 'T00:00:00');
|
||||
const columnDate = new Date(columnElement.dataset.date);
|
||||
|
||||
// Keep the time portion from the 1970 dates, but use the column's date
|
||||
startDate = new Date(
|
||||
|
|
@ -624,7 +624,6 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
|
|||
}
|
||||
}
|
||||
|
||||
const duration = element.dataset.duration;
|
||||
return {
|
||||
id: eventId,
|
||||
title: title,
|
||||
|
|
@ -634,7 +633,7 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
|
|||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: {
|
||||
duration: duration ? parseInt(duration) : 60
|
||||
duration: element.dataset.duration
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -727,53 +726,7 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
|
|||
}, 300);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert dragged clone to all-day event preview
|
||||
*/
|
||||
private convertToAllDayPreview(targetDate: string): void {
|
||||
if (!this.draggedClone) return;
|
||||
|
||||
// Only convert once
|
||||
if (this.draggedClone.tagName === 'SWP-ALLDAY-EVENT') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Transform clone to all-day format
|
||||
this.transformCloneToAllDay(this.draggedClone, targetDate);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Move all-day event to a new date container
|
||||
*/
|
||||
private moveAllDayToNewDate(targetDate: string): void {
|
||||
if (!this.draggedClone) return;
|
||||
|
||||
const calendarHeader = document.querySelector('swp-calendar-header');
|
||||
if (!calendarHeader) return;
|
||||
|
||||
// Find the all-day container
|
||||
const allDayContainer = calendarHeader.querySelector('swp-allday-container');
|
||||
if (!allDayContainer) return;
|
||||
|
||||
// Calculate new column index
|
||||
const dayHeaders = document.querySelectorAll('swp-day-header');
|
||||
let columnIndex = 1;
|
||||
dayHeaders.forEach((header, index) => {
|
||||
if ((header as HTMLElement).dataset.date === targetDate) {
|
||||
columnIndex = index + 1;
|
||||
}
|
||||
});
|
||||
|
||||
// Update grid column position
|
||||
(this.draggedClone as HTMLElement).style.gridColumn = columnIndex.toString();
|
||||
|
||||
// Move to all-day container if not already there
|
||||
if (this.draggedClone.parentElement !== allDayContainer) {
|
||||
allDayContainer.appendChild(this.draggedClone);
|
||||
}
|
||||
|
||||
}
|
||||
renderEvents(events: CalendarEvent[], container: HTMLElement): void {
|
||||
|
||||
// NOTE: Removed clearEvents() to support sliding animation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue