Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fullDay default duration for events #52

Merged
merged 11 commits into from
Oct 14, 2024

Conversation

Jacob-Daniel
Copy link

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

Copy link
Contributor

@LuisRodriguezLD LuisRodriguezLD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR,
I've left a few comments, let me know if you have questions

admin/src/pages/settings.js Outdated Show resolved Hide resolved
@@ -81,7 +81,9 @@ module.exports = () => ({
startDate: x[config.startField],
endDate: config.endField
? x[config.endField]
: moment(x[config.startField]).add(config.defaultDuration, 'minutes'),
: config.defaultDuration === 'fullDay'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default duration will never be fullDay, you would need to compare to that value which is 1440

@@ -81,7 +81,9 @@ module.exports = () => ({
startDate: x[config.startField],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@LuisRodriguezLD LuisRodriguezLD changed the base branch from master to develop October 2, 2024 15:50
@LuisRodriguezLD LuisRodriguezLD added the waiting for op Needs action from the original poster label Oct 3, 2024
Jacob-Daniel and others added 3 commits October 3, 2024 13:24
change formatting from tab to spaces
Fix indenting
@Jacob-Daniel
Copy link
Author

Jacob-Daniel commented Oct 3, 2024

Hi Luis,

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

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

@@ -61,6 +61,7 @@ function Settings() {
titleField: null,
colorField: null,
defaultDuration: 30,
defaultStartTime: '12:00',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of now, there's no way for users to edit this so let's remove it and uses moment instead

@@ -372,7 +379,7 @@ function Settings() {
))}
</Select>
</GridItem>
</Grid>
</Grid>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this whitespace is unnecessary

color: config.colorField ? x[config.colorField] : null,
}));
return dataFiltered.map((x) => {
const startDate = x[config.startField].split('T')[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could yield different results depending on the timezone,
could we use moment().startOf('day') and moment().endOf('day') instead?

server/services/service.js Outdated Show resolved Hide resolved
admin/src/pages/settings.js Show resolved Hide resolved
server/services/service.js Show resolved Hide resolved
@LuisRodriguezLD
Copy link
Contributor

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

Copy link
Contributor

@LuisRodriguezLD LuisRodriguezLD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is solid. Let's just clean up before we merge.
Thank you for your time

pnpm-lock.yaml Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should not be here. We use yarn.
Please remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, sorry for that ..

package.json Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the lint script updated this file by mistake. could you revert the change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my last push looks okay now, again sorry for that ..

package-lock.json Outdated Show resolved Hide resolved
@Jacob-Daniel
Copy link
Author

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
Copy link
Contributor

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

@LuisRodriguezLD LuisRodriguezLD merged commit 16a41cb into offset-dev:develop Oct 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for op Needs action from the original poster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants