-
Notifications
You must be signed in to change notification settings - Fork 8.6k
DEV: full calendar v6 #33737
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
DEV: full calendar v6 #33737
Conversation
55dbfa9
to
1e0ae7c
Compare
d82141e
to
2caa2af
Compare
@@ -30,7 +30,7 @@ export default class DownloadCalendar extends Component { | |||
this.args.model.calendar.title, | |||
this.args.model.calendar.dates, | |||
{ | |||
recurrenceRule: this.args.model.calendar.recurrenceRule, |
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.
just using the same rrule name everywhere
render json: | ||
ActiveModel::ArraySerializer.new( | ||
@events, | ||
each_serializer: serializer, | ||
each_serializer: BasicEventSerializer, |
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.
always using the same serializer for lists, technically that could break stuff, but I didn't find anything
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 this has potential to strip fields that our frontend isn't using, but customers are relying on externally (not sure, I didn't compare field-by-field yet). Context from Meta: /t/-/287566/14
@@ -124,6 +121,8 @@ def filtered_events_params | |||
:limit, | |||
:before, | |||
:attending_user, | |||
:before, |
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.
we only had before, I added after to be able to have a range
@@ -59,40 +59,19 @@ def create_or_update_event_date | |||
|
|||
return if !starts_at_changed && !ends_at_changed | |||
|
|||
event_dates.update_all(finished_at: Time.current) |
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 was fixing a bug introduced months ago which was causing recurring events to be marke as finished
@@ -59,40 +59,19 @@ def create_or_update_event_date | |||
|
|||
return if !starts_at_changed && !ends_at_changed | |||
|
|||
event_dates.update_all(finished_at: Time.current) | |||
set_next_date | |||
end | |||
|
|||
def set_next_date |
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.
just a full refactoring of these methods
end | ||
|
||
def starts_at | ||
# For recurring events, use the original start time to be consistent with rrule |
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.
that was a bug we have had for a long time, but now that we use rrule everywhere we can just use the original start
), | ||
this.siteSettings | ||
); | ||
schedule("afterRender", () => { |
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.
without this the dates are not in the DOM yet at this point
<Description @description={{@event.description}} /> | ||
{{#if @event.canUpdateAttendance}} | ||
<Status @event={{@event}} /> | ||
<AsyncContent @asyncData={{this.loadEvent}}> |
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.
the biggest change is to make it possible to load an event if not provided as param
@@ -0,0 +1,165 @@ | |||
import Component from "@glimmer/component"; |
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 was all in JS/DOM code before, I made it a proper component
/> | ||
</template>; | ||
|
||
export default class FullCalendar extends Component { |
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.
same this was all JS/DOM code before
@@ -1,163 +1,9 @@ | |||
.discourse-calendar-wrap { |
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 removed most styling as things changed too much
@@ -12,4 +12,17 @@ | |||
desaturate(lighten($tertiary, 40%), 20%), | |||
darken($tertiary, 10%) | |||
)}; | |||
--fc-border-color: var(--primary-low); |
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 is where most styling is decided for the full calendar now
@@ -4,85 +4,154 @@ module DiscoursePostEvent | |||
class EventFinder | |||
def self.search(user, params = {}) | |||
guardian = Guardian.new(user) | |||
|
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.
refactored the whole file and added few filtering options
@@ -2,3 +2,5 @@ export { Calendar } from "@fullcalendar/core"; | |||
export { default as DayGrid } from "@fullcalendar/daygrid"; |
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 file allows to efficiently load the full calendar when needed
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.
plugins/discourse-calendar/app/serializers/discourse_post_event/basic_event_serializer.rb
Outdated
Show resolved
Hide resolved
plugins/discourse-calendar/app/serializers/discourse_post_event/event_serializer.rb
Show resolved
Hide resolved
plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
Outdated
Show resolved
Hide resolved
plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
Outdated
Show resolved
Hide resolved
plugins/discourse-calendar/assets/javascripts/discourse/components/post-calendar.gjs
Outdated
Show resolved
Hide resolved
|
||
// header is now generated in the component | ||
// remove the old header generated when cooking if it exists | ||
element.querySelector(".discourse-calendar-header")?.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.
I feel like there can't be many of these in the wild...maybe we mark these posts for rebake in a migration so we can remove this at some point?
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.
Also fine if not, just would be good if we didn't have to keep forever
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.
No it should be good to use const here, const allows mutation, but not reassignement:
> const test = [];
> undefined
> test.push(1);
> 1
plugins/discourse-calendar/assets/javascripts/discourse/initializers/discourse-calendar.gjs
Outdated
Show resolved
Hide resolved
plugins/discourse-calendar/assets/javascripts/discourse/initializers/discourse-calendar.gjs
Outdated
Show resolved
Hide resolved
@@ -47,18 +47,10 @@ discourse_calendar: | |||
default: 2 |
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.
Need a DB migration to cleanup all these removed settings from the site_settings
table
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.
Ah yes right, thanks.
plugins/discourse-calendar/lib/discourse_post_event/event_finder.rb
Outdated
Show resolved
Hide resolved
ed52080
to
5ec5caa
Compare
This commit makes the following changes: