Commit graph

397 commits

Author SHA1 Message Date
Janus C. H. Knudsen
c08fa02c29 Disables fill: forwards for spacer height animation
Removes the `fill: 'forwards'` property to ensure CSS `calc()` takes over the header spacer's height after the animation concludes.
2025-09-23 16:30:30 +02:00
Janus C. H. Knudsen
eb7d257b52 Removes header height animation setup
Eliminates manual DOM manipulation for temporary header height adjustment during slide-in animations. This is no longer necessary.
2025-09-23 16:26:34 +02:00
Janus C. H. Knudsen
ffa0bcafc3 Optimizes animation speed and event flow
Reduces the duration of a UI height animation for a snappier feel.
Disables a specific `header:ready` event emission during navigation rendering.
2025-09-23 09:46:47 +02:00
Janus C. H. Knudsen
6498b0ba8e Refactors all-day event rendering and DOM access
Decouples all-day event rendering, making it reactive to header readiness with period data.
Eliminates explicit DOM element caching, simplifying element access.
Enhances the `header:ready` event payload with `startDate` and `endDate`.
Improves all-day row height animation and calculation.
2025-09-22 23:37:43 +02:00
Janus C. H. Knudsen
f5e9909935 Separates all-day event rendering; handles header lifecycle
Event rendering strategies now exclusively handle timed events, while all-day events are managed by a dedicated renderer.

Centralizes calendar header creation within `GridRenderer`, ensuring the header element is always present from initial DOM construction. `HeaderManager` and `ScrollManager` now react to a `header:ready` event, which signifies the header is fully initialized.

Synchronizes all-day event rendering with header readiness, temporarily queuing events until the header is prepared. Emits an `allday:checkHeight` event to prompt all-day container height adjustments after rendering.
2025-09-22 21:53:18 +02:00
Janus C. H. Knudsen
996459f226 Removes outdated documentation and code comments
Deletes a large set of architectural plans, code reviews, and implementation documents. This content is no longer relevant as the described features and refactorings are complete.

Streamlines the event renderer by removing legacy drag event listener setup and outdated comments, reflecting improved separation of concerns and rendering strategies.
2025-09-22 20:59:25 +02:00
Janus C. H. Knudsen
92463ef173 Removes redundant header cache invalidation
Clearing the header manager's cache on `workweek:header-update` is no longer needed, streamlining updates.
2025-09-22 19:07:46 +02:00
Janus C. H. Knudsen
134ee29cb1 Improves drag cancellation behavior
Implements drag cancellation when the mouse leaves the calendar container during a drag operation. This prevents orphaned drag clones and restores the original event's state, enhancing user experience.

All-day events now correctly recalculate their height upon drag cancellation, ensuring accurate rendering after clone removal.

Refactors HeaderManager by removing redundant caching of the calendar header element.

Adds new mock event data for September and October 2025 to expand testing and demonstration scenarios.
2025-09-22 17:51:24 +02:00
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