Refactors calendar managers to components
Reorganizes navigation, view selector, and workweek preset managers into separate component files Improves code organization by moving specialized manager classes to a more descriptive components directory Adds enhanced logging for all-day event management and drag-and-drop interactions
This commit is contained in:
parent
bd8f5ae6c6
commit
b566aafb19
5 changed files with 73 additions and 15 deletions
|
|
@ -9,6 +9,7 @@ import { ICalendarEvent } from '../types/CalendarTypes';
|
|||
import { SwpAllDayEventElement } from '../elements/SwpEventElement';
|
||||
import {
|
||||
IDragMouseEnterHeaderEventPayload,
|
||||
IDragMouseEnterColumnEventPayload,
|
||||
IDragStartEventPayload,
|
||||
IDragMoveEventPayload,
|
||||
IDragEndEventPayload,
|
||||
|
|
@ -107,12 +108,45 @@ export class AllDayManager {
|
|||
});
|
||||
|
||||
eventBus.on('drag:end', (event) => {
|
||||
let draggedElement: IDragEndEventPayload = (event as CustomEvent<IDragEndEventPayload>).detail;
|
||||
let dragEndPayload: IDragEndEventPayload = (event as CustomEvent<IDragEndEventPayload>).detail;
|
||||
|
||||
if (draggedElement.target != 'swp-day-header') // we are not inside the swp-day-header, so just ignore.
|
||||
console.log('🎯 AllDayManager: drag:end received', {
|
||||
target: dragEndPayload.target,
|
||||
originalElementTag: dragEndPayload.originalElement?.tagName,
|
||||
hasAllDayAttribute: dragEndPayload.originalElement?.hasAttribute('data-allday'),
|
||||
eventId: dragEndPayload.originalElement?.dataset.eventId
|
||||
});
|
||||
|
||||
// Handle all-day → all-day drops (within header)
|
||||
if (dragEndPayload.target === 'swp-day-header') {
|
||||
console.log('✅ AllDayManager: Handling all-day → all-day drop');
|
||||
this.handleDragEnd(dragEndPayload);
|
||||
return;
|
||||
}
|
||||
|
||||
this.handleDragEnd(draggedElement);
|
||||
// Handle all-day → timed conversion (dropped in column)
|
||||
if (dragEndPayload.target === 'swp-day-column' && dragEndPayload.originalElement?.hasAttribute('data-allday')) {
|
||||
const eventId = dragEndPayload.originalElement.dataset.eventId;
|
||||
|
||||
console.log('🔄 AllDayManager: All-day → timed conversion', {
|
||||
eventId,
|
||||
currentLayoutsCount: this.currentLayouts.length,
|
||||
layoutsBeforeFilter: this.currentLayouts.map(l => l.calenderEvent.id)
|
||||
});
|
||||
|
||||
// Remove event from currentLayouts since it's now a timed event
|
||||
this.currentLayouts = this.currentLayouts.filter(
|
||||
layout => layout.calenderEvent.id !== eventId
|
||||
);
|
||||
|
||||
console.log('📊 AllDayManager: After filter', {
|
||||
currentLayoutsCount: this.currentLayouts.length,
|
||||
layoutsAfterFilter: this.currentLayouts.map(l => l.calenderEvent.id)
|
||||
});
|
||||
|
||||
// Recalculate and animate header height
|
||||
this.checkAndAnimateAllDayHeight();
|
||||
}
|
||||
});
|
||||
|
||||
// Listen for drag cancellation to recalculate height
|
||||
|
|
@ -189,6 +223,15 @@ export class AllDayManager {
|
|||
* Check current all-day events and animate to correct height
|
||||
*/
|
||||
public checkAndAnimateAllDayHeight(): void {
|
||||
console.log('📏 AllDayManager: checkAndAnimateAllDayHeight called', {
|
||||
currentLayoutsCount: this.currentLayouts.length,
|
||||
layouts: this.currentLayouts.map(l => ({
|
||||
id: l.calenderEvent.id,
|
||||
row: l.row,
|
||||
title: l.calenderEvent.title
|
||||
}))
|
||||
});
|
||||
|
||||
// Calculate required rows - 0 if no events (will collapse)
|
||||
let maxRows = 0;
|
||||
|
||||
|
|
@ -205,6 +248,12 @@ export class AllDayManager {
|
|||
|
||||
}
|
||||
|
||||
console.log('📊 AllDayManager: Height calculation', {
|
||||
maxRows,
|
||||
currentLayoutsLength: this.currentLayouts.length,
|
||||
isExpanded: this.isExpanded
|
||||
});
|
||||
|
||||
// Store actual row count
|
||||
this.actualRowCount = maxRows;
|
||||
|
||||
|
|
@ -233,6 +282,12 @@ export class AllDayManager {
|
|||
this.clearOverflowIndicators();
|
||||
}
|
||||
|
||||
console.log('🎬 AllDayManager: Will animate to', {
|
||||
displayRows,
|
||||
maxRows,
|
||||
willAnimate: displayRows !== this.actualRowCount
|
||||
});
|
||||
|
||||
// Animate to required rows (0 = collapse, >0 = expand)
|
||||
this.animateToRows(displayRows);
|
||||
}
|
||||
|
|
@ -339,6 +394,9 @@ export class AllDayManager {
|
|||
|
||||
ColumnDetectionUtils.updateColumnBoundsCache();
|
||||
|
||||
// Recalculate height after adding all-day event
|
||||
this.checkAndAnimateAllDayHeight();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue