Commit graph

239 commits

Author SHA1 Message Date
Janus C. H. Knudsen
35651be2f0 Ensures accurate all-day event placement
Reorders operations to calculate grid position for all-day events before appending them to the DOM. This prevents the element from being incorrectly counted during position calculations, improving placement accuracy.
2025-09-21 22:17:24 +02:00
Janus C. H. Knudsen
c9b9ac4cae Simplifies all-day event row calculation
Replaces date expansion logic with direct inspection of CSS grid row styles. This improves accuracy and performance by reflecting the actual rendered layout for determining `maxRows`.
2025-09-21 22:13:31 +02:00
Janus C. H. Knudsen
c682c30e23 Improves all-day drag-and-drop conversion
Refactors drag-to-all-day functionality to apply CSS styling and reposition the existing drag clone within the all-day container, rather than creating a new event element.

Centralizes all-day container creation in HeaderManager. Introduces `drag:mouseleave-header` to handle transitions from all-day back to timed events.

Ensures consistent styling and robust cleanup of drag clones for a smoother user experience.
2025-09-21 21:30:51 +02:00
Janus C. H. Knudsen
2cdbc8f1a3 Unifies all-day event element tag
Removes the `swp-allday-event` custom element, using `swp-event` for all-day events instead. All-day events are now distinguished by their parent `swp-allday-container`. Simplifies element management and CSS selectors.
2025-09-21 16:03:34 +02:00
Janus C. H. Knudsen
c7dcfbbaed Improves drag-drop event system with type safety
Introduces dedicated TypeScript interfaces for all drag-and-drop event payloads, enhancing type safety and developer experience.

Centralizes drag event detection and emission within `DragDropManager`. Refactors `AllDayManager`, `HeaderManager`, and `EventRendererManager` to subscribe to these typed events, improving decoupling and clarifying responsibilities.

Resolves known inconsistencies in drag event payloads, especially for all-day event conversions. Adds a comprehensive analysis document (`docs/EventSystem-Analysis.md`) detailing the event system and planned improvements.
2025-09-21 15:48:13 +02:00
Janus C. H. Knudsen
b4f5b29da3 Refactors event drag-drop and cloning logic
Centralizes drag event listener setup in `EventRendererManager` for better separation of concerns.

Introduces factory and cloning methods in `SwpEventElement` to simplify event cloning and data extraction from DOM elements during drag operations.

Enhances `DragDropManager` to pass the actual dragged element for conversion and accurately detect the drop target (day column or header).

Updates `EventRenderer` to expose drag-handling methods publicly, allowing the `EventRendererManager` to delegate event-specific drag operations based on drop target.
2025-09-20 09:40:56 +02:00
Janus C. H. Knudsen
0b7499521e Enables all-day event drag and drop
Implements comprehensive drag and drop for all-day events, allowing movement within the header and conversion to timed events when dragged into the calendar grid.

Optimizes column detection with a cached bounding box strategy, improving performance and accuracy. Refactors event conversion logic and renames related event bus events for clarity.
2025-09-19 00:20:30 +02:00
Janus C. H. Knudsen
f1d04ae12e wip 2025-09-18 19:45:40 +02:00
Janus C. H. Knudsen
1538e8c460 Optimizes header event handling and all-day display
Improves performance by early-exiting header event processing when no drag operation is active.
Ensures the all-day container height is re-evaluated after the mouse leaves the header area, maintaining correct layout.
2025-09-18 19:26:00 +02:00
3b75e1cafc WIP 2025-09-18 18:00:28 +02:00
fb40279009 Refactors header drag interaction to eliminate ghost columns
Updates the `HeaderManager` to utilize `mouseenter` and `mouseleave` events on the calendar header for improved performance and accuracy.
Calculates the target date based on the mouse's X-coordinate within the header.

Removes the need for 'ghost columns' by simplifying the logic. This significantly reduces complexity.
The `AllDayEventRenderer` is modified to reflect this change, omitting ghost column creation.

Updates `DragDropManager` to accommodate the new interaction model.
Various console logs are added for debugging purposes.
2025-09-18 17:55:52 +02:00
Janus Knudsen
18e80bbce2 WIP 2025-09-18 14:52:38 +02:00
Janus Knudsen
5c67825e19 Updates navigation event data
Updates the navigation event to include the current date
instead of the week start.

Makes the target date optional when rendering an all-day event.
2025-09-18 00:05:54 +02:00
Janus Knudsen
46b8bf9fb5 Fixes drag and drop to header issues
Addresses two key issues related to dragging events to the header: the premature removal of the original event element and the creation of duplicate all-day events.

The original event is no longer removed when dragging to the header; it is now only removed upon a successful drop.

Also, it prevents the creation of duplicate all-day events by checking for existing all-day events before creating new ones, using DOM queries to ensure accurate state.
2025-09-17 23:39:29 +02:00
Janus Knudsen
b4af5a9211 Improves all-day event hover detection
Enhances the all-day event selection by creating transparent, full-height columns for each day, which enables more accurate and reliable hover detection across all-day events.

Now selects all-day events by hovering on the entire column, not just day headers.
2025-09-17 22:08:27 +02:00
Janus Knudsen
3db93a9e89 Needs work... changes css directly 2025-09-16 23:09:56 +02:00
Janus Knudsen
b95a516806 Improves drag and drop event handling
Refactors drag and drop logic for better event handling and code clarity.

- Moves drag styling to CSS class for cleaner code.
- Emits a 'drag:convert-from-allday' event to handle the conversion of all-day events back to day events.
- Adds logging for debugging purposes.
2025-09-16 23:09:10 +02:00
Janus Knudsen
7e45293128 Improves drag and drop behavior
Hides the drag clone when moving events to the all-day area and shows it again when the mouse leaves the header to prevent visual inconsistencies.
Ensures only the correct all-day event is removed by specifying the container in the selector.
2025-09-14 00:32:27 +02:00
Janus Knudsen
8f1c32c9f9 Removes dragged all-day event on header mouseleave
Ensures that when dragging an event from the all-day section and the mouse leaves the header, the original all-day event is removed, allowing the cloned event in the day columns to take over seamlessly. This prevents duplicate events from appearing.
2025-09-14 00:12:34 +02:00
Janus Knudsen
cd079f7641 Removes redundant new_ prefixes
This commit streamlines the codebase by removing the unnecessary `new_` prefixes from the event handling functions, resulting in cleaner and more consistent naming conventions. The functions were likely renamed at some point and the old names were kept around for a while.
2025-09-13 22:38:29 +02:00
Janus Knudsen
692329b7a8 Positions all-day events in the correct row
Ensures that all-day events are placed in the first available row within their column to avoid overlapping.

It achieves this by querying existing all-day events, determining occupied rows based on their grid-row-start style, and then assigning the new event to the next available row.
2025-09-13 22:21:03 +02:00
Janus Knudsen
9cdf4fbe96 Improves drag and drop functionality and fixes issues
Refactors drag and drop logic to dynamically find the dragged element, ensuring correct behavior even when the DOM changes during the drag operation.

Creates all-day container if it doesn't exist.

This resolves issues where drag and drop operations would fail if the original element was no longer present in the DOM or if the container didn't exist.
2025-09-13 20:47:42 +02:00
Janus Knudsen
7054c0d40a Refactors event positioning and drag-and-drop
Centralizes event position calculations into `PositionUtils` for consistency and reusability across managers and renderers.

Improves drag-and-drop functionality by emitting events for all-day event conversion and streamlining position calculations during drag operations.

Introduces `AllDayManager` and `AllDayEventRenderer` to manage and render all-day events in the calendar header. This allows dragging events to the header to convert them to all-day events.
2025-09-13 00:39:56 +02:00
Janus Knudsen
8b96376d1f Centralizes time formatting with timezone support
Addresses inconsistent time formatting and lack of timezone
handling throughout the application by introducing a
`TimeFormatter` utility.

This class centralizes time formatting logic, providing
timezone conversion (defaults to Europe/Copenhagen) and
support for both 12-hour and 24-hour formats, configurable
via `CalendarConfig`.

It also updates event rendering to utilize the new
`TimeFormatter` for consistent time displays.
2025-09-12 22:21:56 +02:00
Janus Knudsen
c07d83d86f Refactors calendar event rendering and management
Improves code organization and maintainability by separating concerns related to all-day event rendering, header management, and event resizing.

Moves all-day event rendering logic into a dedicated `AllDayEventRenderer` class, utilizing the factory pattern for event element creation.

Refactors `AllDayManager` to handle all-day row height animations, separated from `HeaderManager`.

Removes the `ResizeManager` and related functionality.

These changes aim to reduce code duplication, improve testability, and enhance the overall architecture of the calendar component.
2025-09-12 00:36:02 +02:00
Janus Knudsen
e0b83ebd70 wip, buggy 2025-09-11 12:10:34 +02:00
Janus Knudsen
163314353b Enables all-day event to timed event conversion
Introduces the ability to convert all-day events to timed events by dragging them out of the header.

Leverages a factory method to create timed events from all-day elements, ensuring proper data conversion and styling.

Improves user experience by allowing more flexible event scheduling.
2025-09-10 23:57:48 +02:00
Janus Knudsen
e9298934c6 Introduces event element classes
Creates `SwpEventElement` and `SwpAllDayEventElement` classes for handling event rendering.

Refactors event creation logic in `EventRenderer` to utilize these classes, improving code organization and reusability.

Adds factory methods for creating event elements from `CalendarEvent` objects, simplifying event instantiation and data management.
2025-09-10 22:36:11 +02:00
Janus Knudsen
3bd74d6f4e Enhances drag and drop functionality
Improves drag and drop event handling, including conversion between all-day and timed events.

Introduces HeaderManager to handle header-related event logic and
centralizes header event handling for better code organization and
separation of concerns.

Optimizes event listeners and throttles events for improved performance.
Removes redundant code and improves the overall drag and drop
experience.
2025-09-10 22:07:40 +02:00
Janus Knudsen
d087e333fe Refactors event creation date handling
Updates event creation to correctly use the date from the calendar column, removing unnecessary time manipulation.

Simplifies duration handling by directly using the dataset value.

Removes unused all-day event drag and drop conversion functions.
2025-09-10 16:48:38 +02:00
Janus Knudsen
17b9b563a4 Updates event dates using 1970 reference
Modifies event rendering to correctly handle dates that use a 1970 reference point during drag and drop operations.

This ensures that events maintain their correct date when moved between columns, resolving an issue where dragged events would revert to the 1970 reference date.
2025-09-10 00:33:39 +02:00
Janus Knudsen
d205ccb0b6 Implements event resizing functionality
Introduces event resizing feature, allowing users to dynamically adjust event durations by dragging handles on the top or bottom of events.

Moves resize logic into a dedicated ResizeManager class for better code organization and separation of concerns.
2025-09-10 00:10:12 +02:00
Janus Knudsen
86fa7d5bab Improves event drag and drop stack handling
Addresses an issue where dragging events that are part of a stack could lead to inconsistencies.

This change ensures that when an event is dragged and dropped, the other events in the stack are also repositioned correctly.
It traverses the stack, removes the related events from their original positions, and re-renders them in the correct column.
It also removes stack link data from the dragged element to prevent unexpected behavior.
2025-09-09 22:57:38 +02:00
5cffc233c5 Updates event data after drag and drop
Updates event start and end times in the dataset after a successful drag and drop operation. This ensures the event element reflects the new time position.

Also resets the z-index of the dropped element if no overlaps are detected, keeping the element's original appearance.
2025-09-09 18:03:37 +02:00
69f4a71062 Adjusts event clone styling for drag operation
Ensures dragged event clones maintain correct positioning
by setting `marginLeft` to `0px`. This fixes a potential
visual issue where the clone might not fill the full
column width during dragging.
2025-09-09 17:46:48 +02:00
6402cd4565 Updates drag-and-drop overlap handling
Replaces the old overlap handling system with a new approach.

The new system recalculates overlaps after a drag-and-drop action and re-renders the affected events, avoiding manual group management. This simplifies the overlap resolution logic and improves performance.
2025-09-09 17:30:44 +02:00
80ef35c42c Refactors project structure and event rendering
Restructures the project for better maintainability and clarity.  Adds a ManagerFactory for dependency injection and reorganizes files.

Updates event rendering logic to correctly handle overlapping events using a stack link system. The EventRendererStrategy now correctly processes and renders event overlaps, ensuring proper display. Introduces processing tracking to avoid double rendering.

Updates documentation to reflect the new structure and build process. Also implements changes to build output and event system for improved clarity.

Fixes #123
2025-09-09 17:15:06 +02:00
Janus Knudsen
72019a3d9a wip 2025-09-09 14:35:21 +02:00
Janus Knudsen
727a6ec53a Fixes event stacking order during drag and drop
Ensures existing events maintain their base positions when a new event is dragged and dropped into an overlapping time slot.

The fix prioritizes existing events in the stack, placing the newly dropped event on top. This ensures correct visual representation and expected behavior during event manipulation.
2025-09-04 23:56:22 +02:00
Janus Knudsen
c7716d1b8f Improves event overlap stacking logic
Ensures event stacking only occurs when events actually overlap in pixel space, preventing visual artifacts. Breaks stacking chains when events no longer overlap due to middle element removal, and correctly resets styling.
2025-09-04 23:51:39 +02:00
Janus Knudsen
5bdb2f578d Simplifies event overlap management
Refactors event overlap handling to use a DOM-centric approach with data attributes for stack tracking. This eliminates complex state management, reduces code complexity, and improves maintainability. Removes the previous Map-based linked list implementation.

The new approach offers better debugging, automatic memory management, and eliminates state synchronization bugs.

The solution maintains identical functionality with a significantly simpler implementation, focusing on DOM manipulation for visual stacking and column sharing.

Addresses potential performance concerns of DOM queries by scoping them to specific containers.
2025-09-04 23:35:19 +02:00
Janus Knudsen
f5a6b80549 Improves event overlap detection
Refactors event overlap detection to use pixel-based comparison.
This improves accuracy and addresses issues with incorrect overlap
calculations when events have slight time differences but visually overlap.
It removes dependency on the event manager and the need to convert elements
to calendar events for overlap detection.
2025-09-04 20:32:25 +02:00
Janus Knudsen
1aef54bffb Improves event overlap detection logic
Refactors event dropping logic to first check for existing
event groups. If a group exists and the dropped event overlaps
with it, the dropped event is added to the group. Otherwise,
it proceeds with full overlap detection against individual events.

This change prevents unnecessary group creation and optimizes
event arrangement within columns. It also ensures the dragged
event is placed on the rightmost side by adding it to the
overlapping events array last.
2025-09-04 20:06:09 +02:00
Janus Knudsen
6afea2571b Fixes event overlap detection and stacking logic
Updates the event overlap detection to accurately determine when events overlap in time, fixing incorrect stacking behavior.

Implements column sharing for events starting within 30 minutes of each other.

Applies stacking only when events truly overlap in time but start times differ by more than 30 minutes.

Removes unnecessary data attributes and simplifies styling for stacked events, improving code cleanliness and performance.
2025-09-04 19:22:26 +02:00
Janus Knudsen
ff067cfac3 Implements event overlap rendering
Adds logic to handle event overlaps in the calendar view. It introduces two patterns: column sharing for events with the same start time (rendered using flexbox) and stacking for events with a >30 min difference (rendered with reduced width and z-index).

It also introduces deep linking to specific events via URL parameters.
2025-09-04 00:16:35 +02:00
Janus Knudsen
7a1c776bc1 Improves drag and drop functionality
Enhances drag and drop behavior by introducing free positioning during auto-scroll and snapping to grid intervals.

- Introduces a `calculateFreePosition` method to allow events to follow the mouse exactly during auto-scroll.
- Modifies the drag move event to emit the snapped position during normal drag behavior.
- Updates event rendering to use grid settings for snap intervals.
- Updates grid styles to configure CSS variables dynamically.
2025-09-03 20:48:23 +02:00
Janus Knudsen
b4d758b6d9 Improves drag and drop autoscroll behavior.
Refines the drag and drop autoscroll functionality to correctly update the position of the dragged element relative to the scrolling container.

Calculates the snapped position based on the column's bounding rectangle and scroll movement, ensuring accurate placement during autoscroll. This provides a smoother and more responsive user experience when dragging elements near the edges of the scrollable area.
2025-09-03 20:13:56 +02:00
Janus Knudsen
2083c6921e Refactors calendar configuration and event handling
Streamlines calendar configuration by adopting a singleton pattern for consistent access and simplifies event handling.

- Removes direct `CalendarConfig` dependency injection in favor of the `calendarConfig` singleton, reducing code complexity.
- Replaces specific event emissions for grid, date, and resource settings updates with a general `REFRESH_REQUESTED` event.
- Updates event names to be more descriptive and consistent ("NAVIGATION_COMPLETED", "PERIOD_INFO_UPDATE").
- Removes the need to pass the calendar config to renderers since it is now a singleton.

This improves code maintainability and simplifies the event emission process.
2025-09-03 20:04:47 +02:00
Janus Knudsen
d0936d1838 Refactors drag and drop manager for performance
Improves drag and drop performance by caching DOM elements and consolidating position calculations.

This reduces redundant DOM queries and optimizes event handling for smoother user interaction.
Also leverages `DateCalculator` for date/time conversions.
2025-09-03 19:05:03 +02:00
Janus Knudsen
05bb074e9a Refactors calendar managers and renderers
Improves calendar rendering performance by centralizing DOM manipulation in a dedicated `GridRenderer` class. This reduces redundant DOM queries and improves overall efficiency.

Introduces `EventManager` for optimized event lifecycle management with caching and optimized data processing.

The `ViewManager` is refactored for optimized view switching and event handling, further streamlining the application's architecture.

This change moves from a strategy-based `GridManager` to a simpler approach leveraging the `GridRenderer` directly for DOM updates. This eliminates unnecessary abstractions and improves code maintainability.

The changes include removing the old `GridManager`, `EventManager` and introducing new versions.
2025-09-03 18:51:19 +02:00