Allows dynamic drag clone replacement

Introduces a polymorphic `createClone` method on base event elements to customize clone generation.
Adds a `replaceClone` delegate to drag event payloads, enabling subscribers to dynamically swap the active dragged clone.
This supports scenarios like converting a standard event clone to an all-day event clone when dragging to the all-day header.
This commit is contained in:
Janus C. H. Knudsen 2025-10-04 23:10:09 +02:00
parent 125cd678a3
commit 5fae433afb
5 changed files with 641 additions and 31 deletions

View file

@ -7,7 +7,7 @@ import { DateService } from '../utils/DateService';
/**
* Base class for event elements
*/
abstract class BaseSwpEventElement extends HTMLElement {
export abstract class BaseSwpEventElement extends HTMLElement {
protected dateService: DateService;
constructor() {
@ -16,6 +16,16 @@ abstract class BaseSwpEventElement extends HTMLElement {
this.dateService = new DateService(timezone);
}
// ============================================
// Abstract Methods
// ============================================
/**
* Create a clone for drag operations
* Must be implemented by subclasses
*/
public abstract createClone(): HTMLElement;
// ============================================
// Common Getters/Setters
// ============================================
@ -312,6 +322,18 @@ export class SwpAllDayEventElement extends BaseSwpEventElement {
}
}
/**
* Create a clone for drag operations
*/
public createClone(): SwpAllDayEventElement {
const clone = this.cloneNode(true) as SwpAllDayEventElement;
// Apply "clone-" prefix to ID
clone.dataset.eventId = `clone-${this.eventId}`;
return clone;
}
/**
* Apply CSS grid positioning
*/