Commit graph

91 commits

Author SHA1 Message Date
Janus C. H. Knudsen
8bbb2f05d3 Refactors dependency injection and configuration management
Replaces global singleton configuration with dependency injection
Introduces more modular and testable approach to configuration
Removes direct references to calendarConfig in multiple components
Adds explicit configuration passing to constructors

Improves code maintainability and reduces global state dependencies
2025-10-30 23:47:30 +01:00
Janus C. H. Knudsen
1d04f0ce0a Improves drag and drop conversion behavior
Resets scroll state and stops edge scrolling when a drag event converts between all-day and timed events, preventing unexpected scrolling behavior during conversion.
2025-10-13 22:17:17 +02:00
Janus C. H. Knudsen
a0344c6143 Improves drag event handling and scrolling
Refactors drag and drop event handling for smoother updates.

Tracks the current mouse position during drag operations to improve the accuracy of position updates.

Adjusts edge scrolling behavior.
2025-10-12 23:17:22 +02:00
Janus C. H. Knudsen
e620c919aa Improves drag and drop functionality
Refactors drag and drop to use the original element as the source and introduces edge scrolling.

This change aims to enhance the user experience during drag and drop operations by ensuring the correct element is used as the source, fixing issues, and by automatically scrolling the view when the dragged element reaches the edge of the scrollable area.
2025-10-12 22:00:02 +02:00
Janus C. H. Knudsen
8df1f6c4f1 Implements edge scrolling functionality
Adds edge scrolling to automatically scroll the calendar
when dragging an event near the edges of the view.

This improves the drag-and-drop experience by allowing users
to move events beyond the visible area.

Removes auto-scroll logic from the event renderer, centralizing
the scrolling behavior within the new edge scroll manager.
2025-10-12 09:21:32 +02:00
Janus C. H. Knudsen
42e28f46bc Refactors drag and drop manager for efficiency.
Streamlines drag and drop logic by removing unnecessary state variables
and simplifying column change handling, enhancing performance
and code maintainability.
2025-10-11 09:19:33 +02:00
Janus C. H. Knudsen
9b073a15b7 Refactors all-day event conversion to timed events
Streamlines the conversion of all-day events to timed events during drag and drop operations. This change improves the event rendering process by ensuring proper handling of element replacement and position updates.

Removes redundant code and simplifies the logic for updating the dragged clone.
2025-10-11 01:30:41 +02:00
Janus C. H. Knudsen
0a3d274164 Enables all-day event to timed event conversion
Implements drag-and-drop conversion from all-day events to timed events in day columns. This change introduces a new event type (`drag:mouseenter-column`) and delegates rendering logic to the `DateEventRenderer` to maintain architectural consistency.
2025-10-10 19:37:10 +02:00
Janus C. H. Knudsen
e83753a7d2 Improves event drag and drop
Enhances the event drag and drop functionality by setting the initial position of the dragged event to prevent it from jumping to the top of the column.
Also adjust event transition for a smoother user experience.
Removes unused resize logic.
2025-10-08 21:50:41 +02:00
Janus C. H. Knudsen
8b8a1e3127 wip, resize, debugging 2025-10-08 00:58:38 +02:00
Janus C. H. Knudsen
faa59f6a3c Improves event layout and stacking logic
Refactors the event layout and stacking logic based on review feedback.

This includes:
- Merging conflicting event groups to prevent inconsistencies.
- Implementing minimal stack level assignment using a min-heap.
- Consolidating styling and using DateService for drag operations.
- Adding reflow after drag and drop.
- Improving the column event filtering to include events overlapping midnight.
- Ensuring explicit sorting of events for grid layout.
2025-10-06 21:16:29 +02:00
Janus C. H. Knudsen
6b8c5d4673 Stacking and Sharecolumn WIP 2025-10-06 17:05:18 +02:00
Janus C. H. Knudsen
c788a1695e Extracts event layout calculations
Moves complex layout determination logic (grid grouping, stack levels, positioning) from `EventRenderer` to a new `EventLayoutCoordinator` class.

Delegates layout responsibilities to the coordinator, significantly simplifying the `EventRenderer`'s `renderColumnEvents` method. Refines `EventStackManager` by removing deprecated layout methods, consolidating its role to event grouping and core stack level management.

Improves modularity and separation of concerns within the rendering pipeline.
2025-10-06 00:24:13 +02:00
Janus C. H. Knudsen
2f58ceccd4 Implements advanced event stacking and grid layout
Introduces a 3-phase algorithm in `EventStackManager` for dynamic event positioning. Groups events by start time proximity to determine optimal layout.

Optimizes horizontal space by using side-by-side grid columns for simultaneous events and allowing non-overlapping events to share stack levels. Supports nested stacking for late-arriving events within grid columns.

Includes comprehensive documentation (`STACKING_CONCEPT.md`) and a visual demonstration (`stacking-visualization.html`) to explain the new layout logic. Updates event rendering to utilize the new manager and adds extensive test coverage.
2025-10-05 23:54:50 +02:00
Janus C. H. Knudsen
57bf122675 Moves event positioning to renderer
Relocates event CSS positioning logic from the `SwpEventElement` to the `DateEventRenderer`. This improves separation of concerns, making the renderer responsible for event layout.
2025-10-05 21:53:25 +02:00
Janus C. H. Knudsen
a9d6d14c93 Refactors event element handling with web components
Introduces web components for event elements, separating timed and all-day events into distinct components for better organization and reusability.

This change also simplifies event rendering and drag-and-drop operations by leveraging the properties and lifecycle methods of web components.
2025-10-04 15:35:09 +02:00
Janus C. H. Knudsen
1a47214831 Remove this stupid stacking logic 2025-10-04 14:50:25 +02:00
Janus C. H. Knudsen
fc884efa71 Improves event overlap handling
Refactors event rendering to handle transitive overlaps, ensuring that entire chains of overlapping events are correctly processed.

Fixes an issue where only direct overlaps were re-rendered after a drag and drop, leading to inconsistent stacking.
Now collects and re-renders all events in the stack.
2025-10-04 00:51:21 +02:00
Janus C. H. Knudsen
9bc082eed4 Improves date handling and event stacking
Enhances date validation and timezone handling using DateService, ensuring data integrity and consistency.

Refactors event rendering and dragging to correctly handle date transformations.

Adds a test plan for event stacking and z-index management.

Fixes edge cases in navigation and date calculations for week/year boundaries and DST transitions.
2025-10-04 00:32:26 +02:00
Janus C. H. Knudsen
a86a736340 Refactors date handling to use DateService
Standardizes date manipulation across the application by leveraging the DateService.
This change improves consistency and reduces code duplication by removing redundant date calculations.
2025-10-03 20:59:52 +02:00
Janus C. H. Knudsen
6bbf2d8adb Refactors date handling with DateService
Replaces DateCalculator with DateService for improved date and time operations, including timezone handling.

This change enhances the calendar's accuracy and flexibility in managing dates, especially concerning timezone configurations.
It also corrects a typo in the `allDay` dataset attribute.
2025-10-03 20:50:40 +02:00
Janus C. H. Knudsen
4fea01c76b Improves all-day event drag and drop
Addresses issues with all-day event duration calculation and positioning during drag and drop.

- Uses `differenceInCalendarDays` to correctly calculate event duration across timezone and DST boundaries.
- Preserves the original event time when moving events to a different day.
- Snaps dragged event to the top of the target time slot.
2025-10-03 19:09:44 +02:00
Janus C. H. Knudsen
53cf097a47 Introduces DateService for time zone handling
Adds DateService using date-fns-tz for robust time zone
conversions and date manipulations.

Refactors DateCalculator and TimeFormatter to utilize the
DateService, centralizing date logic and ensuring consistent
time zone handling throughout the application.

Improves event dragging by updating time displays and data
attributes, handling cross-midnight events correctly.
2025-10-03 16:47:42 +02:00
Janus C. H. Knudsen
1821d805d1 Comments out timestamp update in dragged clone
Comments out the timestamp update logic within the dragged clone functionality.

This change is a preliminary step towards refactoring the scroll logic, which will be managed by a dedicated scroll manager, decoupling it from the event renderer.
2025-10-03 16:33:26 +02:00
Janus C. H. Knudsen
38737762c5 Adds technical date and time formatting
Adds options for technical date and time formatting and includes the option to show seconds.

Updates time formatting to use UTC-to-local conversion and ensures consistent colon separators for time values.

Adjusts all-day event handling to preserve original start/end times.
2025-10-03 16:05:22 +02:00
Janus C. H. Knudsen
89e8a3f7b2 wip 2025-10-02 23:11:26 +02:00
Janus C. H. Knudsen
5cdcd12e0a Updates all-day event overflow indicator
Ensures that the all-day event overflow indicator updates
correctly when the number of events changes, instead of
creating duplicate indicators.
Removes unused event click handling logic.
2025-10-02 17:30:48 +02:00
Janus C. H. Knudsen
a1e1c5d185 Removes unnecessary destroy methods 2025-10-01 22:38:15 +02:00
Janus C. H. Knudsen
83e01f9cb7 Improves all-day event drag and drop
Refactors all-day event conversion during drag and drop to
use the event payload, improving code clarity and reducing
redundancy.

Removes unnecessary style settings and fixes column detection
logic. Addresses an issue where event removal occurred before
successful placement.
2025-09-29 20:50:52 +02:00
Janus C. H. Knudsen
8b5420f367 Refactors event extraction to utility function
Moves event extraction logic to a shared utility function for reusability.

Removes redundant code and improves consistency in event handling.
The original duration is now mandatory.
2025-09-29 18:39:40 +02:00
Janus C. H. Knudsen
0d33b51ff8 Corrects dragged event clone position 2025-09-29 17:56:30 +02:00
Janus C. H. Knudsen
6ccc071587 Refactors drag and drop column detection
Improves drag and drop functionality by refactoring column detection to use column bounds instead of dates.
This change enhances the accuracy and efficiency of determining the target column during drag operations.
It also removes redundant code and simplifies the logic in both the DragDropManager and AllDayManager.
2025-09-28 13:25:09 +02:00
Janus C. H. Knudsen
9dfd4574d8 Improves drag and drop for timed and all-day events
Refactors drag and drop handling to use a cloned event element,
ensuring correct positioning and styling during drag operations
for both regular timed events and all-day events.

This change streamlines the drag and drop process by:
- Creating a clone of the dragged event at the start of the drag.
- Passing the clone through the drag events.
- Handling all-day events with the AllDayManager
- Handling regular timed events with the EventRendererManager

This resolves issues with event positioning and styling during
drag, especially when moving events across columns or between
all-day and timed sections.
2025-09-26 22:53:49 +02:00
Janus C. H. Knudsen
48d1fd681c Major refactor into type safe TS
With a risk oof rolling it all back
2025-09-23 20:44:15 +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
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
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 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
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
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