Refactors date handling in calendar components
Updates event and column date parsing to use identifier instead of data attribute Improves date handling consistency across multiple calendar managers and renderers Replaces direct Date casting with dateService.parseISO() for more robust date parsing
This commit is contained in:
parent
8e52d670d6
commit
0f10d44037
3 changed files with 14 additions and 14 deletions
|
|
@ -165,8 +165,8 @@ export class AllDayManager {
|
|||
eventBus.on('header:ready', async (event: Event) => {
|
||||
let headerReadyEventPayload = (event as CustomEvent<IHeaderReadyEventPayload>).detail;
|
||||
|
||||
let startDate = new Date(headerReadyEventPayload.headerElements.at(0)!.data as Date);
|
||||
let endDate = new Date(headerReadyEventPayload.headerElements.at(-1)!.data as Date);
|
||||
let startDate = this.dateService.parseISO(headerReadyEventPayload.headerElements.at(0)!.identifier);
|
||||
let endDate = this.dateService.parseISO(headerReadyEventPayload.headerElements.at(-1)!.identifier);
|
||||
|
||||
let events: ICalendarEvent[] = await this.eventManager.getEventsForPeriod(startDate, endDate);
|
||||
// Filter for all-day events
|
||||
|
|
@ -398,7 +398,7 @@ export class AllDayManager {
|
|||
this.currentWeekDates = dayHeaders;
|
||||
|
||||
// Initialize layout engine with provided week dates
|
||||
let layoutEngine = new AllDayLayoutEngine(dayHeaders.map(column => column.data as Date));
|
||||
let layoutEngine = new AllDayLayoutEngine(dayHeaders.map(column => column.identifier));
|
||||
|
||||
// Calculate layout for all events together - AllDayLayoutEngine handles CalendarEvents directly
|
||||
return layoutEngine.calculateLayout(events);
|
||||
|
|
@ -489,8 +489,8 @@ export class AllDayManager {
|
|||
|
||||
const clone = dragEndEvent.draggedClone as SwpAllDayEventElement;
|
||||
const eventId = clone.eventId.replace('clone-', '');
|
||||
const targetDate = dragEndEvent.finalPosition.column.data as Date;
|
||||
|
||||
const targetDate = this.dateService.parseISO(dragEndEvent.finalPosition.column.identifier);
|
||||
|
||||
console.log('🔄 AllDayManager: Converting timed event to all-day', { eventId, targetDate });
|
||||
|
||||
// Create new dates preserving time
|
||||
|
|
@ -537,8 +537,8 @@ export class AllDayManager {
|
|||
|
||||
const clone = dragEndEvent.draggedClone as SwpAllDayEventElement;
|
||||
const eventId = clone.eventId.replace('clone-', '');
|
||||
const targetDate = dragEndEvent.finalPosition.column.data as Date;
|
||||
|
||||
const targetDate = this.dateService.parseISO(dragEndEvent.finalPosition.column.identifier);
|
||||
|
||||
// Calculate duration in days
|
||||
const durationDays = this.dateService.differenceInCalendarDays(clone.end, clone.start);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue