wip
This commit is contained in:
parent
1a4c22d37f
commit
9e568fbd8e
4 changed files with 23 additions and 4 deletions
|
|
@ -4,7 +4,7 @@ import { DateService } from '../../core/DateService';
|
||||||
import { IGridConfig } from '../../core/IGridConfig';
|
import { IGridConfig } from '../../core/IGridConfig';
|
||||||
import { calculateEventPosition, snapToGrid, pixelsToMinutes } from '../../utils/PositionUtils';
|
import { calculateEventPosition, snapToGrid, pixelsToMinutes } from '../../utils/PositionUtils';
|
||||||
import { CoreEvents } from '../../constants/CoreEvents';
|
import { CoreEvents } from '../../constants/CoreEvents';
|
||||||
import { IDragColumnChangePayload, IDragMovePayload } from '../../types/DragTypes';
|
import { IDragColumnChangePayload, IDragMovePayload, IDragEndPayload } from '../../types/DragTypes';
|
||||||
import { calculateColumnLayout } from './EventLayoutEngine';
|
import { calculateColumnLayout } from './EventLayoutEngine';
|
||||||
import { IGridGroupLayout } from './EventLayoutTypes';
|
import { IGridGroupLayout } from './EventLayoutTypes';
|
||||||
|
|
||||||
|
|
@ -46,6 +46,22 @@ export class EventRenderer {
|
||||||
const payload = (e as CustomEvent<IEventUpdatedPayload>).detail;
|
const payload = (e as CustomEvent<IEventUpdatedPayload>).detail;
|
||||||
this.handleEventUpdated(payload);
|
this.handleEventUpdated(payload);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.eventBus.on(CoreEvents.EVENT_DRAG_END, (e) => {
|
||||||
|
const payload = (e as CustomEvent<IDragEndPayload>).detail;
|
||||||
|
this.handleDragEnd(payload);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle EVENT_DRAG_END - remove element if dropped in header
|
||||||
|
*/
|
||||||
|
private handleDragEnd(payload: IDragEndPayload): void {
|
||||||
|
if (payload.target === 'header') {
|
||||||
|
// Event was dropped in header drawer - remove from grid
|
||||||
|
const element = this.container?.querySelector(`swp-content-viewport swp-event[data-event-id="${payload.eventId}"]`);
|
||||||
|
element?.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,8 @@ export class HeaderDrawerRenderer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle drag end - finalize the item (it stays in header)
|
* Handle drag end - finalize the item (it stays in header)
|
||||||
|
* Note: EventRenderer handles removing the original element from the grid
|
||||||
|
* via EVENT_DRAG_END with target === 'header'
|
||||||
*/
|
*/
|
||||||
private handleDragEnd(): void {
|
private handleDragEnd(): void {
|
||||||
if (!this.currentItem) return;
|
if (!this.currentItem) return;
|
||||||
|
|
@ -135,10 +137,9 @@ export class HeaderDrawerRenderer {
|
||||||
// Remove dragging state
|
// Remove dragging state
|
||||||
this.currentItem.classList.remove('dragging');
|
this.currentItem.classList.remove('dragging');
|
||||||
|
|
||||||
// Item stays - it's now permanent
|
|
||||||
// TODO: Emit event to persist allDay=true change
|
// TODO: Emit event to persist allDay=true change
|
||||||
|
|
||||||
// Clear references but leave item in DOM
|
// Clear references
|
||||||
this.currentItem = null;
|
this.currentItem = null;
|
||||||
this.sourceElement = null;
|
this.sourceElement = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,8 @@ export class DragDropManager {
|
||||||
dateKey,
|
dateKey,
|
||||||
resourceId,
|
resourceId,
|
||||||
sourceDateKey: this.dragState.sourceDateKey,
|
sourceDateKey: this.dragState.sourceDateKey,
|
||||||
sourceResourceId: this.dragState.sourceResourceId
|
sourceResourceId: this.dragState.sourceResourceId,
|
||||||
|
target: this.inHeader ? 'header' : 'grid'
|
||||||
};
|
};
|
||||||
|
|
||||||
this.eventBus.emit(CoreEvents.EVENT_DRAG_END, payload);
|
this.eventBus.emit(CoreEvents.EVENT_DRAG_END, payload);
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ export interface IDragEndPayload {
|
||||||
resourceId?: string; // Target column resource (resource mode)
|
resourceId?: string; // Target column resource (resource mode)
|
||||||
sourceDateKey: string; // Source column date (where drag started)
|
sourceDateKey: string; // Source column date (where drag started)
|
||||||
sourceResourceId?: string; // Source column resource (where drag started)
|
sourceResourceId?: string; // Source column resource (where drag started)
|
||||||
|
target: 'grid' | 'header'; // Where the event was dropped
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDragCancelPayload {
|
export interface IDragCancelPayload {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue