offset-dev / strapi-calendar

Visualize your Strapi content in month, week or daily view
37 stars 13 forks source link

Added fullDay default duration for events #52

Closed Jacob-Daniel closed 1 month ago

Jacob-Daniel commented 1 month ago

Changes Implemented fullDay functionality for the Calendar to support events spanning multiple days. Updated the default behaviour to handle multi-day events in a 'Booking' collection type.

Testing Tested functionality in the month view successfully. Bookings were correctly displayed across the appropriate duration of days. Clicking on an event correctly redirects to the corresponding Booking details page in Strapi.

Error Encountered an error when switching between calendar views (e.g., from month to week or day view), unrelated to the fullDay changes. The error (Uncaught TypeError: Cannot read properties of undefined (reading 'end')) was reproduced on a fresh install. A separate issue will be opened to track this bug.

Versions Strapi version: 4.25.11 Calendar plugin version: ^0.1.2 Node version: v20.17.0

Jacob-Daniel commented 1 month ago

Hi Luis,

I believe I have pushed to the same branch, do you not see it?

https://github.com/offset-dev/strapi-calendar/compare/master...Jacob-Daniel:strapi-calendar:add-fullDay-duration

I hope I have resolved the above issues, here is an outline.

The logic to determine all-day events has been adjusted. Specifically, if an event is deemed full-day, we only use the date part of the startField, ensuring the start and end dates are treated as:

startDate: ${startDate}T00:00:00 endDate: ${endDate}T23:59:59 This ensures that the calendar visually represents the entire day block, allowing events to visually span across multiple days correctly.

The default duration is now set to 1440.

"If the event is fullDay, shouldn't it also affect the start?"

Yes, I addressed this by ensuring that for all-day events, the start time is set to midnight (T00:00:00) and the end time is set to one second before the next day (T23:59:59). This change guarantees that the event fills the entire day block on the calendar.

Please let me know what you think, if we need to do any further adjustments etc.

Jacob

LuisRodriguezLD commented 1 month ago

Code looks good but the build failed, could you run npm run lint:fix and push the changes?

Jacob-Daniel commented 1 month ago

Louis, I think you mentioned a new release? Do you have an out-line of goals/ objectives? Just, as you know I am using your plugin and there maybe features I would like to contribute. Thanks for your recent help.

LuisRodriguezLD commented 1 month ago

Code is flawless, thank you Jacob. Regarding the next major version, I published a beta a few weeks ago, the work is here. I don't have specific goals or objectives other than

  1. change calendar library
  2. TS support everywhere
  3. use new strapi plugin sdk
  4. strapi5 compat

Fee free to join the conversation here

Jacob-Daniel commented 2 weeks ago

Hi Luis,

I’m looking to test the version 1 beta of the FullCalendar Strapi plugin, and I noticed that the fullDay duration option is not available in this version. I wanted to clarify a few things:

Strapi V4 vs V5 Focus: Is the develop branch primarily focused on supporting Strapi v4, while version 1 targets Strapi v5, or is there a goal to eventually consolidate the two?

Calendar Options: Given that there are relatively few calendar options available in the plugin, is the intention for developers to contribute additional FullCalendar library options (such as validRange, initialDate, etc.)?

Specifically, my current need is to control the calendar range like so:

validRange={{
  start: '2024-06-01',
  end: '2024-08-31',
}}
initialDate="2024-06-01"

If you prefer, I can post this in the version 1 thread, but I wanted to clarify these points with you first.

Thanks for your help!

LuisRodriguezLD commented 2 weeks ago

Hey Jacob, thanks for reaching out!

Strapi V4 vs V5 Focus: Is the develop branch primarily focused on supporting Strapi v4, while version 1 targets Strapi v5, or is there a goal to eventually consolidate the two?

Think of the v1 branch as a feature branch to make the plugin Strapi5 ready. I haven't heard issues so I'm creating a PR towards main & develop later this week

Calendar Options: Given that there are relatively few calendar options available in the plugin, is the intention for developers to contribute additional FullCalendar library options (such as validRange, initialDate, etc.)?

That is correct. As of know, most features from v0 are available in v1 (except for the full day feature). Developers should contribute using the FullCalendar library

You can create a new feature from the v1 branch and as soon as it lands in develop you can create a PR towards develop

Jacob-Daniel commented 2 weeks ago

Thanks Luis, that makes sense. I will comment on the v1 thread stating intentions.