Updates all-day event overflow indicator

Ensures that the all-day event overflow indicator updates
correctly when the number of events changes, instead of
creating duplicate indicators.
Removes unused event click handling logic.
This commit is contained in:
Janus C. H. Knudsen 2025-10-02 17:30:48 +02:00
parent 496be2f7ce
commit 5cdcd12e0a
3 changed files with 20 additions and 48 deletions

View file

@ -569,18 +569,27 @@ export class AllDayManager {
let overflowCount = totalEventsInColumn - ALL_DAY_CONSTANTS.MAX_COLLAPSED_ROWS let overflowCount = totalEventsInColumn - ALL_DAY_CONSTANTS.MAX_COLLAPSED_ROWS
if (overflowCount > 0) { if (overflowCount > 0) {
// Create new overflow indicator element // Check if indicator already exists in this column
let overflowElement = document.createElement('swp-event'); let existingIndicator = container.querySelector(`.max-event-indicator[data-column="${columnBounds.index}"]`) as HTMLElement;
overflowElement.className = 'max-event-indicator';
overflowElement.style.gridRow = ALL_DAY_CONSTANTS.MAX_COLLAPSED_ROWS.toString();
overflowElement.style.gridColumn = columnBounds.index.toString();
overflowElement.innerHTML = `<span>+${overflowCount + 1} more</span>`;
overflowElement.onclick = (e) => {
e.stopPropagation();
this.toggleExpanded();
};
container.appendChild(overflowElement); if (existingIndicator) {
// Update existing indicator
existingIndicator.innerHTML = `<span>+${overflowCount + 1} more</span>`;
} else {
// Create new overflow indicator element
let overflowElement = document.createElement('swp-event');
overflowElement.className = 'max-event-indicator';
overflowElement.setAttribute('data-column', columnBounds.index.toString());
overflowElement.style.gridRow = ALL_DAY_CONSTANTS.MAX_COLLAPSED_ROWS.toString();
overflowElement.style.gridColumn = columnBounds.index.toString();
overflowElement.innerHTML = `<span>+${overflowCount + 1} more</span>`;
overflowElement.onclick = (e) => {
e.stopPropagation();
this.toggleExpanded();
};
container.appendChild(overflowElement);
}
} }
}); });
} }

View file

@ -331,33 +331,6 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
} }
/**
* Handle event click (when drag threshold not reached)
*/
public handleEventClick(eventId: string, originalElement: HTMLElement): void {
console.log('handleEventClick:', eventId);
// Clean up any drag artifacts from failed drag attempt
if (this.draggedClone) {
this.draggedClone.classList.remove('dragging');
this.draggedClone.remove();
this.draggedClone = null;
}
// Restore original element styling if it was modified
if (this.originalEvent) {
this.originalEvent.style.opacity = '';
this.originalEvent.style.userSelect = '';
this.originalEvent = null;
}
// Emit a clean click event for other components to handle
eventBus.emit('event:clicked', {
eventId: eventId,
element: originalElement
});
}
/** /**
* Handle navigation completed event * Handle navigation completed event
*/ */

View file

@ -197,16 +197,6 @@ export class EventRenderingService {
} }
}); });
// Handle click (when drag threshold not reached)
this.eventBus.on('event:click', (event: Event) => {
const { draggedElement } = (event as CustomEvent).detail;
// Use draggedElement directly - no need for DOM query
if (draggedElement && this.strategy.handleEventClick) {
const eventId = draggedElement.dataset.eventId || '';
this.strategy.handleEventClick(eventId, draggedElement); //TODO: fix this redundant parameters
}
});
// Handle column change // Handle column change
this.eventBus.on('drag:column-change', (event: Event) => { this.eventBus.on('drag:column-change', (event: Event) => {
let columnChangeEvent = (event as CustomEvent<DragColumnChangeEventPayload>).detail; let columnChangeEvent = (event as CustomEvent<DragColumnChangeEventPayload>).detail;