Skip to main content

CnObjectCalendar

Month calendar that plots objects by a date property (dateField), with optional day-spanning via endDateField. Navigating months emits range-change so the host can (re)fetch objects for the newly visible window — the component never fetches anything itself.

Try it

Loading CnObjectCalendar playground…

Props

Props

NameTypeRequiredDefaultDescription
objectsArray<object>[]Objects to plot. Expected to already be scoped to the visible range — e.g. the response of GET /api/views/{id}/calendar?start=&end=.
dateFieldstringThe date property an object is plotted on.
endDateFieldstringnullOptional end-date property — when set, an object spans dateField..endDateField.
visibleDateunionnullAny day within the currently visible month (.sync-compatible). Defaults to today when omitted.
titleFieldstringnullObject property used as a title fallback and as each object's identity.
rowKeystring'id'Object property used as each object's identity (for :key and click payload matching).
loadingbooleanfalseLoading state (host is (re)fetching the visible range).
maxEventsPerDaynumber3Maximum events shown per day cell before "+N" overflow.

Events

NamePayloadDescription
object-clickEmitted when a plotted object is clicked.
range-changeEmitted on mount and after every month navigation so the host can re-fetch objects for the new window.
update:visibleDateEmitted on month navigation, for v-model:visible-date binding.

Slots

NameBindingsDescription
day-eventobject, dayday-event Override a single day's event entry.

Besides objects/dateField/endDateField/visibleDate above: titleField picks the object property shown as an event's label (falls back to title/name/the row key); rowKey is the object property used as each object's identity (defaults to id); maxEventsPerDay caps how many events a day cell shows before a "+N" overflow.

Fetching pattern

objects is expected to already be scoped to the visible range — typically the response of OpenRegister's GET /api/views/{id}/calendar?start=&end=. Wire range-change (fired on mount and after every month navigation) to a re-fetch:

<CnObjectCalendar
:objects="objects"
date-field="dueDate"
end-date-field="endDate"
v-model:visible-date="visibleDate"
:loading="loading"
@range-change="fetchCalendarObjects"
@object-click="openObject" />
async fetchCalendarObjects({ rangeStart, rangeEnd }) {
this.loading = true
const { data } = await axios.get(url, { params: { start: rangeStart, end: rangeEnd } })
this.objects = data.objects
this.loading = false
},

The emitted rangeStart/rangeEnd cover the full displayed grid (the month padded to whole Sunday–Saturday weeks), matching the query parameters the OpenRegister calendar endpoint expects.

Slots

  • #day-event="{ object, day }" — override a single day's event entry (default renders the object's title).