domma-cms 1.35.0 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/admin/js/api.js +1 -1
- package/admin/js/app.js +2 -2
- package/admin/js/lib/image-editor.js +1 -1
- package/admin/js/lib/media-arrange.js +1 -1
- package/admin/js/lib/media-picker.js +2 -2
- package/admin/js/lib/media-upload.js +1 -1
- package/admin/js/lib/seo-redirects.js +1 -1
- package/admin/js/templates/docs/usage-media.html +6 -0
- package/admin/js/templates/media.html +1 -0
- package/admin/js/views/media.js +3 -3
- package/bin/lib/left-free-tier.js +4 -1
- package/bin/update.js +4 -0
- package/docs/DommaFeatures.md +10 -5
- package/docs/plugin-development.md +2 -2
- package/package.json +1 -1
- package/plugins/docs/tests/plugin.test.js +2 -0
- package/plugins/free-tier.lock.json +2 -50
- package/server/routes/api/media.js +3 -1
- package/server/routes/api/sidebar.js +2 -2
- package/server/services/content.js +26 -2
- package/server/services/hooks.js +27 -4
- package/server/services/plugins.js +9 -3
- package/server/services/renderer.js +3 -1
- package/server/services/siteGitignore.js +1 -1
- package/plugins/booking/CLAUDE.md +0 -204
- package/plugins/booking/admin/css/index.css +0 -192
- package/plugins/booking/admin/lib/details.js +0 -58
- package/plugins/booking/admin/lib/diary-layout.js +0 -158
- package/plugins/booking/admin/lib/drafts.js +0 -139
- package/plugins/booking/admin/lib/email.js +0 -191
- package/plugins/booking/admin/lib/extension-sections.js +0 -160
- package/plugins/booking/admin/lib/kit.js +0 -471
- package/plugins/booking/admin/templates/booking.html +0 -1
- package/plugins/booking/admin/views/booking.js +0 -216
- package/plugins/booking/admin/views/bookings.js +0 -132
- package/plugins/booking/admin/views/diary.js +0 -382
- package/plugins/booking/admin/views/panels.js +0 -603
- package/plugins/booking/admin/views/people.js +0 -318
- package/plugins/booking/admin/views/services.js +0 -264
- package/plugins/booking/admin/views/settings.js +0 -222
- package/plugins/booking/collections/booking-bookables.json +0 -17
- package/plugins/booking/collections/booking-bookings.json +0 -18
- package/plugins/booking/collections/booking-services.json +0 -17
- package/plugins/booking/config.js +0 -36
- package/plugins/booking/docs/guide.md +0 -73
- package/plugins/booking/inject/body.html +0 -1
- package/plugins/booking/lib/call.js +0 -88
- package/plugins/booking/lib/extensions.js +0 -169
- package/plugins/booking/lib/mail.js +0 -113
- package/plugins/booking/lib/store.js +0 -392
- package/plugins/booking/plugin.js +0 -905
- package/plugins/booking/plugin.json +0 -81
- package/plugins/booking/plugin.public.js +0 -175
- package/plugins/booking/public/booking.css +0 -159
- package/plugins/booking/public/booking.js +0 -808
- package/plugins/booking/public/lib/clean.js +0 -141
- package/plugins/booking/public/lib/page-format.js +0 -121
- package/plugins/booking/public/lib/slots.js +0 -247
- package/plugins/booking/public/lib/time.js +0 -131
- package/plugins/booking/templates/booking.html +0 -5
- package/plugins/booking/tests/admin-diary.test.js +0 -81
- package/plugins/booking/tests/admin-drafts.test.js +0 -67
- package/plugins/booking/tests/api.test.js +0 -651
- package/plugins/booking/tests/email.test.js +0 -69
- package/plugins/booking/tests/public.test.js +0 -72
- package/plugins/booking/tests/pure.test.js +0 -189
- package/plugins/booking/tests/seo.test.js +0 -71
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
# booking - AI Assistant Guide
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
|
|
5
|
-
Appointments and resources booked from the site. 1.0.0 (2026-09-30): people (appointments with you or your team)
|
|
6
|
-
and resources (rooms, equipment) with weekly hours, days off and business-wide closed days; services with a length,
|
|
7
|
-
buffers before and after, a start step, notice and how far ahead; a public booking page at a configurable address
|
|
8
|
-
(`/booking`) and the `[booking /]` shortcode; confirmation, reminder and owner emails with an .ics; a private link for
|
|
9
|
-
the customer to move or cancel within the notice; a Diary (day / week), a Bookings list, Services and People & rooms
|
|
10
|
-
in the admin; a sidebar badge for bookings still to come today (none left: the next 7 days' bookings, as an inventory).
|
|
11
|
-
|
|
12
|
-
Links to other Tools, each absent when that Tool is: customers become contacts (the booked person's address book,
|
|
13
|
-
else the settings' owner, else whoever booked); "Book {name}…" on a contact's menu and a Bookings panel on the
|
|
14
|
-
contact card (core `registerRelatedItems('contact')`); "Book {name}…" on an email's menu in Email / Mail Reader
|
|
15
|
-
(core 0.103 `registerRelatedItems('message')`; an older core ignores it); a Bookings calendar source; a person's own
|
|
16
|
-
Calendar events block their times (read from `calendar-occurrences` / `calendar-events` through the collections
|
|
17
|
-
service - no import of the Calendar, which is a separate paid Tool).
|
|
18
|
-
|
|
19
|
-
`tier: free`, ships with the engine, disabled on arrival. Plan and phases: `dcms-marketplace/docs/booking-plan.md`.
|
|
20
|
-
Booking Pro (marketplace `booking-pro`, 0.4.x) is an ADD-ON that registers into this one (`lib/extensions.js`), the
|
|
21
|
-
Cart / Cart Pro pattern - it does not supersede it. Neither takes payment yet.
|
|
22
|
-
|
|
23
|
-
1.6.0 (2026-09-30): "Add people" in an online booking's call (core with `server/services/callInvites.js` and
|
|
24
|
-
`_lib/call/invite.js`; both imported dynamically - lib/call.js by top-level `await import`, plugin.js beside
|
|
25
|
-
`mountCallRoutes` - so an older core simply has no button). The HOST (the person's host link) searches the contacts
|
|
26
|
-
of the person's linked ACTIVE account (`hostUserOf`) and the team, and invites contacts, team members or any name +
|
|
27
|
-
email. With NO linked account the host link may be held by an outsider (it goes to the person's email address and
|
|
28
|
-
the .ics), so resolve answers `inviteOptions: {search: false, typed: false, copyLink: true}` - Copy link only: no
|
|
29
|
-
directory, no contacts, nothing sent (the engine and `send` both refuse people). Links use core's `inviteOrigin`
|
|
30
|
-
(`site.baseUrl` first).
|
|
31
|
-
Each invitee gets their OWN pass `?b=<booking>&g=<nonce>.<hmac>` signed with the session's `callExtraKey` - made on the
|
|
32
|
-
first invite and written to EVERY booking of the session (`changeBooking` patch, online only, never replaced; the
|
|
33
|
-
stored key is re-read after writing, so two sends at once agree), never the customer's token or the host key (a
|
|
34
|
-
customer token carries their name and identity: an invitee would replace them). `whoIsCalling` answers `{host: false,
|
|
35
|
-
name: '', identity: '<session>:inv:<nonce>', invited: true}` for a pass; the page asks their name; they knock. Core
|
|
36
|
-
sends (Join email, a notification + a DM from the person's user for team members). `adminBooking` strips
|
|
37
|
-
`callExtraKey`. Tests: tests/api.test.js "1.6 Add people" (a linked host; a host with no account).
|
|
38
|
-
|
|
39
|
-
1.5.0 (2026-09-30): the call's chat is saved per SESSION (`sessionOf` - a class's shared call has one chat) in
|
|
40
|
-
`data/call-chat.json` (`options.dataDir` in tests) through core's `_lib/call/chatStore.js` (dynamic import beside
|
|
41
|
-
`mountCallRoutes`; an older core has none and nothing changes), passed as the engine's `chat` - so the call reopened
|
|
42
|
-
shows it. `GET /bookings/:id` adds `callChat` (typed messages) on online bookings; `GET /bookings/:id/call-chat`
|
|
43
|
-
(booking.read; 404 unless online) answers `{messages, items}` without participant ids, the session's host lines
|
|
44
|
-
(`whoOf('<bookingId>:host')` for each booking of the session) marked `mine`. The panel (`openBooking`) shows "Call chat
|
|
45
|
-
(N messages)" when N > 0 and opens `/plugins/_lib/admin/ui/transcript.js` (read-only, domma-reactive). The customer
|
|
46
|
-
has no admin view of it. Kept: 500 items a session, the 1000 most recent sessions. Tests: tests/api.test.js.
|
|
47
|
-
|
|
48
|
-
1.4.0 (2026-09-30): "Call now" hooks for Booking Pro. Registry `version: 4`: `actions: [{id, icon, title, module}]`
|
|
49
|
-
(module under `/plugins/<owner>/`; ids `[a-z0-9-]`, never a screen's or tab's key, first owner keeps an id) ->
|
|
50
|
-
`registry.actions()` -> bootstrap `actions` -> a banner button each (`booking-x-<id>`) that imports the module and calls
|
|
51
|
-
`run(ctx, prefill)` (ctx = the screen's ctx + `owner`, `api` (sectionApi), `bookables`, `services`, `helpPopovers`).
|
|
52
|
-
`#/plugins/booking/<action-id>?contact=|email=&name=` is the Diary + that action with the prefill resolved like `new`
|
|
53
|
-
(the address goes back to `diary`). `callOpenedAt` on an online booking (`changeBooking` patch, online only, history
|
|
54
|
-
`call-opened`; a move clears it): `callWindow` opens at min(start - 10 min, callOpenedAt) and closes at max(end + 60
|
|
55
|
-
min, callOpenedAt + 2 h), so the customer's EXISTING link works at once - Booking (free) honours it after a lapse.
|
|
56
|
-
`registry.services` adds `openCall(id, {by})` (every online HOLDING booking of the session; throws `code` none |
|
|
57
|
-
not-online | cancelled), `callLinks(b, request?)` (absolute join/host URLs from a RAW booking), `adminBooking`,
|
|
58
|
-
`ownContact(id, userId)`, `siteBase(request?)`; `book()` takes `contactId` + `userId` (checked with `ownContact`) and
|
|
59
|
-
`request` (for the email links). An older Pro registers no actions; an older Booking ignores them.
|
|
60
|
-
Instant calls ("Call Sam now…", not a booking) were Booking Pro 0.3's and MOVED INTO THE CMS in Booking Pro 0.4.0
|
|
61
|
-
(core `services/instantCalls.js`, admin `#/calls/new`): Pro's banner action `call-now` now only sends the browser to
|
|
62
|
-
`#/calls/new[?contact=|?email=&name=]`, so the deep link `#/plugins/booking/call-now?...` above ends there too. Nothing in
|
|
63
|
-
Booking changed for it; `ownContact`/`siteBase` stay for Pro's booking-panel Call now.
|
|
64
|
-
|
|
65
|
-
1.3.0 (2026-09-30): online bookings (plan: `dcms-marketplace/docs/online-meetings-plan.md`). An extension's
|
|
66
|
-
`rules()` may say `online` (+ `recordingAllowed`); `placeBooking` then stores `online: true`, `hostKey`,
|
|
67
|
-
`recordingAllowed` ON THE BOOKING, so Booking (free) serves the call for it even after Pro lapses. `lib/call.js`:
|
|
68
|
-
a room is a SESSION (`sessionOf` = service + start + person, so a class shares one call), `whoIsCalling` (customer
|
|
69
|
-
token -> guest, host key -> host, only while HOLDING, window 10 min before to 60 after). The engine is core's
|
|
70
|
-
`_lib/call` (dynamic import - an older core has no calls); routes at `/call/...`, page at `<bookingPath>/call/<session>
|
|
71
|
-
?b=&t=|h=` (plugin.public.js). Emails: customer's main button becomes "Join the call" (change/cancel moves into the
|
|
72
|
-
text), the owner's copy gets "Start the call"; .ics LOCATION/DESCRIPTION carry the join link. `adminBooking` swaps
|
|
73
|
-
`hostKey` for `hostUrl`; `publicBooking` adds `online`, `callUrl`. Staff-made bookings still do not email the owner.
|
|
74
|
-
|
|
75
|
-
1.2.0 (2026-09-30): an email's sender who is already one of the caller's contacts is booked AS that contact:
|
|
76
|
-
`GET /contact?email=` (`contactByEmail`, main address or Contacts Pro `emails[]`) fills the slideover (the
|
|
77
|
-
sender's own address kept). Without a `contactId`, `POST /bookings` leaves it to `linkContact`, which already finds
|
|
78
|
-
the booked person's (else the caller's) contact by email - never the caller's for someone else's booking.
|
|
79
|
-
|
|
80
|
-
1.1.0 (2026-09-30): extension points for Booking Pro - see "Extensions" below. The slot engine now knows places (a
|
|
81
|
-
class), companions (a booking that also holds a room), and a daily limit, all OFF unless an extension's `rules`
|
|
82
|
-
turn them on; bookings carry `holds` (every bookable they block, first = `bookableId`) and `alsoNames`.
|
|
83
|
-
|
|
84
|
-
## The one rule about time
|
|
85
|
-
|
|
86
|
-
Bookings are UTC instants (`startAt`, `endAt`, and the span they BLOCK, `blockStart` / `blockEnd`, buffers
|
|
87
|
-
included - stored, so changing a service's buffers never moves what existing bookings hold). Opening hours, days
|
|
88
|
-
off and everything a person reads are the business's wall clock in `settings.timeZone`. `public/lib/time.js` is the
|
|
89
|
-
only place one becomes the other (`wallClock`, `atWallClock`; Intl, no library; DST-tested: a skipped time is never
|
|
90
|
-
offered, a repeated one is the first). Never build a Date from a date string and a time string anywhere else.
|
|
91
|
-
|
|
92
|
-
## The one rule about clashes
|
|
93
|
-
|
|
94
|
-
`public/lib/slots.js` `slotsFor` decides what is free - the page, the admin and the server all ask it, and
|
|
95
|
-
`lib/store.js` `placeBooking` checks AGAIN inside `withLock` before writing. The public `POST /public/book` also
|
|
96
|
-
requires the time to be one the page would offer (in range, on the service's steps, in hours). Staff may book over a
|
|
97
|
-
clash with `force: true` after a 409 (`code: 'slot-taken'`). Statuses that hold time: pending, confirmed,
|
|
98
|
-
completed, no-show (`HOLDING`); cancelled frees it.
|
|
99
|
-
|
|
100
|
-
## Files
|
|
101
|
-
|
|
102
|
-
- `plugin.json`, `config.js` (every setting, documented), `plugin.js` (API, shortcode, emails, reminders, links)
|
|
103
|
-
- `plugin.public.js` - the booking pages from ONE onRequest hook on the LIVE `bookingPath` (moving it needs no
|
|
104
|
-
restart): `<base>`, `<base>/<service-slug>`, `<base>/manage/<id>?t=<token>`.
|
|
105
|
-
- `public/lib/time.js`, `slots.js`, `clean.js` - PURE, shared by server, admin and page (public/ is served; lib/ is not).
|
|
106
|
-
- `lib/store.js` - collections I/O, live settings, `withLock`, `placeBooking` / `changeBooking`, Calendar busy time,
|
|
107
|
-
contact linking. `shelfNow` / `settingsNow` for the synchronous shortcode.
|
|
108
|
-
- `lib/mail.js` - one way out (copied from Waypoint Pro): never throws, not sent without SMTP (`mailReady()`),
|
|
109
|
-
`setMailer()` for tests; `icsFor` (stable UID per booking, SEQUENCE = history length, CANCEL on cancel).
|
|
110
|
-
- `lib/extensions.js` - the registry (`globalThis[Symbol.for('domma.booking')]`): `on` {made, moved, cancelled,
|
|
111
|
-
status}, `tabs`, and `registry.services` (Booking's data functions, `sendReminders`).
|
|
112
|
-
- `admin/` - the Tool (tab host `admin/views/booking.js`), `templates/` + `public/booking.js|css` - the page.
|
|
113
|
-
- `public/booking.js` - the page in the browser: domma-reactive (`window.M`, Domma is on every public page) - one
|
|
114
|
-
template holding every step (shown by `data-bind-hidden` on `step`), one `M.applyBindings`; plain code only fetches,
|
|
115
|
-
writes observables, and moves focus / scroll. Without `window.M` the server's page is left as it is.
|
|
116
|
-
- `docs/guide.md` - the user guide in the admin Documentation folder.
|
|
117
|
-
- `tests/pure.test.js` (time, slots, cleaning), `tests/api.test.js` (the whole API against the real collection
|
|
118
|
-
service; restores config/plugins.json and contacts-contacts; registry actions, callOpenedAt), `tests/public.test.js`
|
|
119
|
-
(the page's paths; `call-now/<id>` is left to Booking Pro).
|
|
120
|
-
|
|
121
|
-
## Data
|
|
122
|
-
|
|
123
|
-
Collections `booking-bookables`, `booking-services`, `booking-bookings` (made at every boot if missing; API access
|
|
124
|
-
all off - bookings hold customers' details). Settings: `config/plugins.json` `booking.settings`.
|
|
125
|
-
|
|
126
|
-
A booking: `serviceId`, `serviceName`, `duration`, `bookableId`, `bookableName`, `startAt`, `endAt`, `blockStart`,
|
|
127
|
-
`blockEnd`, `status`, `name`, `email`, `phone`, `notes`, `staffNote`, `contactId`, `source` (public | admin),
|
|
128
|
-
`createdBy`, `token` (the customer's link; never sent to the admin), `reminderSentAt`, `history` [{at, what, by,
|
|
129
|
-
from?, reason?}], `cancelledAt`, `ext` (Pro's); online ones also `online`, `hostKey`, `recordingAllowed`, `callOpenedAt`, `callExtraKey` (1.6, the session's key for
|
|
130
|
-
Add people passes; never sent to the admin). Services and bookables carry `ext` too (Pro's fields, kept by the
|
|
131
|
-
free Tool untouched).
|
|
132
|
-
|
|
133
|
-
## Extensions (Booking Pro)
|
|
134
|
-
|
|
135
|
-
`bookingRegistry()` (`lib/extensions.js`, `version: 4`): `register(owner, {rules, form, answers, check, admin, waitlistUrl,
|
|
136
|
-
on, tabs, actions})` - every hook optional and guarded (one that throws counts as absent). `rules(service)` ->
|
|
137
|
-
{capacity, companions: [[ids]], maxPerDay, waitlist}, resolved to bookable objects by `registry.rules(service,
|
|
138
|
-
bookables)` and applied by `slotsFor` / `whoCanTake` / `placeBooking` (same session = same service + start +
|
|
139
|
-
primary bookable: shares places, never clashes with itself; a day's limit counts sessions). `form` / `answers`: extra
|
|
140
|
-
questions on the page, cleaned into `ext.answers` (errors come back as `errors['answers.<id>']`). `check(ctx)`: a
|
|
141
|
-
reason refuses a public booking (409 `code: 'refused'`). `admin`: section modules mounted in Booking's own
|
|
142
|
-
slideovers (service editor, new booking, booking panel) - the contract is in `admin/lib/extension-sections.js`.
|
|
143
|
-
`registry.services`: Booking's data functions plus `book()` (the whole flow: contacts, emails, notices, events; throws
|
|
144
|
-
SlotTaken with `code: 'slot-taken'`), `cancel()`, `mail` {send, compose, mailReady}, `time` helpers and
|
|
145
|
-
`timeZone()` - so an extension never imports Booking's files. Without an extension every service is plain; existing
|
|
146
|
-
bookings keep blocking what they hold.
|
|
147
|
-
|
|
148
|
-
## Emails
|
|
149
|
-
|
|
150
|
-
Customer: confirmation (setting), moved, cancelled, reminder (`reminderHours` before; not for a booking made inside
|
|
151
|
-
that window - its confirmation was the reminder), with "Change or cancel" while `customerMayChange`. Owner copy: the
|
|
152
|
-
booked person's email, else `notifyAddress`, else the site's. Staff changes email the customer only when the
|
|
153
|
-
admin's "email the customer" box is ticked (`notify`). Reminders: a 5-minute `setInterval` (unref'd, cleared on
|
|
154
|
-
close) - no engine scheduler exists. Without SMTP nothing is sent; the settings slideover says so.
|
|
155
|
-
|
|
156
|
-
## Permissions
|
|
157
|
-
|
|
158
|
-
`booking` (read = see, manage = change), granted to admin; admins give it to other roles in Users & Roles. The
|
|
159
|
-
contact and email "Book…" actions carry `permission: {resource: 'booking', action: 'manage'}`, so core shows them
|
|
160
|
-
only to roles that hold it.
|
|
161
|
-
|
|
162
|
-
## Gotchas
|
|
163
|
-
|
|
164
|
-
- Add `return reply.send(...)` / return a value in every async route (compressed responses come back empty).
|
|
165
|
-
- `siteBase()` is `site.baseUrl` or '' - NEVER a request's Host (1.6.3): without a Site URL emails go out with no
|
|
166
|
-
links and the log warns once. Before, a booker with a chosen Host header got the owner an email whose "Start the
|
|
167
|
-
call" button went to their domain carrying the host key. tests/api.test.js sets `baseUrl` in config/site.json for
|
|
168
|
-
the run (restored after) and forges a Host to prove it.
|
|
169
|
-
- The API tests create contacts in domma-cms's `content/collections/contacts-contacts/data.json` (tracked) - they
|
|
170
|
-
snapshot and restore it; a crashed run can leave it changed: `git checkout` it in domma-cms.
|
|
171
|
-
|
|
172
|
-
## 1.6.4 (2026-10-13 Tool sweep, upgrades)
|
|
173
|
-
- The Diary is domma-reactive end to end: heads, hour gutter and columns are keyed `data-each` lists (`HEAD`, `HOUR`,
|
|
174
|
-
`COL` in diary.js; each column's open bands and blocks are `{{#each}}` inside it). One `draw` effect works out every
|
|
175
|
-
measure as a CSS length (`blockRow`) and the markup only binds; the empty state, "add a service" tip and first-run
|
|
176
|
-
checklist (`STEP`) are bound too. Kebab / right-click / Shift+F10 still come from `wireRows(gridBox, {match: '.bk-block'})`
|
|
177
|
-
(delegated, so re-rendered blocks need no rewiring). `mergeWindows` moved to admin/lib/diary-layout.js (tested).
|
|
178
|
-
- Settings > Closed days (`CLOSURE_ROW`) and a person's opening hours / days off (`DAY_ROW` with a nested
|
|
179
|
-
`{{#each windows}}`, `OFF_ROW`) are keyed lists of per-field observables; `hoursOut` / `daysOffOut` / `closuresOut`
|
|
180
|
-
turn them back into plain data for the dirty snapshot and the save. A "from" after the "to" still pulls "to" along.
|
|
181
|
-
- Icons in rows added after binding are drawn by `I.scan` after a flush (`rescan`), because new rows arrive after
|
|
182
|
-
the panel's first scan.
|
|
183
|
-
|
|
184
|
-
## 1.7.0 (2026-10-15 Tool Upgrade, second pass)
|
|
185
|
-
|
|
186
|
-
- Slideovers: `openPanel({ctx, release, draft})` - the panel goes with the screen (`ctx.hold`), `claim(key)` stops it
|
|
187
|
-
opening twice (released if building the panel throws - it is built inside try/catch), and `methods.save` is locked
|
|
188
|
-
while it runs. `draft: {key, label, kind, values, apply(values, panel), was, prefilled, initial}` keeps typed work
|
|
189
|
-
per user (`booking.drafts.<user>`, 14 days, rules in `admin/lib/drafts.js`, tests/admin-drafts.test.js); `was` is
|
|
190
|
-
`updatedAt`, or `fingerprint()` for settings; a draft taken "as new" from a deleted record starts with `was: ''` and
|
|
191
|
-
waits while another new-record draft exists. `ask()` is an E.confirm that answers 'no' when the screen goes.
|
|
192
|
-
- Restore questions put Discard on the CONFIRM button: Escape, the backdrop or leaving keep the draft (Domma's confirm
|
|
193
|
-
cannot tell Escape from Cancel). Booking Pro's sections are not drafted - the section contract cannot put values back.
|
|
194
|
-
- First loads use core skeletons through `kit.whileLoading` (`.bk-loading-slot`) on the host, Bookings and the Diary.
|
|
195
|
-
- No ContextMenu-key handler in wireRows: Windows Chrome opens its own menu on that key too. Shift+F10 only.
|
|
196
|
-
|
|
197
|
-
## 1.7.1
|
|
198
|
-
|
|
199
|
-
- **Email (openEmail).** Email actions go through `admin/lib/email.js`: `emailTo()` for menu actions (several people always in Bcc), `routeMailLinks(root)` for visible `mailto:` links. Core's `/admin/js/lib/mail-compose.js` (CMS 1.6.61+) opens Email Pro's compose window when the user has a mailbox there; older cores keep a cleaned, capped `mailto:` (over 1800 chars the addresses are copied instead). Stored addresses are encoded into links, or shown as text when invalid. Never set `location.href = 'mailto:…'` directly.
|
|
200
|
-
|
|
201
|
-
## 1.7.2 - a meta description on every booking page (2026-10-22)
|
|
202
|
-
`metaDescription(text, fallback)` in plugin.public.js: the Introduction (index) or the service's description,
|
|
203
|
-
else "Book an appointment with <site> online: <services>." / "Book <service> (<length>) with <site> online.";
|
|
204
|
-
one line, 160 characters at most. The Introduction's help says search engines show it. Test: `tests/seo.test.js`.
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/* Booking admin - only --dm-* tokens, so it follows the admin theme (light, dark, custom). */
|
|
2
|
-
.bk, .bk-form { --bk-soft: color-mix(in srgb, var(--dm-text) 5%, transparent); --bk-line: var(--dm-border, rgba(128, 128, 128, .3)); }
|
|
3
|
-
.bk [hidden], .bk-form [hidden] { display: none !important; }
|
|
4
|
-
.bk { display: flex; flex-direction: column; gap: 1rem; }
|
|
5
|
-
.bk-body { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
|
|
6
|
-
.bk-error { color: var(--dm-danger); }
|
|
7
|
-
.bk-muted { color: var(--dm-text-muted); }
|
|
8
|
-
.bk-note { margin: 0; font-size: var(--dm-text-sm); color: var(--dm-text-muted); }
|
|
9
|
-
.bk-note.is-bad { color: var(--dm-danger); }
|
|
10
|
-
.bk-note.is-warn { color: color-mix(in srgb, var(--dm-warning) 60%, var(--dm-text)); }
|
|
11
|
-
.bk-spacer { flex: 1; }
|
|
12
|
-
.bk-link { border: 0; background: none; padding: 0; color: var(--dm-primary); cursor: pointer; font: inherit; text-align: left; }
|
|
13
|
-
.bk-link:hover { text-decoration: underline; }
|
|
14
|
-
.bk-danger-text { color: var(--dm-danger) !important; }
|
|
15
|
-
|
|
16
|
-
/* Tabs under the banner */
|
|
17
|
-
.bk-nav { display: flex; flex-wrap: wrap; gap: .15rem; border-bottom: 1px solid var(--bk-line); }
|
|
18
|
-
.bk-nav a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; color: var(--dm-text-muted); text-decoration: none;
|
|
19
|
-
font-size: var(--dm-text-sm); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: var(--dm-radius-sm) var(--dm-radius-sm) 0 0; }
|
|
20
|
-
.bk-nav a:hover { color: var(--dm-text); background: var(--bk-soft); }
|
|
21
|
-
.bk-nav a.is-on { color: var(--dm-primary); border-bottom-color: var(--dm-primary); font-weight: 600; }
|
|
22
|
-
.bk-nav a.is-ext::after { content: 'Pro'; font-size: .62rem; font-weight: 700; letter-spacing: .04em; padding: .05rem .35rem; border-radius: 999px;
|
|
23
|
-
background: color-mix(in srgb, var(--dm-primary) 15%, transparent); color: var(--dm-primary); }
|
|
24
|
-
|
|
25
|
-
/* Cards, bars, chips */
|
|
26
|
-
.bk-card { border: 1px solid var(--bk-line); border-radius: var(--dm-radius-md); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .7rem;
|
|
27
|
-
background: var(--dm-surface, transparent); min-width: 0; }
|
|
28
|
-
.bk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
|
|
29
|
-
.bk-search { flex: 1; min-width: 10rem; max-width: 22rem; }
|
|
30
|
-
.bk-date { width: auto; max-width: 11rem; }
|
|
31
|
-
.bk-when { font-size: var(--dm-text-sm); }
|
|
32
|
-
.bk-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--bk-line); border-radius: var(--dm-radius-md); overflow: hidden; }
|
|
33
|
-
.bk-seg button { border: 0; background: none; color: var(--dm-text); padding: .32rem .7rem; cursor: pointer; font: inherit; font-size: var(--dm-text-sm);
|
|
34
|
-
display: inline-flex; align-items: center; gap: .3rem; }
|
|
35
|
-
.bk-seg button + button { border-left: 1px solid var(--bk-line); }
|
|
36
|
-
.bk-seg button b { font-weight: 500; opacity: .6; }
|
|
37
|
-
.bk-seg button:hover { background: var(--bk-soft); }
|
|
38
|
-
.bk-seg button.is-on { background: var(--dm-primary); color: var(--dm-primary-text, #fff); }
|
|
39
|
-
.bk-chip { display: inline-flex; align-items: center; gap: .25rem; font-size: var(--dm-text-xs); font-weight: 600; padding: .12rem .55rem; border-radius: 999px;
|
|
40
|
-
white-space: nowrap; background: color-mix(in srgb, var(--dm-text) 9%, transparent); color: var(--dm-text-muted); }
|
|
41
|
-
.bk-chip.is-primary { background: color-mix(in srgb, var(--dm-primary) 14%, transparent); color: var(--dm-primary); }
|
|
42
|
-
.bk-chip.is-success { background: color-mix(in srgb, var(--dm-success) 15%, transparent); color: var(--dm-success); }
|
|
43
|
-
.bk-chip.is-warning { background: color-mix(in srgb, var(--dm-warning) 16%, transparent); color: color-mix(in srgb, var(--dm-warning) 55%, var(--dm-text)); }
|
|
44
|
-
.bk-chip.is-danger { background: color-mix(in srgb, var(--dm-danger) 14%, transparent); color: var(--dm-danger); }
|
|
45
|
-
.bk-empty { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; padding: 2rem 1rem; color: var(--dm-text-muted); }
|
|
46
|
-
.bk-empty p { margin: 0; }
|
|
47
|
-
.bk-empty strong { color: var(--dm-text); }
|
|
48
|
-
|
|
49
|
-
/* Colours - one hue per name, mixed with the theme so they read on light and dark */
|
|
50
|
-
[data-colour] { --bk-c: var(--dm-primary); }
|
|
51
|
-
[data-colour="blue"] { --bk-c: var(--dm-blue-500, #3b82f6); }
|
|
52
|
-
[data-colour="green"] { --bk-c: var(--dm-green-500, #16a34a); }
|
|
53
|
-
[data-colour="teal"] { --bk-c: #0d9488; }
|
|
54
|
-
[data-colour="purple"] { --bk-c: #8b5cf6; }
|
|
55
|
-
[data-colour="pink"] { --bk-c: #db2777; }
|
|
56
|
-
[data-colour="orange"] { --bk-c: #ea580c; }
|
|
57
|
-
[data-colour="red"] { --bk-c: var(--dm-red-500, #dc2626); }
|
|
58
|
-
[data-colour="grey"] { --bk-c: var(--dm-gray-500, #6b7280); }
|
|
59
|
-
.bk-dot { width: .7rem; height: .7rem; border-radius: 50%; flex: none; background: var(--bk-c, var(--dm-text-muted)); }
|
|
60
|
-
|
|
61
|
-
/* Rows */
|
|
62
|
-
.bk-list { display: flex; flex-direction: column; }
|
|
63
|
-
.bk-row { display: flex; align-items: center; gap: .85rem; padding: .6rem .4rem; border-bottom: 1px solid var(--bk-line); cursor: pointer; border-radius: var(--dm-radius-sm); }
|
|
64
|
-
.bk-row:last-child { border-bottom: 0; }
|
|
65
|
-
.bk-row:hover, .bk-row:focus-visible { background: var(--bk-soft); outline: none; }
|
|
66
|
-
.bk-when-col { display: flex; flex-direction: column; min-width: 8.5rem; font-variant-numeric: tabular-nums; }
|
|
67
|
-
.bk-when-col small { color: var(--dm-text-muted); font-size: var(--dm-text-xs); }
|
|
68
|
-
.bk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
|
69
|
-
.bk-main strong, .bk-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
70
|
-
.bk-main small { color: var(--dm-text-muted); font-size: var(--dm-text-xs); }
|
|
71
|
-
.bk-kebab { border: 0; background: none; cursor: pointer; font-size: 1.15rem; color: var(--dm-text-muted); border-radius: var(--dm-radius-sm); padding: 0 .35rem; line-height: 1.6; }
|
|
72
|
-
.bk-kebab:hover { color: var(--dm-primary); background: var(--bk-soft); }
|
|
73
|
-
@media (max-width: 720px) { .bk-when-col { min-width: 6rem; } }
|
|
74
|
-
|
|
75
|
-
/* Getting started */
|
|
76
|
-
.bk-checklist { border: 1px solid color-mix(in srgb, var(--dm-primary) 40%, var(--bk-line)); border-radius: var(--dm-radius-md); padding: .75rem 1rem;
|
|
77
|
-
background: color-mix(in srgb, var(--dm-primary) 5%, transparent); }
|
|
78
|
-
.bk-checklist header { display: flex; align-items: center; justify-content: space-between; }
|
|
79
|
-
.bk-checklist h3 { margin: 0; font-size: var(--dm-text-base, 1rem); display: flex; align-items: center; gap: .35rem; }
|
|
80
|
-
.bk-checklist ol { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
|
|
81
|
-
.bk-checklist li { display: flex; align-items: center; gap: .5rem; font-size: var(--dm-text-sm); }
|
|
82
|
-
.bk-checklist li.is-done { color: var(--dm-text-muted); }
|
|
83
|
-
.bk-checklist li:not(.is-done) .bk-link { color: var(--dm-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--dm-text) 35%, transparent); text-underline-offset: 3px; }
|
|
84
|
-
.bk-checklist li.is-done .bk-link { color: var(--dm-text-muted); text-decoration: line-through; }
|
|
85
|
-
.bk-checklist li.is-done svg { color: var(--dm-success); }
|
|
86
|
-
|
|
87
|
-
/* The Diary */
|
|
88
|
-
.bk-diary-wrap { overflow: auto; max-height: calc(100vh - 16rem); min-height: 20rem; border: 1px solid var(--bk-line); border-radius: var(--dm-radius-sm); }
|
|
89
|
-
.bk-diary-wrap > .bk-note { padding: .5rem .75rem; }
|
|
90
|
-
.bk-diary-grid { --bk-gutter: 3.4rem; min-width: calc(var(--bk-gutter) + var(--bk-cols) * 9rem); }
|
|
91
|
-
.bk-diary-grid.is-week { min-width: calc(var(--bk-gutter) + 7 * 7.5rem); }
|
|
92
|
-
.bk-diary-head, .bk-diary-body { display: grid; grid-template-columns: var(--bk-gutter) repeat(var(--bk-cols), minmax(0, 1fr)); }
|
|
93
|
-
.bk-diary-head { position: sticky; top: 0; z-index: 3; background: var(--dm-surface, var(--dm-bg, #fff)); border-bottom: 1px solid var(--bk-line); }
|
|
94
|
-
.bk-col-head { padding: .45rem .5rem; font-size: var(--dm-text-sm); font-weight: 600; display: flex; align-items: center; gap: .3rem; border-left: 1px solid var(--bk-line);
|
|
95
|
-
overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
96
|
-
.bk-col-head[data-colour] { box-shadow: inset 0 -3px 0 var(--bk-c); }
|
|
97
|
-
.bk-col-head.is-today { color: var(--dm-primary); }
|
|
98
|
-
.bk-link-head { cursor: pointer; }
|
|
99
|
-
.bk-link-head:hover { background: var(--bk-soft); }
|
|
100
|
-
.bk-gutter { position: relative; height: var(--bk-h); }
|
|
101
|
-
.bk-gutter span { position: absolute; right: .4rem; transform: translateY(-.55em); font-size: var(--dm-text-xs); color: var(--dm-text-muted); font-variant-numeric: tabular-nums; }
|
|
102
|
-
.bk-gutter span:first-child { transform: none; }
|
|
103
|
-
.bk-col { position: relative; height: var(--bk-h); border-left: 1px solid var(--bk-line); cursor: copy;
|
|
104
|
-
background-image:
|
|
105
|
-
repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--bk-hour) - 1px), var(--bk-line) calc(var(--bk-hour) - 1px), var(--bk-line) var(--bk-hour)),
|
|
106
|
-
repeating-linear-gradient(135deg, transparent 0, transparent 7px, color-mix(in srgb, var(--dm-text) 7%, transparent) 7px, color-mix(in srgb, var(--dm-text) 7%, transparent) 8px); }
|
|
107
|
-
/* Opening hours: plain; outside them, hatched. */
|
|
108
|
-
.bk-open { position: absolute; left: 0; right: 0; background-color: var(--dm-surface, var(--dm-bg, #fff)); pointer-events: none;
|
|
109
|
-
background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--bk-hour) - 1px), var(--bk-line) calc(var(--bk-hour) - 1px), var(--bk-line) var(--bk-hour)); }
|
|
110
|
-
.bk-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--dm-danger); z-index: 2; pointer-events: none; }
|
|
111
|
-
.bk-block { position: absolute; z-index: 1; border-radius: var(--dm-radius-sm); padding: .2rem .4rem; overflow: hidden; cursor: pointer; font-size: var(--dm-text-xs);
|
|
112
|
-
line-height: 1.25; background: color-mix(in srgb, var(--bk-c) 18%, var(--dm-surface, var(--dm-bg, #fff))); border-left: 3px solid var(--bk-c);
|
|
113
|
-
color: var(--dm-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
|
|
114
|
-
.bk-block:hover, .bk-block:focus-visible { background: color-mix(in srgb, var(--bk-c) 28%, var(--dm-surface, var(--dm-bg, #fff))); outline: none; }
|
|
115
|
-
.bk-block:focus-visible { box-shadow: 0 0 0 2px var(--dm-primary); }
|
|
116
|
-
.bk-block strong, .bk-block small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
117
|
-
.bk-block small { color: var(--dm-text-muted); }
|
|
118
|
-
.bk-block .bk-kebab { float: right; font-size: .95rem; line-height: 1; padding: 0 .15rem; margin: -.05rem -.2rem 0 .1rem; }
|
|
119
|
-
.bk-block.is-cancelled { opacity: .55; text-decoration: line-through; border-left-style: dashed; }
|
|
120
|
-
.bk-block.is-completed { border-left-color: var(--dm-success); }
|
|
121
|
-
.bk-block.is-no-show { border-left-color: var(--dm-danger); }
|
|
122
|
-
|
|
123
|
-
/* Forms (slideovers) */
|
|
124
|
-
.bk-form { display: flex; flex-direction: column; gap: .75rem; padding: .25rem .1rem 1rem; }
|
|
125
|
-
.bk-form p { margin: 0; }
|
|
126
|
-
.bk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; align-items: start; }
|
|
127
|
-
.bk-grid > div { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
|
|
128
|
-
.bk-wide { grid-column: 1 / -1; }
|
|
129
|
-
@media (max-width: 560px) { .bk-grid { grid-template-columns: 1fr; } }
|
|
130
|
-
.bk-form .form-label { margin: 0; display: inline-flex; align-items: center; gap: .3rem; }
|
|
131
|
-
.bk-sub { margin: .5rem 0 0; font-size: var(--dm-text-sm); font-weight: 600; display: flex; align-items: center; gap: .3rem; }
|
|
132
|
-
.bk-check { display: inline-flex; align-items: center; gap: .45rem; font-size: var(--dm-text-sm); cursor: pointer; }
|
|
133
|
-
.bk-checks { display: flex; flex-direction: column; gap: .4rem; }
|
|
134
|
-
.bk-picks { display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
|
|
135
|
-
.bk-inline { display: flex; gap: .4rem; }
|
|
136
|
-
.bk-inline .form-input { max-width: 6rem; }
|
|
137
|
-
.bk-err { color: var(--dm-danger); font-size: var(--dm-text-xs); }
|
|
138
|
-
.bk-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
|
|
139
|
-
.bk-actions-start { justify-content: flex-start; }
|
|
140
|
-
.bk-copy { display: flex; align-items: center; gap: .4rem; }
|
|
141
|
-
.bk-copy code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .3rem .5rem; border-radius: var(--dm-radius-sm);
|
|
142
|
-
background: var(--bk-soft); font-size: var(--dm-text-sm); }
|
|
143
|
-
.bk-alert { display: flex; gap: .5rem; align-items: flex-start; padding: .6rem .75rem; border-radius: var(--dm-radius-sm); font-size: var(--dm-text-sm);
|
|
144
|
-
background: color-mix(in srgb, var(--dm-warning) 14%, transparent); border: 1px solid color-mix(in srgb, var(--dm-warning) 45%, transparent); }
|
|
145
|
-
.bk-alert svg { color: color-mix(in srgb, var(--dm-warning) 60%, var(--dm-text)); flex: none; margin-top: .1rem; }
|
|
146
|
-
.bk-settings-nav { align-self: flex-start; }
|
|
147
|
-
|
|
148
|
-
/* Free times */
|
|
149
|
-
.bk-picker { display: flex; flex-direction: column; gap: .5rem; }
|
|
150
|
-
.bk-slots { display: flex; flex-wrap: wrap; gap: .35rem; }
|
|
151
|
-
.bk-slot { border: 1px solid var(--bk-line); background: none; color: var(--dm-text); border-radius: var(--dm-radius-sm); padding: .25rem .55rem; cursor: pointer;
|
|
152
|
-
font: inherit; font-size: var(--dm-text-sm); font-variant-numeric: tabular-nums; }
|
|
153
|
-
.bk-slot:hover { border-color: var(--dm-primary); color: var(--dm-primary); }
|
|
154
|
-
.bk-slot.is-on { background: var(--dm-primary); border-color: var(--dm-primary); color: var(--dm-primary-text, #fff); }
|
|
155
|
-
|
|
156
|
-
/* One booking */
|
|
157
|
-
.bk-booking-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
|
|
158
|
-
.bk-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0; font-size: var(--dm-text-sm); }
|
|
159
|
-
.bk-dl dt { color: var(--dm-text-muted); }
|
|
160
|
-
.bk-dl dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
|
|
161
|
-
.bk-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: var(--dm-text-sm); }
|
|
162
|
-
.bk-history small { display: block; color: var(--dm-text-muted); font-size: var(--dm-text-xs); }
|
|
163
|
-
|
|
164
|
-
/* Hours and days off */
|
|
165
|
-
.bk-hours { display: flex; flex-direction: column; border: 1px solid var(--bk-line); border-radius: var(--dm-radius-sm); }
|
|
166
|
-
.bk-day { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) auto; gap: .5rem; align-items: center; padding: .35rem .6rem; }
|
|
167
|
-
.bk-day + .bk-day { border-top: 1px solid var(--bk-line); }
|
|
168
|
-
.bk-day-name { font-size: var(--dm-text-sm); font-weight: 500; }
|
|
169
|
-
.bk-windows { display: flex; flex-wrap: wrap; gap: .35rem .75rem; align-items: center; font-size: var(--dm-text-sm); }
|
|
170
|
-
.bk-window { display: inline-flex; align-items: center; gap: .25rem; }
|
|
171
|
-
.bk-window .form-input { width: 7.2rem; padding-block: .2rem; }
|
|
172
|
-
.bk-x { opacity: .6; }
|
|
173
|
-
.bk-x:hover { opacity: 1; }
|
|
174
|
-
.bk-off { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .35rem; font-size: var(--dm-text-sm); }
|
|
175
|
-
.bk-off .form-input[type="date"] { width: 10rem; }
|
|
176
|
-
.bk-off .form-input:not([type="date"]) { flex: 1; min-width: 8rem; }
|
|
177
|
-
@media (max-width: 560px) { .bk-day { grid-template-columns: 1fr; } }
|
|
178
|
-
/* Week columns are narrow: the menu is right-click / Shift+F10 there, so the time and name get the room. */
|
|
179
|
-
.bk-diary-grid.is-week .bk-block .bk-kebab { display: none; }
|
|
180
|
-
.bk-col-head.is-today::after { content: ''; width: .4rem; height: .4rem; border-radius: 50%; background: var(--dm-primary); flex: none; }
|
|
181
|
-
|
|
182
|
-
/* ---- 1.1: companions, classes, extension sections, places ---- */
|
|
183
|
-
.bk-block.is-companion { border-left-style: dashed; background: color-mix(in srgb, var(--bk-c) 8%, var(--dm-surface, var(--dm-bg, #fff))); }
|
|
184
|
-
.bk-block.is-companion strong { font-weight: 500; }
|
|
185
|
-
.bk-block.is-session { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bk-c) 45%, transparent); }
|
|
186
|
-
.bk-session-list .bk-row { width: 100%; text-align: left; background: none; color: inherit; font: inherit; }
|
|
187
|
-
.bk-ext-host:empty { display: none; }
|
|
188
|
-
.bk-ext { border: 1px solid var(--bk-line); border-radius: var(--dm-radius-md, 8px); padding: .75rem .9rem; margin: .9rem 0 0; }
|
|
189
|
-
.bk-ext > .bk-note { margin: 0; }
|
|
190
|
-
.bk-slot small { display: block; font-size: var(--dm-text-xs); color: var(--dm-text-muted); line-height: 1.2; }
|
|
191
|
-
.bk-slot.is-on small { color: inherit; opacity: .85; }
|
|
192
|
-
.bk-answers { margin-bottom: .5rem; }
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How a booking reads in the admin - PURE, shared by the booking slideover,
|
|
3
|
-
* the Bookings list and the Diary, and tested without a browser.
|
|
4
|
-
*
|
|
5
|
-
* @module booking/admin/lib/details
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** "Alex", "Alex and Court 1", "Alex, Court 1 and Projector". */
|
|
9
|
-
export function withNames(b) {
|
|
10
|
-
const names = [b?.bookableName, ...(Array.isArray(b?.alsoNames) ? b.alsoNames : [])].filter(Boolean);
|
|
11
|
-
if (names.length < 2) return names[0] || '';
|
|
12
|
-
return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** Where a booking came from, in words. */
|
|
16
|
-
export function sourceLabel(source) {
|
|
17
|
-
return {
|
|
18
|
-
public: 'Online, on the booking page',
|
|
19
|
-
admin: 'By staff',
|
|
20
|
-
waitlist: 'From the waiting list',
|
|
21
|
-
extension: 'Added by an extension'
|
|
22
|
-
}[source] || (source ? `From ${source}` : 'By staff');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** The short form for a list row's meta. */
|
|
26
|
-
export function sourceShort(source) {
|
|
27
|
-
return {public: 'booked online', admin: 'booked by staff', waitlist: 'from the waiting list', extension: 'added automatically'}[source] || 'booked by staff';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The answers to a service's questions as [label, text] rows, in the
|
|
32
|
-
* questions' order, then any answer whose question has gone (by its key).
|
|
33
|
-
*
|
|
34
|
-
* @param {Object<string, *>} answers
|
|
35
|
-
* @param {object} [service] - its ext['booking-pro'].questions give the labels
|
|
36
|
-
* @returns {[string, string][]}
|
|
37
|
-
*/
|
|
38
|
-
export function answerRows(answers, service) {
|
|
39
|
-
if (!answers || typeof answers !== 'object') return [];
|
|
40
|
-
const questions = Array.isArray(service?.ext?.['booking-pro']?.questions) ? service.ext['booking-pro'].questions : [];
|
|
41
|
-
const text = (v) => (v === true ? 'Yes' : v === false ? 'No' : Array.isArray(v) ? v.join(', ') : String(v ?? ''));
|
|
42
|
-
const rows = [];
|
|
43
|
-
const seen = new Set();
|
|
44
|
-
for (const q of questions) {
|
|
45
|
-
if (!q || !(q.id in answers)) continue;
|
|
46
|
-
seen.add(q.id);
|
|
47
|
-
rows.push([String(q.label || q.id), text(answers[q.id])]);
|
|
48
|
-
}
|
|
49
|
-
for (const [k, v] of Object.entries(answers)) if (!seen.has(k)) rows.push([k, text(v)]);
|
|
50
|
-
return rows.filter(([, v]) => v !== '');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** "2 places left" / "1 place left" - for a service that takes more than one. */
|
|
54
|
-
export function placesLabel(left) {
|
|
55
|
-
const n = Number(left);
|
|
56
|
-
if (!Number.isFinite(n)) return '';
|
|
57
|
-
return `${n} place${n === 1 ? '' : 's'} left`;
|
|
58
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Diary's geometry - PURE, so it can be tested without a browser.
|
|
3
|
-
*
|
|
4
|
-
* A day column is a strip of minutes. Bookings are placed by their wall-clock
|
|
5
|
-
* time in the business zone; bookings that overlap (a clash booked anyway, or
|
|
6
|
-
* several people's in the week view) sit side by side in lanes.
|
|
7
|
-
*
|
|
8
|
-
* Imported relatively (../../public/lib/...) so the same file works in the
|
|
9
|
-
* browser (/plugins/booking/admin/lib/) and under node --test.
|
|
10
|
-
*
|
|
11
|
-
* @module booking/admin/lib/diary-layout
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import {addDays, weekdayOf, wallClock} from '../../public/lib/time.js';
|
|
15
|
-
import {windowsOn} from '../../public/lib/slots.js';
|
|
16
|
-
|
|
17
|
-
/** Monday of the week a date is in. */
|
|
18
|
-
export function weekStart(date) {
|
|
19
|
-
const wd = weekdayOf(date);
|
|
20
|
-
return addDays(date, wd === 0 ? -6 : 1 - wd);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** The dates a view shows: one for 'day', Monday to Sunday for 'week'. */
|
|
24
|
-
export function datesFor(view, date) {
|
|
25
|
-
if (view !== 'week') return [date];
|
|
26
|
-
const first = weekStart(date);
|
|
27
|
-
return Array.from({length: 7}, (_, i) => addDays(first, i));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The hours the grid shows: from the earliest opening to the latest closing of
|
|
32
|
-
* any bookable on those dates, widened to take in any booking outside them,
|
|
33
|
-
* whole hours, never less than 8 hours. 08:00-18:00 when nothing is open.
|
|
34
|
-
*
|
|
35
|
-
* @param {object[]} bookables
|
|
36
|
-
* @param {string[]} dates
|
|
37
|
-
* @param {{startMin: number, endMin: number}[]} placed - bookings' minutes on those dates
|
|
38
|
-
* @returns {{from: number, to: number}} minutes since midnight, whole hours
|
|
39
|
-
*/
|
|
40
|
-
export function gridHours(bookables, dates, placed = []) {
|
|
41
|
-
let from = Infinity;
|
|
42
|
-
let to = -Infinity;
|
|
43
|
-
for (const date of dates) {
|
|
44
|
-
for (const bk of bookables) {
|
|
45
|
-
for (const w of windowsOn(bk, date)) { from = Math.min(from, w.from); to = Math.max(to, w.to); }
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
for (const p of placed) { from = Math.min(from, p.startMin); to = Math.max(to, p.endMin); }
|
|
49
|
-
if (!Number.isFinite(from)) { from = 480; to = 1080; }
|
|
50
|
-
from = Math.floor(from / 60) * 60;
|
|
51
|
-
to = Math.ceil(to / 60) * 60;
|
|
52
|
-
if (to - from < 480) to = Math.min(1440, from + 480);
|
|
53
|
-
if (to - from < 480) from = Math.max(0, to - 480);
|
|
54
|
-
return {from, to};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Where a booking falls: its date and minutes in the zone, clipped to its own
|
|
59
|
-
* day (a booking past midnight shows to the end of the day it starts on).
|
|
60
|
-
*
|
|
61
|
-
* @param {{startAt: string, endAt: string}} b
|
|
62
|
-
* @param {string} tz
|
|
63
|
-
* @returns {{date: string, startMin: number, endMin: number}}
|
|
64
|
-
*/
|
|
65
|
-
export function placeOf(b, tz) {
|
|
66
|
-
const s = wallClock(b.startAt, tz);
|
|
67
|
-
const e = wallClock(b.endAt, tz);
|
|
68
|
-
const endMin = e.date === s.date ? e.minutes : 1440;
|
|
69
|
-
return {date: s.date, startMin: s.minutes, endMin: Math.max(endMin, s.minutes + 10)};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Lanes for items in one column: each gets `lane` and `lanes` (how many sit
|
|
74
|
-
* side by side in its cluster of overlapping items).
|
|
75
|
-
*
|
|
76
|
-
* @template T
|
|
77
|
-
* @param {(T & {startMin: number, endMin: number})[]} items
|
|
78
|
-
* @returns {(T & {lane: number, lanes: number})[]}
|
|
79
|
-
*/
|
|
80
|
-
export function layoutColumn(items) {
|
|
81
|
-
const sorted = [...items].sort((a, b) => a.startMin - b.startMin || b.endMin - a.endMin);
|
|
82
|
-
const out = [];
|
|
83
|
-
let cluster = [];
|
|
84
|
-
let clusterEnd = -1;
|
|
85
|
-
const flush = () => {
|
|
86
|
-
const n = cluster.reduce((m, x) => Math.max(m, x.lane + 1), 0);
|
|
87
|
-
for (const x of cluster) out.push({...x, lanes: n});
|
|
88
|
-
cluster = [];
|
|
89
|
-
};
|
|
90
|
-
for (const it of sorted) {
|
|
91
|
-
if (cluster.length && it.startMin >= clusterEnd) { flush(); clusterEnd = -1; }
|
|
92
|
-
const busy = new Set(cluster.filter(x => x.endMin > it.startMin).map(x => x.lane));
|
|
93
|
-
let lane = 0;
|
|
94
|
-
while (busy.has(lane)) lane++;
|
|
95
|
-
cluster.push({...it, lane});
|
|
96
|
-
clusterEnd = Math.max(clusterEnd, it.endMin);
|
|
97
|
-
}
|
|
98
|
-
if (cluster.length) flush();
|
|
99
|
-
return out;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** The minute a click at `y` px lands on, rounded down to `snap` minutes. */
|
|
103
|
-
export function minuteAt(y, {from, pxPerMin, snap = 15}) {
|
|
104
|
-
const raw = from + Math.max(0, y) / pxPerMin;
|
|
105
|
-
return Math.floor(raw / snap) * snap;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Column heading: "Mon 06/10". */
|
|
109
|
-
export function dayLabel(date) {
|
|
110
|
-
const [, m, d] = date.split('-');
|
|
111
|
-
return `${['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][weekdayOf(date)]} ${d}/${m}`;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** The bookables a booking holds: its own, and any it took along. */
|
|
115
|
-
const holdsOf = (b) => (Array.isArray(b?.holds) && b.holds.length ? b.holds : [b?.bookableId]).filter(Boolean);
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* What one Diary column shows. In the day view (a column per person or room)
|
|
119
|
-
* a booking appears in every column it holds - the companion copies (a court
|
|
120
|
-
* booked with a trainer) marked `companion`. Several live bookings of one
|
|
121
|
-
* session (same service, start and person - a class) become ONE item with all
|
|
122
|
-
* of them in `bookings`. Cancelled ones are never grouped.
|
|
123
|
-
*
|
|
124
|
-
* @param {object[]} bookings
|
|
125
|
-
* @param {{bookableId?: string}} [column] - none: every booking (the week view)
|
|
126
|
-
* @returns {{key: string, b: object, bookings: object[], companion: boolean, session: boolean}[]}
|
|
127
|
-
*/
|
|
128
|
-
export function columnItems(bookings, {bookableId = ''} = {}) {
|
|
129
|
-
const groups = new Map();
|
|
130
|
-
for (const b of bookings || []) {
|
|
131
|
-
if (bookableId && !holdsOf(b).includes(bookableId)) continue;
|
|
132
|
-
const companion = Boolean(bookableId) && b.bookableId !== bookableId;
|
|
133
|
-
const key = b.status === 'cancelled'
|
|
134
|
-
? `x|${b.id}`
|
|
135
|
-
: `s|${b.serviceId}|${b.startAt}|${b.bookableId}${companion ? '|c' : ''}`;
|
|
136
|
-
if (!groups.has(key)) groups.set(key, {key, b, bookings: [], companion});
|
|
137
|
-
groups.get(key).bookings.push(b);
|
|
138
|
-
}
|
|
139
|
-
return [...groups.values()].map(g => ({...g, session: g.bookings.length > 1}));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Opening windows (minutes) merged where they touch or overlap - the week view's one band per day for everyone.
|
|
144
|
-
* Moved here from diary.js (1.6.4) so it is tested with the rest of the geometry.
|
|
145
|
-
*
|
|
146
|
-
* @param {{from: number, to: number}[]} list
|
|
147
|
-
* @returns {{from: number, to: number}[]} sorted, non-overlapping copies
|
|
148
|
-
*/
|
|
149
|
-
export function mergeWindows(list) {
|
|
150
|
-
const sorted = [...(list || [])].sort((a, b) => a.from - b.from);
|
|
151
|
-
const out = [];
|
|
152
|
-
for (const w of sorted) {
|
|
153
|
-
const last = out[out.length - 1];
|
|
154
|
-
if (last && w.from <= last.to) last.to = Math.max(last.to, w.to);
|
|
155
|
-
else out.push({...w});
|
|
156
|
-
}
|
|
157
|
-
return out;
|
|
158
|
-
}
|