GuavaCZ / calendar

MIT License
140 stars 13 forks source link

[Request]: Conditional extendedProps for event #29

Closed danhvu02 closed 3 months ago

danhvu02 commented 3 months ago

What feature would you like to add?

I have Course model and Session model. The relationship is course has many sessions. I have a CourseCalendarWidget where I display all sessions for a specific course. Because I show this widget inside the view page of the course, so I don't have to add info about the course to extendedProps such as course_name, staff ... Howerver, I have a MasterCalendarWidget where I display all sessions for all courses. In this page, I want to add props like course_name, staff, ... to the event My question is inside toEvent() method, is it possible to have conditional extendedProps only when I needed?

Notes

No response

lukas-frey commented 3 months ago

No not possible. You have two widgets, just filter out the unneeded props in the getEvents method of the widget.

Or add an optional parameter with a default value to the toEvent method and in one of the getEvents method, map the events using the toEvent method yourself and call the correct parameter to the method which you can use to conditionally choose what to include.

danhvu02 commented 3 months ago

The second option works for me. Thank you so much!!