Major refactor into type safe TS
With a risk oof rolling it all back
This commit is contained in:
parent
c08fa02c29
commit
48d1fd681c
19 changed files with 449 additions and 81 deletions
|
|
@ -8,6 +8,7 @@ import { OverlapDetector, OverlapResult } from '../utils/OverlapDetector';
|
|||
import { SwpEventElement } from '../elements/SwpEventElement';
|
||||
import { TimeFormatter } from '../utils/TimeFormatter';
|
||||
import { PositionUtils } from '../utils/PositionUtils';
|
||||
import { DragOffset, StackLinkData } from '../types/DragDropTypes';
|
||||
|
||||
/**
|
||||
* Interface for event rendering strategies
|
||||
|
|
@ -15,8 +16,8 @@ import { PositionUtils } from '../utils/PositionUtils';
|
|||
export interface EventRendererStrategy {
|
||||
renderEvents(events: CalendarEvent[], container: HTMLElement): void;
|
||||
clearEvents(container?: HTMLElement): void;
|
||||
handleDragStart?(originalElement: HTMLElement, eventId: string, mouseOffset: any, column: string): void;
|
||||
handleDragMove?(eventId: string, snappedY: number, column: string, mouseOffset: any): void;
|
||||
handleDragStart?(originalElement: HTMLElement, eventId: string, mouseOffset: DragOffset, column: string): void;
|
||||
handleDragMove?(eventId: string, snappedY: number, column: string, mouseOffset: DragOffset): void;
|
||||
handleDragAutoScroll?(eventId: string, snappedY: number): void;
|
||||
handleDragEnd?(eventId: string, originalElement: HTMLElement, draggedClone: HTMLElement, finalColumn: string, finalY: number): void;
|
||||
handleEventClick?(eventId: string, originalElement: HTMLElement): void;
|
||||
|
|
@ -159,7 +160,7 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
|
|||
/**
|
||||
* Handle drag start event
|
||||
*/
|
||||
public handleDragStart(originalElement: HTMLElement, eventId: string, mouseOffset: any, column: string): void {
|
||||
public handleDragStart(originalElement: HTMLElement, eventId: string, mouseOffset: DragOffset, column: string): void {
|
||||
this.originalEvent = originalElement;
|
||||
|
||||
// Remove stacking styling during drag will be handled by new system
|
||||
|
|
@ -195,7 +196,7 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
|
|||
/**
|
||||
* Handle drag move event
|
||||
*/
|
||||
public handleDragMove(eventId: string, snappedY: number, column: string, mouseOffset: any): void {
|
||||
public handleDragMove(eventId: string, snappedY: number, column: string, mouseOffset: DragOffset): void {
|
||||
if (!this.draggedClone) return;
|
||||
|
||||
// Update position
|
||||
|
|
@ -259,7 +260,7 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
|
|||
const allStackEventIds: Set<string> = new Set();
|
||||
|
||||
// Recursive funktion til at traversere stack chain
|
||||
const traverseStack = (linkData: any, visitedIds: Set<string>) => {
|
||||
const traverseStack = (linkData: StackLinkData, visitedIds: Set<string>) => {
|
||||
if (linkData.prev && !visitedIds.has(linkData.prev)) {
|
||||
visitedIds.add(linkData.prev);
|
||||
const prevElement = document.querySelector(`swp-time-grid [data-event-id="${linkData.prev}"]`) as HTMLElement;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue