Skip to main content

AgendaViewModel

The ViewModel subclass behind the built-in "agenda" view (PRO). Pre-registered under the id "agenda". Subclass it to derive list-style views (e.g. "next 14 days", "by category") that reuse the agenda layout.

PRO

The functionality is available in PRO Edition only

Usage

import { AgendaViewModel } from "@svar-ui/vue-calendar";

class MyAgenda extends AgendaViewModel {
// override points
}

Override points

MethodSignatureBehavior
getSections()() => Section[]Returns one section: { name: "agenda", mode: "list", size: 1 }.
rangeStart(date)(date: Date) => DateReturns the first day of the month at 00:00.
addRange(date, n)(date: Date, n: number) => DateReturns date + n months, anchored to day 1.
getRangeLabel()() => stringFormatted month label via fmt("titleMonthFormat").
process(events)(events: CalendarEvent[]) => SectionResult[]Full override of the pipeline - filters events to the month range and sorts by start then end time.
configure(sections)(sections: Record<string, any>) => voidDeep-merges views[].sections overrides into the section definitions.

Inside the subclass this.startDate, this.endDate, and this.fmt(pattern) are available.

Registration

AgendaViewModel is pre-registered as "agenda" when the package loads. Register a subclass under a new id with registerCalendarView:

import {
AgendaViewModel,
registerCalendarView,
} from "@svar-ui/vue-calendar";

class FortnightAgenda extends AgendaViewModel {
rangeStart(date: Date): Date {
const d = new Date(date);
d.setHours(0, 0, 0, 0);
return d;
}

addRange(date: Date, n: number): Date {
const d = new Date(date);
d.setDate(d.getDate() + n * 14);
return d;
}
}

registerCalendarView("fortnight", FortnightAgenda);
<Calendar :events="events" view="fortnight" :views="['fortnight', 'month']" />