PhoenixKitCalendar (PhoenixKitCalendar v0.1.0)

Copy Markdown View Source

Personal calendars for PhoenixKit — one implicit calendar per user, with fine-grained permissions over other people's calendars.

Permission model

This module is the reference consumer of PhoenixKit's fine-grained sub-permissions:

KeyGrants
calendarThe calendar admin page + full control of YOUR OWN calendar
calendar.view_othersRead-only access to other users' calendars
calendar.edit_othersCreate/edit/delete events on other users' calendars

Typical role setup (created in /admin/users/roles, granted in the permissions matrix):

  • Employeecalendar (own calendar only)
  • Junior Managercalendar + calendar.view_others
  • Bosscalendar + calendar.view_others + calendar.edit_others

Admin and Owner hold every key by default (Owner always; Admin via seeding/auto-grant, revocable by the Owner in the matrix).

Authorization happens at the context layer (PhoenixKitCalendar.Events) — every function takes the caller's scope and checks it against the event's owner, so the rules hold no matter which UI drives it.

Data model

phoenix_kit_calendar_events (core migration V141): events keyed by owner_uuid (CASCADE on user delete). Timed events store an exclusive-end UTC pair; all-day events store an exclusive-end DATE pair ([start, end), iCal-style — matching phoenix_live_calendar). Recurrence is deliberately out of scope for v1.

UI

/admin/calendar renders the month view via the standalone phoenix_live_calendar library (server-rendered; JS hooks are optional progressive enhancement). Users holding calendar.view_others get a person switcher listing all active users — including people who no longer hold calendar access, so an admin can always review old events — annotated with whether each user has events and whether they currently hold calendar access.

Summary

Functions

Admin sidebar tab. The route is auto-generated from live_view.

OTP apps whose templates Tailwind should scan for CSS classes.

Disables the module. Same pattern as enable_system/0.

Enables the module by persisting a boolean setting.

Whether the module is currently enabled.

Unique key for this module. Used in settings, permissions, and PubSub events.

Display name shown in the admin UI.

Permission metadata for the roles/permissions matrix.

Version string. Shown on the admin Modules page. Reads the app spec so it can't drift from mix.exs.

Functions

admin_tabs()

Admin sidebar tab. The route is auto-generated from live_view.

css_sources()

OTP apps whose templates Tailwind should scan for CSS classes.

disable_system()

Disables the module. Same pattern as enable_system/0.

enable_system()

Enables the module by persisting a boolean setting.

enabled?()

Whether the module is currently enabled.

Reads from the DB-backed settings table; defensive against DB unavailability around startup (all failure branches return false).

module_key()

Unique key for this module. Used in settings, permissions, and PubSub events.

module_name()

Display name shown in the admin UI.

permission_metadata()

Permission metadata for the roles/permissions matrix.

Declares the base calendar key plus the two fine-grained sub-permissions gating access to OTHER users' calendars. Sub-keys are stored as "calendar.view_others" / "calendar.edit_others" and checked in the Events context via PhoenixKit.Users.Auth.Scope.can?/2.

version()

Version string. Shown on the admin Modules page. Reads the app spec so it can't drift from mix.exs.