Snapshot
This commit is contained in:
parent
42c418e961
commit
001443ce11
3 changed files with 16 additions and 87 deletions
|
|
@ -41,7 +41,7 @@ export class EventManager {
|
|||
type: 'meeting',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 1, duration: 30 }
|
||||
metadata: { duration: 30 }
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
|
|
@ -51,7 +51,7 @@ export class EventManager {
|
|||
type: 'meeting',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 1, duration: 90 }
|
||||
metadata: { duration: 90 }
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
|
|
@ -61,7 +61,7 @@ export class EventManager {
|
|||
type: 'meal',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 1, duration: 60 }
|
||||
metadata: { duration: 60 }
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
|
|
@ -71,7 +71,7 @@ export class EventManager {
|
|||
type: 'work',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 2, duration: 120 }
|
||||
metadata: { duration: 120 }
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
|
|
@ -81,7 +81,7 @@ export class EventManager {
|
|||
type: 'meeting',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 2, duration: 30 }
|
||||
metadata: { duration: 30 }
|
||||
},
|
||||
{
|
||||
id: '6',
|
||||
|
|
@ -91,7 +91,7 @@ export class EventManager {
|
|||
type: 'meal',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 2, duration: 60 }
|
||||
metadata: { duration: 60 }
|
||||
},
|
||||
{
|
||||
id: '7',
|
||||
|
|
@ -101,7 +101,7 @@ export class EventManager {
|
|||
type: 'meeting',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 3, duration: 60 }
|
||||
metadata: { duration: 60 }
|
||||
},
|
||||
{
|
||||
id: '8',
|
||||
|
|
@ -111,7 +111,7 @@ export class EventManager {
|
|||
type: 'meal',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 3, duration: 60 }
|
||||
metadata: { duration: 60 }
|
||||
},
|
||||
{
|
||||
id: '9',
|
||||
|
|
@ -121,7 +121,7 @@ export class EventManager {
|
|||
type: 'meeting',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 4, duration: 120 }
|
||||
metadata: { duration: 120 }
|
||||
},
|
||||
{
|
||||
id: '10',
|
||||
|
|
@ -131,7 +131,7 @@ export class EventManager {
|
|||
type: 'meal',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 4, duration: 30 }
|
||||
metadata: { duration: 30 }
|
||||
},
|
||||
{
|
||||
id: '11',
|
||||
|
|
@ -141,7 +141,7 @@ export class EventManager {
|
|||
type: 'work',
|
||||
allDay: false,
|
||||
syncStatus: 'synced',
|
||||
metadata: { day: 5, duration: 180 }
|
||||
metadata: { duration: 180 }
|
||||
}
|
||||
];
|
||||
|
||||
|
|
@ -161,9 +161,6 @@ export class EventManager {
|
|||
return [...this.events];
|
||||
}
|
||||
|
||||
public getEventsByDay(day: number): CalendarEvent[] {
|
||||
return this.events.filter(event => event.metadata?.day === day);
|
||||
}
|
||||
|
||||
public getEventById(id: string): CalendarEvent | undefined {
|
||||
return this.events.find(event => event.id === id);
|
||||
|
|
|
|||
|
|
@ -54,12 +54,9 @@ export class EventRenderer {
|
|||
// Clear existing events first
|
||||
this.clearEvents();
|
||||
|
||||
// Group events by day for better rendering
|
||||
const eventsByDay = this.groupEventsByDay(events);
|
||||
|
||||
// Render events for each day
|
||||
Object.entries(eventsByDay).forEach(([dayIndex, dayEvents]) => {
|
||||
this.renderDayEvents(parseInt(dayIndex), dayEvents);
|
||||
// For now, just log events - proper rendering will be implemented later
|
||||
events.forEach(event => {
|
||||
console.log(`EventRenderer: Event "${event.title}" from ${event.start} to ${event.end}`);
|
||||
});
|
||||
|
||||
this.eventBus.emit(EventTypes.EVENT_RENDERED, {
|
||||
|
|
@ -67,68 +64,6 @@ export class EventRenderer {
|
|||
});
|
||||
}
|
||||
|
||||
private groupEventsByDay(events: CalendarEvent[]): Record<number, CalendarEvent[]> {
|
||||
const grouped: Record<number, CalendarEvent[]> = {};
|
||||
|
||||
events.forEach(event => {
|
||||
const day = event.metadata?.day || 0;
|
||||
if (!grouped[day]) {
|
||||
grouped[day] = [];
|
||||
}
|
||||
grouped[day].push(event);
|
||||
});
|
||||
|
||||
return grouped;
|
||||
}
|
||||
|
||||
private renderDayEvents(dayIndex: number, events: CalendarEvent[]): void {
|
||||
// Sort events by start time
|
||||
const sortedEvents = events.sort((a, b) => a.start.localeCompare(b.start));
|
||||
|
||||
sortedEvents.forEach(event => {
|
||||
// Find the appropriate events container for this event
|
||||
const eventContainer = this.findEventContainer(event, dayIndex);
|
||||
if (eventContainer) {
|
||||
this.renderEvent(event, eventContainer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private findEventContainer(event: CalendarEvent, dayIndex: number): Element | null {
|
||||
// Debug: Log what we're looking for
|
||||
console.log(`EventRenderer: Looking for day ${dayIndex} using POC structure`);
|
||||
|
||||
// Check what day columns actually exist
|
||||
const dayColumns = document.querySelectorAll('swp-day-column');
|
||||
console.log(`EventRenderer: Found ${dayColumns.length} day columns total`);
|
||||
|
||||
// Check first few columns to see their attributes
|
||||
for (let i = 0; i < Math.min(3, dayColumns.length); i++) {
|
||||
const column = dayColumns[i] as HTMLElement;
|
||||
console.log(`Column ${i}:`, {
|
||||
dayIndex: column.dataset.dayIndex,
|
||||
date: column.dataset.date,
|
||||
tagName: column.tagName
|
||||
});
|
||||
}
|
||||
|
||||
// Find the day column that corresponds to the event's day
|
||||
const dayColumn = document.querySelector(`swp-day-column[data-dayIndex="${dayIndex}"]`);
|
||||
if (!dayColumn) {
|
||||
console.warn(`EventRenderer: Day column for day ${dayIndex} not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Find the events layer within this day column
|
||||
const eventsLayer = dayColumn.querySelector('swp-events-layer');
|
||||
if (!eventsLayer) {
|
||||
console.warn(`EventRenderer: Events layer not found in day column for day ${dayIndex}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return eventsLayer;
|
||||
}
|
||||
|
||||
private renderEvent(event: CalendarEvent, container: Element): void {
|
||||
const eventElement = document.createElement('swp-event');
|
||||
eventElement.dataset.eventId = event.id;
|
||||
|
|
|
|||
|
|
@ -220,7 +220,6 @@ export class GridManager {
|
|||
daysToShow.forEach((date, dayIndex) => {
|
||||
const column = document.createElement('swp-day-column');
|
||||
(column as any).dataset.date = this.formatDate(date);
|
||||
(column as any).dataset.dayIndex = dayIndex.toString();
|
||||
|
||||
console.log(`GridManager: Creating day column ${dayIndex} for date ${this.formatDate(date)}`);
|
||||
|
||||
|
|
@ -278,8 +277,7 @@ export class GridManager {
|
|||
eventBus.emit(EventTypes.GRID_CLICK, {
|
||||
date: (dayColumn as any).dataset.date,
|
||||
time: position.time,
|
||||
minutes: position.minutes,
|
||||
dayIndex: parseInt((dayColumn as any).dataset.dayIndex)
|
||||
minutes: position.minutes
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -296,8 +294,7 @@ export class GridManager {
|
|||
eventBus.emit(EventTypes.GRID_DBLCLICK, {
|
||||
date: (dayColumn as any).dataset.date,
|
||||
time: position.time,
|
||||
minutes: position.minutes,
|
||||
dayIndex: parseInt((dayColumn as any).dataset.dayIndex)
|
||||
minutes: position.minutes
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue