-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added fullDay default duration for events #52
Conversation
There was a problem hiding this 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
server/services/service.js
Outdated
@@ -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' |
There was a problem hiding this comment.
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
server/services/service.js
Outdated
@@ -81,7 +81,9 @@ module.exports = () => ({ | |||
startDate: x[config.startField], |
There was a problem hiding this comment.
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?
change formatting from tab to spaces
Fix indenting
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 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 |
admin/src/pages/settings.js
Outdated
@@ -61,6 +61,7 @@ function Settings() { | |||
titleField: null, | |||
colorField: null, | |||
defaultDuration: 30, | |||
defaultStartTime: '12:00', |
There was a problem hiding this comment.
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
admin/src/pages/settings.js
Outdated
@@ -372,7 +379,7 @@ function Settings() { | |||
))} | |||
</Select> | |||
</GridItem> | |||
</Grid> | |||
</Grid> |
There was a problem hiding this comment.
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
server/services/service.js
Outdated
color: config.colorField ? x[config.colorField] : null, | ||
})); | ||
return dataFiltered.map((x) => { | ||
const startDate = x[config.startField].split('T')[0]; |
There was a problem hiding this comment.
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?
…f time zones using moment().
Code looks good but the build failed, could you run |
Revert ESLint version to match master branch
071df13
to
9d21648
Compare
There was a problem hiding this 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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ..
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. |
Code is flawless, thank you Jacob.
Fee free to join the conversation here |
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