Calendar Layout Component: Complete example
Back to Calendar Layout Component.
Complete example
Section titled “Complete example”A system with a module appointments (fields: title string, period dateRange, status select with confirmed
and tentative, owner relation to users) and a module employees with a birthdate date field and a repeat field.
The layout puts a full width calendar into a tab:
{ "tabs": [ { "identifier": "calendar", "rows": [ { "cols": [ { "span": 24, "components": [ { "type": "calendar", "options": { "default_view": "week", "available_views": ["day", "week", "month", "list"], "week_numbers": true, "height": "75vh", "events": [ { "identifier": "appointments", "module": "appointments", "field": "period", "color": "#1890ff", "icon": "team", "quick_create": true, "recipes": { "title": "this.title", "color": "this.status == 'confirmed' ? '#1890ff' : '#faad14'" } }, { "identifier": "my_appointments", "module": "appointments", "field": "period", "color": "#722ed1", "editable": false, "pre_filters": [ {"column": "owner.id", "operator": "=", "recipe": "user().id"} ], "recipes": { "title": "this.title" } }, { "identifier": "birthdays", "module": "employees", "field": "birthdate", "color": "#4adeff", "text_color": "rgba(0, 0, 0, 0.85)", "editable": false, "recurrence_field": "repeat", "recipes": { "title": "'Birthday: ' + this.first_name + ' ' + this.family_name", "recurrence": "this.repeat" } } ] } } ] } ] } ] } ]}To label the sidebar entries, add translations for the event type identifiers, for example under calendar.appointments,
calendar.my_appointments and calendar.birthdays in your translation files.
For the birthdays to repeat, each employee needs repeat set to yearly.
Legacy mode
Section titled “Legacy mode”If a calendar component has no events option, it works in the older mode of the built-in Calendar page: event types
come from the field options show_in_calendar, calendar_color, calendar_title, calendar_recurrence,
quick_create_in_calendar and create_in_calendar of the date fields, and a “Create” button is shown above the
calendar. New layouts should use events.
Troubleshooting
Section titled “Troubleshooting”- The calendar is empty. Check that
moduleandfieldare spelled exactly like the identifiers in the module, that the field is of typedate,datetimeordateRange, and that your user may read the module. The sidebar shows only event types that were set up successfully. - Events have no text. Add a
titlerecipe. - Repeating events disappear when navigating. Set
recurrence_field, see Recurring events. - Option has no effect. Options are
snake_case(default_view, notdefaultView).