Refactor column key handling and event positioning
Introduces more robust column key management across renderers and drag/resize operations Decouples column key parsing from date extraction Simplifies event positioning logic Improves multi-resource view compatibility
This commit is contained in:
parent
0eb3bacb41
commit
c2f7564f8e
7 changed files with 81 additions and 71 deletions
|
|
@ -176,7 +176,8 @@ export class DragDropManager {
|
|||
|
||||
if (gridEvent) {
|
||||
const columnKey = this.dragState.currentColumn.dataset.columnKey || '';
|
||||
const swpEvent = SwpEvent.fromElement(gridEvent, columnKey, this.gridConfig);
|
||||
const date = this.dragState.currentColumn.dataset.date || '';
|
||||
const swpEvent = SwpEvent.fromElement(gridEvent, columnKey, date, this.gridConfig);
|
||||
|
||||
const payload: IDragEndPayload = {
|
||||
swpEvent,
|
||||
|
|
@ -203,13 +204,15 @@ export class DragDropManager {
|
|||
// Remove ghost
|
||||
this.dragState.ghostElement?.remove();
|
||||
|
||||
// Get columnKey from target column
|
||||
// Get columnKey and date from target column
|
||||
const columnKey = this.dragState.columnElement.dataset.columnKey || '';
|
||||
const date = this.dragState.columnElement.dataset.date || '';
|
||||
|
||||
// Create SwpEvent from element (reads top/height/eventId from element)
|
||||
const swpEvent = SwpEvent.fromElement(
|
||||
this.dragState.element,
|
||||
columnKey,
|
||||
date,
|
||||
this.gridConfig
|
||||
);
|
||||
|
||||
|
|
@ -406,7 +409,7 @@ export class DragDropManager {
|
|||
eventId: this.dragState.eventId,
|
||||
element: this.dragState.element,
|
||||
sourceColumnIndex: this.getColumnIndex(this.dragState.columnElement),
|
||||
sourceDate: this.dragState.columnElement.dataset.date || '',
|
||||
sourceColumnKey: this.dragState.columnElement.dataset.columnKey || '',
|
||||
title: this.dragState.element.querySelector('swp-event-title')?.textContent || '',
|
||||
colorClass: [...this.dragState.element.classList].find(c => c.startsWith('is-')),
|
||||
itemType: 'event',
|
||||
|
|
@ -468,7 +471,7 @@ export class DragDropManager {
|
|||
const payload: IDragMoveHeaderPayload = {
|
||||
eventId: this.dragState.eventId,
|
||||
columnIndex: this.getColumnIndex(column),
|
||||
dateKey: column.dataset.date || ''
|
||||
columnKey: column.dataset.columnKey || ''
|
||||
};
|
||||
|
||||
this.eventBus.emit(CoreEvents.EVENT_DRAG_MOVE_HEADER, payload);
|
||||
|
|
|
|||
|
|
@ -251,14 +251,16 @@ export class ResizeManager {
|
|||
// Remove global resizing class
|
||||
document.documentElement.classList.remove('swp--resizing');
|
||||
|
||||
// Get columnKey from parent column
|
||||
// Get columnKey and date from parent column
|
||||
const column = this.resizeState.element.closest('swp-day-column') as HTMLElement;
|
||||
const columnKey = column?.dataset.columnKey || '';
|
||||
const date = column?.dataset.date || '';
|
||||
|
||||
// Create SwpEvent from element (reads top/height/eventId from element)
|
||||
const swpEvent = SwpEvent.fromElement(
|
||||
this.resizeState.element,
|
||||
columnKey,
|
||||
date,
|
||||
this.gridConfig
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue