wip
This commit is contained in:
parent
88702e574a
commit
89e8a3f7b2
6 changed files with 137 additions and 198 deletions
|
|
@ -3,21 +3,20 @@ import { SwpAllDayEventElement } from '../elements/SwpEventElement';
|
|||
import { EventLayout } from '../utils/AllDayLayoutEngine';
|
||||
import { ColumnBounds } from '../utils/ColumnDetectionUtils';
|
||||
import { EventManager } from '../managers/EventManager';
|
||||
/**
|
||||
* AllDayEventRenderer - Simple rendering of all-day events
|
||||
* Handles adding and removing all-day events from the header container
|
||||
* NOTE: Layout calculation is now handled by AllDayManager
|
||||
*/
|
||||
import { DragStartEventPayload } from '../types/EventTypes';
|
||||
import { EventRendererStrategy } from './EventRenderer';
|
||||
|
||||
export class AllDayEventRenderer {
|
||||
|
||||
private container: HTMLElement | null = null;
|
||||
private originalEvent: HTMLElement | null = null;
|
||||
private draggedClone: HTMLElement | null = null;
|
||||
|
||||
constructor() {
|
||||
this.getContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or cache all-day container, create if it doesn't exist - SIMPLIFIED (no ghost columns)
|
||||
*/
|
||||
|
||||
private getContainer(): HTMLElement | null {
|
||||
|
||||
const header = document.querySelector('swp-calendar-header');
|
||||
|
|
@ -27,14 +26,45 @@ export class AllDayEventRenderer {
|
|||
if (!this.container) {
|
||||
this.container = document.createElement('swp-allday-container');
|
||||
header.appendChild(this.container);
|
||||
|
||||
}
|
||||
}
|
||||
return this.container;
|
||||
|
||||
}
|
||||
|
||||
// REMOVED: createGhostColumns() method - no longer needed!
|
||||
|
||||
private getAllDayContainer(): HTMLElement | null {
|
||||
return document.querySelector('swp-calendar-header swp-allday-container');
|
||||
}
|
||||
/**
|
||||
* Handle drag start for all-day events
|
||||
*/
|
||||
public handleDragStart(payload: DragStartEventPayload): void {
|
||||
|
||||
this.originalEvent = payload.draggedElement;;
|
||||
this.draggedClone = payload.draggedClone;
|
||||
|
||||
if (this.draggedClone) {
|
||||
|
||||
const container = this.getAllDayContainer();
|
||||
if (!container) return;
|
||||
|
||||
this.draggedClone.style.gridColumn = this.originalEvent.style.gridColumn;
|
||||
this.draggedClone.style.gridRow = this.originalEvent.style.gridRow;
|
||||
console.log('handleDragStart:this.draggedClone', this.draggedClone);
|
||||
container.appendChild(this.draggedClone);
|
||||
|
||||
// Add dragging style
|
||||
this.draggedClone.classList.add('dragging');
|
||||
this.draggedClone.style.zIndex = '1000';
|
||||
this.draggedClone.style.cursor = 'grabbing';
|
||||
|
||||
// Make original semi-transparent
|
||||
this.originalEvent.style.opacity = '0.3';
|
||||
this.originalEvent.style.userSelect = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Render an all-day event with pre-calculated layout
|
||||
|
|
@ -77,28 +107,14 @@ export class AllDayEventRenderer {
|
|||
* Render all-day events for specific period using AllDayEventRenderer
|
||||
*/
|
||||
public renderAllDayEventsForPeriod(eventLayouts: EventLayout[]): void {
|
||||
// Get events from EventManager for the period
|
||||
// const events = this.eventManager.getEventsForPeriod(startDate, endDate);
|
||||
|
||||
|
||||
|
||||
// Clear existing all-day events first
|
||||
this.clearAllDayEvents();
|
||||
|
||||
// Get actual visible dates from DOM headers instead of generating them
|
||||
|
||||
// const layouts = this.allDayManager.initAllDayEventsLayout(allDayEvents, weekDates);
|
||||
|
||||
// Render each all-day event with pre-calculated layout
|
||||
eventLayouts.forEach(layout => {
|
||||
this.renderAllDayEventWithLayout(layout.calenderEvent, layout);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Clear only all-day events
|
||||
*/
|
||||
|
||||
private clearAllDayEvents(): void {
|
||||
const allDayContainer = document.querySelector('swp-allday-container');
|
||||
if (allDayContainer) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue