@weaver-apps/calendar
v0.8.1
Published
The calendar app's weaver for a LoomWeaver distribution: a calendar's appointments by week, booking, editing, cancelling and deleting, behind a gateway the host supplies.
Readme
@weaver-apps/calendar
The calendar app's weaver for a LoomWeaver distribution: a calendar's appointments by week, booking, editing, cancelling and deleting. It talks to the Weaver Apps server through a gateway the host supplies, and holds no key.
Compose it
import {
calendarPluginId,
createCalendarPlugin,
createHttpCalendarGateway,
provideCalendarGateway,
} from '@weaver-apps/calendar';
provideTranslationNamespaces(calendarPluginId),
provideCapabilityGrants({ [calendarPluginId]: ['contributions', 'navigation', 'ui'] }),
...providePlugins(createCalendarPlugin({ railItem: true })),
provideCalendarGateway(createHttpCalendarGateway({ baseUrl: '/weaver-apps' })),baseUrlis a same-origin path the host's backend forwards to the server, adding the forwarding key and the signed-in person's tenant (X-API-Key,X-Act-For-Tenant). The gateway appends the server's own routes, such as/calendar/calendars/{id}/appointments.- Serve the translations: the package carries them under
i18n/weaver-apps-calendar; add an assets glob that copiesnode_modules/@weaver-apps/calendar/i18n/weaver-apps-calendartoi18n/weaver-apps-calendar. - Install AG Grid, a peer dependency the list is drawn with:
npm i ag-grid-community@^36.2 ag-grid-angular@^36.2 @ag-grid-community/locale@^36.2.@weaver-apps/data-grid, the grid both Weaver Apps weavers share, comes along as a dependency; the host composes nothing for it. - If the host compiles the shell's theme with Tailwind, add the package and
@weaver-apps/data-gridas an@source.
Titles from the host
By default a calendar is headed and listed by the name stored with it. A host that names calendars itself, say in the reader's language, hands those titles to the weaver:
import { provideCalendarTitles } from '@weaver-apps/calendar';
provideCalendarTitles(() => {
const names = inject(MyCalendarNames);
return (calendarId) => names.titleOf(calendarId);
}),- The factory runs in the host's injection context, so it may
injectwhat it needs. - The returned function answers a calendar id with a title, or
null(or a blank string) when the host has none. The calendar page's heading and the list then show the host's title, otherwise the stored name, and while neither is known the weaver's own translated title. - The weaver calls the function inside a
computed. Every signal it reads, such as the host's active language, is tracked, so a changed title re-titles the open page. A host with an observable turns it into a signal withtoSignalfirst. - The function runs for every listed calendar whenever a signal it reads changes; keep it a lookup.
Names in the host
The plugin id is weaver-apps-calendar (calendarPluginId). Every id the plugin registers and every icon
it contributes starts with weaver-apps-calendar., its routes live under weaver-apps-calendar/, and its
translations are the namespace weaver-apps-calendar. The ids are exported as calendarContributionIds.
| Id | Path | What it shows |
|---|---|---|
| weaver-apps-calendar.calendars | weaver-apps-calendar | the tenant's calendars |
| weaver-apps-calendar.calendar | weaver-apps-calendar/:calendarId | one calendar's appointments, a week at a time |
| weaver-apps-calendar.rail | | the rail item, only with railItem: true |
A calendar's week is a grid: a click on a column header sorts it (earliest first by default), and the status column filters by any number of statuses.
calendarPath(id) builds the address of one calendar; a host that shows one entry per calendar navigates
there. createCalendarPlugin({ railItem: true }) adds a rail item that opens the list; without it the host
decides where the calendar is reached from.
Moving from 0.1.x
0.2.0 draws the list with AG Grid, so a host installs it (see above). It also renamed everything the plugin puts
into a host; a host composing it changes three places: the key of
its capability grant (calendar becomes weaver-apps-calendar), the translation namespace it declares, and
the folder it serves the translations from (i18n/calendar becomes i18n/weaver-apps-calendar). Addresses
saved under calendar/... no longer resolve; build them with calendarPath.
