The Y PEF Schedule module provides a calendar functionality for scheduling events.
It includes a Vue.js component, fullcalendar-app
, to display and interact with the calendar.
Requirements
Installation
composer require ycloudyusa/y_pef_schedule
drush en y_pef_schedule lb_simple_schedule
- Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.
- Enable the module by navigating to Admin > Extend (
/admin/modules
) in your Drupal admin interface, then enabling "Y PEF Schedules Admin tool" and "LB Simple Schedule".
Configuration
- Configure the calendar settings at Admin > YMCA Website Services > Settings > Schedules calendar settings (
/admin/openy/settings/schedules-calendar
) - Go to Admin > Content > Schedules Calendar (
/admin/openy/branch-schedules
) and select a branch.
After choosing a branch, you can view the calendar. The calendar features include:
- Viewing events in weekly or daily format.
- Viewing the main information of the event (by clicking on the event).
- Creating a new event (using the Session Content Type).
- Updating existing events.
- Downloading the schedule in PDF format.
- Filtering results by categories.
Showing the calendar on a page
Once you have added sessions to a calendar, you can add the calendar block to a Layout Builder page to display on the site. Ensure the "LB Simple Schedule" is enabled first.
- Edit the Layout of a Layout Builder page (Branch, Landing Page, etc).
- Create or find a section, then Add Block.
- Choose Add custom/content block then Simple Schedule.
- Add a Title and choose a Branch to populate the calendar.
- Save the block and the page.
Customization
A few options are available for advanced customization of the calendar.
Retrieving Events
The module provides controllers to handle AJAX requests for fetching events. To create a custom request, use the following route in your JavaScript code:
axios.get('/fullcalendar-api/get-event-data-date-range/{location}/{start}/{end}/{category}')
.then(response => {
const events = response.data;
// Process the received events as needed
})
.catch(error => {
console.error('Error fetching events:', error);
});
Replace {location}
, {start}
, {end}
, and {category}
with the appropriate values.
Creating Events
The fullcalendar-app
component allows users to create events interactively. When a date is clicked, a modal form is displayed for users to enter event details such as title, category, time, and date.
To customize the form or extend the functionality, refer to the Vue.js component documentation and customize the handleDateClick and createEvent methods in the fullcalendar-app component.
Troubleshooting
Known issues
- After creating a series of events, it is created, but only one event is displayed in the calendar, the page must be refreshed to see the correct data
- The color is fixed to the session and not to the category
- PDF format is A3