domma-cms 1.36.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/bin/lib/left-free-tier.js +4 -1
  3. package/bin/update.js +4 -0
  4. package/docs/DommaFeatures.md +8 -6
  5. package/docs/plugin-development.md +2 -2
  6. package/package.json +1 -1
  7. package/plugins/docs/tests/plugin.test.js +2 -0
  8. package/plugins/free-tier.lock.json +2 -50
  9. package/server/services/siteGitignore.js +1 -1
  10. package/plugins/booking/CLAUDE.md +0 -204
  11. package/plugins/booking/admin/css/index.css +0 -192
  12. package/plugins/booking/admin/lib/details.js +0 -58
  13. package/plugins/booking/admin/lib/diary-layout.js +0 -158
  14. package/plugins/booking/admin/lib/drafts.js +0 -139
  15. package/plugins/booking/admin/lib/email.js +0 -191
  16. package/plugins/booking/admin/lib/extension-sections.js +0 -160
  17. package/plugins/booking/admin/lib/kit.js +0 -471
  18. package/plugins/booking/admin/templates/booking.html +0 -1
  19. package/plugins/booking/admin/views/booking.js +0 -216
  20. package/plugins/booking/admin/views/bookings.js +0 -132
  21. package/plugins/booking/admin/views/diary.js +0 -382
  22. package/plugins/booking/admin/views/panels.js +0 -603
  23. package/plugins/booking/admin/views/people.js +0 -318
  24. package/plugins/booking/admin/views/services.js +0 -264
  25. package/plugins/booking/admin/views/settings.js +0 -222
  26. package/plugins/booking/collections/booking-bookables.json +0 -17
  27. package/plugins/booking/collections/booking-bookings.json +0 -18
  28. package/plugins/booking/collections/booking-services.json +0 -17
  29. package/plugins/booking/config.js +0 -36
  30. package/plugins/booking/docs/guide.md +0 -73
  31. package/plugins/booking/inject/body.html +0 -1
  32. package/plugins/booking/lib/call.js +0 -88
  33. package/plugins/booking/lib/extensions.js +0 -169
  34. package/plugins/booking/lib/mail.js +0 -113
  35. package/plugins/booking/lib/store.js +0 -392
  36. package/plugins/booking/plugin.js +0 -905
  37. package/plugins/booking/plugin.json +0 -81
  38. package/plugins/booking/plugin.public.js +0 -175
  39. package/plugins/booking/public/booking.css +0 -159
  40. package/plugins/booking/public/booking.js +0 -808
  41. package/plugins/booking/public/lib/clean.js +0 -141
  42. package/plugins/booking/public/lib/page-format.js +0 -121
  43. package/plugins/booking/public/lib/slots.js +0 -247
  44. package/plugins/booking/public/lib/time.js +0 -131
  45. package/plugins/booking/templates/booking.html +0 -5
  46. package/plugins/booking/tests/admin-diary.test.js +0 -81
  47. package/plugins/booking/tests/admin-drafts.test.js +0 -67
  48. package/plugins/booking/tests/api.test.js +0 -651
  49. package/plugins/booking/tests/email.test.js +0 -69
  50. package/plugins/booking/tests/public.test.js +0 -72
  51. package/plugins/booking/tests/pure.test.js +0 -189
  52. package/plugins/booking/tests/seo.test.js +0 -71
@@ -1,222 +0,0 @@
1
- /**
2
- * Booking settings - the banner cog's slideover: the booking page, what
3
- * customers may change themselves, emails, links to other Tools, and the days
4
- * the whole business is closed. Each field explained in place; the server's
5
- * per-field messages shown beside the field.
6
- */
7
-
8
- import {api, claim, copy, errText, esc, openPanel, store} from '../lib/kit.js';
9
- import {fingerprint} from '../lib/drafts.js';
10
- import {isDate} from '/plugins/booking/public/lib/time.js';
11
-
12
- const SECTIONS = [
13
- {key: 'page', label: 'Booking page', icon: 'globe'},
14
- {key: 'changes', label: 'Changes', icon: 'refresh-cw'},
15
- {key: 'emails', label: 'Emails', icon: 'mail'},
16
- {key: 'tools', label: 'Other Tools', icon: 'plug'},
17
- {key: 'closed', label: 'Closed days', icon: 'ban'}
18
- ];
19
- // One spell of closed days.
20
- const CLOSURE_ROW = `
21
- <div class="bk-off">
22
- <input type="date" class="form-input" data-model="from.value" aria-label="From" data-on-change="$parent.closureFrom($data)"><span>to</span>
23
- <input type="date" class="form-input" data-model="to.value" aria-label="To">
24
- <input class="form-input" data-model="label.value" placeholder="Bank holiday…" maxlength="80" aria-label="Why">
25
- <button type="button" class="btn btn-xs btn-ghost bk-x" title="Remove" aria-label="Remove" data-on-click="$parent.dropClosure($data)"><span data-icon="x" data-icon-size="12"></span></button>
26
- </div>`;
27
-
28
- const BOOL_KEYS = ['askPhone', 'phoneRequired', 'allowCancel', 'allowMove', 'sendConfirmation', 'addToContacts', 'calendarBusy'];
29
- const FIELD_SECTION = {pageTitle: 'page', bookingPath: 'page', timeZone: 'page', termsUrl: 'page', notifyAddress: 'emails'};
30
-
31
- /** Zones the browser knows, the business's own first. */
32
- function zones(current) {
33
- let list = [];
34
- try { list = Intl.supportedValuesOf('timeZone'); } catch { list = ['Europe/London', 'Europe/Dublin', 'Europe/Paris', 'America/New_York', 'UTC']; }
35
- return [...new Set([current, ...list])];
36
- }
37
-
38
- export async function openSettings(ctx, section = 'page') {
39
- store.set('booking.settings-seen', true);
40
- // One settings panel: the cog clicked twice while they load opens it once.
41
- const release = claim('settings');
42
- if (!release) return;
43
- let info;
44
- try { info = await api.settings.get(); } catch (err) { release(); if (ctx.here()) E.toast(`Settings did not load: ${errText(err)}`, {type: 'error'}); return; }
45
- if (!ctx.here()) { release(); return; }
46
- const s = info.settings;
47
- const f = {};
48
- for (const [k, v] of Object.entries(s)) if (k !== 'closures') f[k] = M.observable(v);
49
- // Closed days are a keyed list (CLOSURE_ROW); each field is an observable the inputs write through.
50
- let seq = 0;
51
- const closureRow = (c) => ({id: `c${++seq}`, from: M.observable(c.from || ''), to: M.observable(c.to || ''), label: M.observable(c.label || '')});
52
- const closures = M.observable((s.closures || []).map(closureRow));
53
- const closuresOut = () => closures.peek().map(o => ({from: o.from.peek(), to: o.to.peek(), label: o.label.peek()}));
54
- const tab = M.observable(SECTIONS.some(x => x.key === section) ? section : 'page');
55
- const saving = M.observable(false);
56
- const snapshot = () => JSON.stringify([Object.entries(f).map(([k, o]) => [k, o.peek()]), closuresOut()]);
57
- const opened = snapshot();
58
- let panel = null;
59
- // New rows carry icons; they are drawn once the list has rendered.
60
- const rescan = () => { M.flushSync?.(); if (panel) { I.scan(panel.panel); requestAnimationFrame(() => panel?.panel.isConnected && I.scan(panel.panel)); } };
61
- const model = {
62
- ...f, tab, saving, closures,
63
- dropClosure(o) { closures.value = closures.peek().filter(x => x !== o); },
64
- // An end before the start is never meant: it follows the start.
65
- closureFrom(o, e) {
66
- const v = e?.target?.value ?? o.from.peek();
67
- if (!o.to.peek() || o.to.peek() < v) o.to.value = v;
68
- },
69
- pageUrl: M.computed(() => `${location.origin}${f.bookingPath.value || '/booking'}`),
70
- noPhone: M.computed(() => !f.askPhone.value),
71
- remindText: M.computed(() => (Number(f.reminderHours.value) > 0 ? `${f.reminderHours.value} hours before` : 'off'))
72
- };
73
- for (const x of SECTIONS) model[`is_${x.key}`] = M.computed(() => tab.value === x.key);
74
-
75
- const check = (k, label, help = '') => `<label class="bk-check"><input type="checkbox" data-bool="${k}"> ${label}${help ? ` <span data-help-title="${esc(label)}" data-help="${esc(help)}"></span>` : ''}</label>`;
76
- const err = (k) => `<small class="bk-err" data-err="${k}" hidden></small>`;
77
- const users = ctx.boot.users || [];
78
- const html = `<div class="bk-form bk-settings">
79
- <div class="bk-seg bk-settings-nav" role="tablist">
80
- ${SECTIONS.map(x => `<button type="button" role="tab" data-tab="${x.key}" data-bind-class="tab.value === '${x.key}' && 'is-on'"><span data-icon="${x.icon}" data-icon-size="13"></span> ${x.label}</button>`).join('')}
81
- </div>
82
-
83
- <section data-bind-hidden="!is_page.value" class="bk-grid">
84
- <div><label class="form-label">Page heading <span data-help-title="Page heading" data-help="The heading on the booking page."></span></label>
85
- <input class="form-input" data-model="pageTitle.value" maxlength="80">${err('pageTitle')}</div>
86
- <div><label class="form-label">Address <span data-help-title="Address" data-help="Where the booking page lives on your site. /booking gives /booking, a page per service at /booking/service-name, and the customer's own page at /booking/manage/…. Links in emails already sent keep working only at the old address."></span></label>
87
- <input class="form-input" data-model="bookingPath.value" maxlength="60">${err('bookingPath')}</div>
88
- <div class="bk-wide"><div class="bk-copy"><code data-bind-text="pageUrl.value"></code><button type="button" class="btn btn-sm btn-ghost" data-on-click="copyUrl" title="Copy the address"><span data-icon="copy" data-icon-size="13"></span></button></div></div>
89
- <div class="bk-wide"><label class="form-label">Introduction <span data-help-title="Introduction" data-help="A line or two under the heading: what to expect, where you are, how to prepare. Search engines show it too; left empty, they get a line made from your site name and services."></span></label>
90
- <textarea class="form-input" rows="2" data-model="intro.value" maxlength="2000"></textarea></div>
91
- <div><label class="form-label">Time zone <span data-help-title="Time zone" data-help="Opening hours, the Diary and every time in emails are in this zone - where the business is, not where the customer is."></span></label>
92
- <select class="form-select" data-model="timeZone.value">${zones(s.timeZone).map(z => `<option value="${esc(z)}">${esc(z.replace(/_/g, ' '))}</option>`).join('')}</select>${err('timeZone')}</div>
93
- <div><label class="form-label">Terms page <span data-help-title="Terms page" data-help="If set, customers tick 'I agree to the terms' (linked here) before booking. /terms or a full https:// address."></span></label>
94
- <input class="form-input" data-model="termsUrl.value" placeholder="/terms">${err('termsUrl')}</div>
95
- <div class="bk-wide bk-checks">
96
- ${check('askPhone', 'Ask for a phone number')}
97
- <span data-bind-hidden="noPhone.value">${check('phoneRequired', 'A phone number is required')}</span>
98
- </div>
99
- </section>
100
-
101
- <section data-bind-hidden="!is_changes.value" class="bk-grid">
102
- <p class="bk-wide bk-note">Every confirmation email has a private link where the customer can see their booking - and, if you allow it here, move or cancel it themselves.</p>
103
- <div class="bk-wide bk-checks">
104
- ${check('allowCancel', 'Customers can cancel', 'From their private link. The time becomes free at once and you are told.')}
105
- ${check('allowMove', 'Customers can move to another time', 'To another free time with the same person or room.')}
106
- </div>
107
- <div><label class="form-label">Up to (hours before) <span data-help-title="Notice for changes" data-help="Changes close this many hours before the booking; after that the page asks them to contact you. 0: right up to the start."></span></label>
108
- <input class="form-input" type="number" min="0" max="720" data-model="changeNoticeHours.value"></div>
109
- </section>
110
-
111
- <section data-bind-hidden="!is_emails.value" class="bk-grid">
112
- ${info.mailReady ? '' : `<div class="bk-wide bk-alert"><span data-icon="alert-triangle" data-icon-size="15"></span>
113
- <span><strong>No emails can be sent.</strong> This site has no outgoing mail server, so confirmations and reminders are not sent. Set one up in Settings › Email (SMTP).</span></div>`}
114
- <div class="bk-wide bk-checks">
115
- ${check('sendConfirmation', 'Email customers a confirmation', 'Sent when they book on the page. The details, a calendar file, and their private link.')}
116
- </div>
117
- <div><label class="form-label">Reminder (hours before) <span data-help-title="Reminder" data-help="A reminder email this many hours before. 0 turns reminders off. Not sent for a booking made after that point - its confirmation is recent enough."></span></label>
118
- <input class="form-input" type="number" min="0" max="336" data-model="reminderHours.value"><small class="bk-muted" data-bind-text="remindText.value"></small></div>
119
- <div><label class="form-label">Copies to <span data-help-title="Copies to" data-help="New, moved and cancelled bookings are emailed to the person booked (their email under People &amp; rooms), else here, else the site's own address."></span></label>
120
- <input class="form-input" type="email" data-model="notifyAddress.value" placeholder="bookings@example.com">${err('notifyAddress')}</div>
121
- <div class="bk-wide"><label class="form-label">Note in every confirmation <span data-help-title="Note" data-help="Directions, parking, what to bring - added at the end of confirmation and move emails."></span></label>
122
- <textarea class="form-input" rows="3" data-model="confirmationNote.value" maxlength="2000"></textarea></div>
123
- </section>
124
-
125
- <section data-bind-hidden="!is_tools.value" class="bk-grid">
126
- <div class="bk-wide bk-checks">
127
- ${check('addToContacts', 'Add customers to Contacts', 'Each new customer becomes a contact (once - matched by email), in the address book of the person booked if they are linked to a user, else the owner below.')}
128
- </div>
129
- <div class="bk-wide"><label class="form-label">Contacts go to <span data-help-title="Contacts owner" data-help="Contacts are per user. Customers of a room, or of a person with no user account, go into this user's Contacts."></span></label>
130
- <select class="form-select" data-model="contactsOwnerId.value"><option value="">Nobody (not added)</option>${users.map(u => `<option value="${esc(u.id)}">${esc(u.name)}</option>`).join('')}</select>
131
- ${ctx.boot.contacts ? '' : '<small class="bk-muted">Contacts is switched off on this site.</small>'}</div>
132
- <div class="bk-wide bk-checks">
133
- ${check('calendarBusy', 'Calendar events block booking times', 'A person linked to a user is not offered at times of Calendar events they organise. Needs the Calendar Tool.')}
134
- ${ctx.boot.calendar ? '' : '<small class="bk-muted">The Calendar Tool is not on this site, so this has no effect yet.</small>'}
135
- </div>
136
- </section>
137
-
138
- <section data-bind-hidden="!is_closed.value">
139
- <p class="bk-note">Days the whole business is closed - bank holidays, a closure. Nobody can be booked. (For one person's holiday, use their days off.)</p>
140
- <p class="bk-note" data-bind-hidden="closures.value.length">None yet.</p>
141
- <div data-each="closures.value key=id">${CLOSURE_ROW}</div>
142
- <div class="bk-actions bk-actions-start"><button type="button" class="btn btn-xs btn-outline" data-on-click="addClosure"><span data-icon="plus" data-icon-size="12"></span> Add closed days</button></div>
143
- </section>
144
-
145
- <div class="bk-actions">
146
- <span class="bk-spacer"></span>
147
- <button type="button" class="btn btn-sm btn-ghost" data-on-click="cancel">Close</button>
148
- <button type="button" class="btn btn-sm btn-primary" data-on-click="save" data-bind-disabled="saving.value"><span data-icon="check" data-icon-size="13"></span> Save</button>
149
- </div>
150
- </div>`;
151
-
152
- panel = await openPanel({
153
- title: 'Booking settings',
154
- size: 'md',
155
- html,
156
- model,
157
- ctx, release,
158
- dirty: () => snapshot() !== opened,
159
- // Settings carry no updatedAt: `was` is a fingerprint of them as loaded, so a save made
160
- // elsewhere since shows up as a change.
161
- draft: {
162
- key: 'settings', label: 'Booking settings', was: fingerprint(s),
163
- values: () => ({f: Object.fromEntries(Object.entries(f).map(([k, o]) => [k, o.peek()])), closures: closuresOut()}),
164
- apply(v, el) {
165
- for (const [k, val] of Object.entries(v.f || {})) {
166
- if (f[k] && ['string', 'number', 'boolean'].includes(typeof val) && typeof val === typeof f[k].peek()) f[k].value = val;
167
- else if (f[k] && typeof f[k].peek() === 'number' && typeof val === 'string') f[k].value = val; // a number typed is text
168
- }
169
- for (const box of el.querySelectorAll('[data-bool]')) box.checked = Boolean(f[box.dataset.bool].peek());
170
- closures.value = (Array.isArray(v.closures) ? v.closures : []).map(closureRow);
171
- }
172
- },
173
- before: (el) => {
174
- for (const box of el.querySelectorAll('[data-bool]')) {
175
- box.checked = Boolean(f[box.dataset.bool].peek());
176
- box.addEventListener('change', () => { f[box.dataset.bool].value = box.checked; });
177
- }
178
- el.querySelector('.bk-settings-nav').addEventListener('click', (e) => {
179
- const b = e.target.closest('[data-tab]');
180
- if (b) tab.value = b.dataset.tab;
181
- });
182
- },
183
- methods: {
184
- cancel: () => panel?.close(),
185
- copyUrl: () => copy(model.pageUrl.peek(), 'Booking page address copied'),
186
- addClosure() { closures.value = [...closures.peek(), closureRow({from: ctx.boot.today, to: ctx.boot.today, label: ''})]; rescan(); },
187
- async save() {
188
- if (saving.peek()) return;
189
- const closed = closuresOut();
190
- for (const o of closed) {
191
- if (!isDate(o.from) || !isDate(o.to) || o.to < o.from) { tab.value = 'closed'; E.toast('Closed days: each needs a start date, and an end on or after it.', {type: 'warning'}); return; }
192
- }
193
- const out = {};
194
- for (const [k, o] of Object.entries(f)) out[k] = o.peek();
195
- for (const k of BOOL_KEYS) out[k] = Boolean(out[k]);
196
- out.changeNoticeHours = Number(out.changeNoticeHours) || 0;
197
- out.reminderHours = Number(out.reminderHours) || 0;
198
- out.closures = closed;
199
- saving.value = true;
200
- const el = panel.panel;
201
- try {
202
- const r = await api.settings.save(out);
203
- Object.assign(ctx.settings, r.settings);
204
- ctx.tz = r.settings.timeZone;
205
- ctx.boot.settings = ctx.settings;
206
- E.toast('Booking settings saved.', {type: 'success'});
207
- const moved = r.settings.timeZone !== s.timeZone;
208
- panel.close(true);
209
- if (moved) location.reload();
210
- } catch (e) {
211
- const errors = e?.body?.errors || {};
212
- for (const box of el.querySelectorAll('[data-err]')) { box.textContent = errors[box.dataset.err] || ''; box.hidden = !errors[box.dataset.err]; }
213
- const first = Object.keys(errors)[0];
214
- if (first && FIELD_SECTION[first]) tab.value = FIELD_SECTION[first];
215
- E.toast(`Not saved: ${errText(e)}`, {type: 'error', duration: 8000});
216
- } finally {
217
- saving.value = false;
218
- }
219
- }
220
- }
221
- });
222
- }
@@ -1,17 +0,0 @@
1
- {
2
- "slug": "booking-bookables",
3
- "title": "Booking - People & rooms",
4
- "description": "Who and what can be booked: people (appointments) and resources (rooms, equipment), each with weekly hours and days off. Edit them in Booking, not here.",
5
- "plugin": "booking",
6
- "fields": [
7
- {"name": "name", "label": "Name", "type": "text"},
8
- {"name": "kind", "label": "Kind", "type": "text"},
9
- {"name": "active", "label": "Active", "type": "boolean"}
10
- ],
11
- "api": {
12
- "create": {"enabled": false, "access": "admin"},
13
- "read": {"enabled": false, "access": "admin"},
14
- "update": {"enabled": false, "access": "admin"},
15
- "delete": {"enabled": false, "access": "admin"}
16
- }
17
- }
@@ -1,18 +0,0 @@
1
- {
2
- "slug": "booking-bookings",
3
- "title": "Booking - Bookings",
4
- "description": "Bookings, times in UTC. They hold customers' details: change them in Booking, never here, so the diary and the emails stay right.",
5
- "plugin": "booking",
6
- "fields": [
7
- {"name": "startAt", "label": "Starts (UTC)", "type": "text"},
8
- {"name": "status", "label": "Status", "type": "text"},
9
- {"name": "serviceName", "label": "Service", "type": "text"},
10
- {"name": "email", "label": "Email", "type": "text"}
11
- ],
12
- "api": {
13
- "create": {"enabled": false, "access": "admin"},
14
- "read": {"enabled": false, "access": "admin"},
15
- "update": {"enabled": false, "access": "admin"},
16
- "delete": {"enabled": false, "access": "admin"}
17
- }
18
- }
@@ -1,17 +0,0 @@
1
- {
2
- "slug": "booking-services",
3
- "title": "Booking - Services",
4
- "description": "What can be booked, for how long, and with whom. Edit them in Booking, not here.",
5
- "plugin": "booking",
6
- "fields": [
7
- {"name": "name", "label": "Name", "type": "text"},
8
- {"name": "duration", "label": "Length (minutes)", "type": "number"},
9
- {"name": "active", "label": "Active", "type": "boolean"}
10
- ],
11
- "api": {
12
- "create": {"enabled": false, "access": "admin"},
13
- "read": {"enabled": false, "access": "admin"},
14
- "update": {"enabled": false, "access": "admin"},
15
- "delete": {"enabled": false, "access": "admin"}
16
- }
17
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Booking - default settings.
3
- *
4
- * Every one is editable from the cog in the Booking banner, which writes to
5
- * config/plugins.json under `booking.settings`. Times are the business's
6
- * wall clock in `timeZone`.
7
- */
8
- export default {
9
- // The booking page
10
- pageTitle: 'Book',
11
- bookingPath: '/booking',
12
- intro: '',
13
- timeZone: 'Europe/London',
14
- askPhone: true,
15
- phoneRequired: false,
16
- termsUrl: '',
17
- confirmationNote: '',
18
-
19
- // Changes by the customer
20
- allowCancel: true,
21
- allowMove: true,
22
- changeNoticeHours: 24,
23
-
24
- // Emails
25
- sendConfirmation: true,
26
- reminderHours: 24,
27
- notifyAddress: '',
28
-
29
- // Links to other Tools
30
- addToContacts: true,
31
- contactsOwnerId: '',
32
- calendarBusy: true,
33
-
34
- // Closed days for the whole business: [{from, to, label}]
35
- closures: []
36
- };
@@ -1,73 +0,0 @@
1
- ---
2
- title: Guide
3
- order: 1
4
- ---
5
-
6
- Let people book time with you, your team, or a room or piece of equipment, straight from your website. Booking is free.
7
-
8
- ## What it does
9
-
10
- - A booking page at `/booking` (you can change the address). Customers pick a service, a day and a free time, then enter their details.
11
- - **People and rooms.** A person is someone customers book an appointment with. A room or resource is something they book, such as a meeting room, a court or a van. Each has its own weekly hours and days off.
12
- - **Services.** Each service has a length and optional buffer time before and after, for setting up, cleaning or travel. You also choose how often a start time is offered, how much notice you need, how far ahead people can book, and who provides it.
13
- - **Emails.** Customers get a confirmation with a calendar file and a reminder before the booking, and you get a copy of each new booking. Each email has a private link that lets the customer move or cancel within the notice you set.
14
- - **The Diary** in the admin, by day or by week, plus a list of every booking. The sidebar badge shows how many bookings are still to come today; once none are left, it shows how many there are in the next 7 days.
15
- - **Nobody is double-booked.** A time is only offered while it is free, and it is checked again at the moment of booking.
16
-
17
- ## Getting started
18
-
19
- 1. Switch Booking on in **Tools**.
20
- 2. Open **Booking > People & rooms** and add who or what can be booked. Set the weekly hours and any days off.
21
- 3. Open **Services** and add what can be booked, how long it takes, and who provides it.
22
- 4. Open the settings (the cog in the Booking banner) and check the booking page's address, your time zone and the emails.
23
- 5. Share the booking page link, or put the booking form on any page with the `[booking /]` shortcode.
24
-
25
- Booking emails need the site's outgoing email (SMTP) to be set up in **Settings**. Without it, bookings still work, but no emails are sent, and the Booking settings will warn you. The links in those emails (change or cancel, join the call) use the **Site URL** in **Settings > Site**; until it is set, emails go out without links.
26
-
27
- ## Booking from Contacts and Email
28
-
29
- - **From a contact:** open the contact's menu and choose **Book (name)...** to start a new booking with their details filled in. The contact card also shows their bookings.
30
- - **From an email:** in Email or Mail Reader, right-click a message (or use its menu) and choose **Book (name)...** to book the sender. If they are already one of your contacts, the booking starts from that contact (phone number included) and is linked to it - no second contact is made.
31
- - **New customers become contacts.** When someone books, they are added to your Contacts. If they are already there, the booking is linked to their existing contact. You can switch this off in the settings.
32
-
33
- The **Book...** options only appear for people who are allowed to manage bookings. The contact option also needs the Contacts Tool switched on.
34
-
35
- ## Working with the Calendar
36
-
37
- If you also use the Calendar Tool, bookings appear there under **Bookings**. A person's own Calendar events block their booking times, so nobody can book them while they are busy. To use this, link the person to their user account in **People & rooms**. You can switch it off per person or for the whole of Booking.
38
-
39
- Search engines show the **Introduction** (booking settings) as the booking page's description, and a service's description on its own page. Left empty, they get a line made from your site's name and services.
40
-
41
- ## Putting the booking form on a page
42
-
43
- | Shortcode | What it shows |
44
- |---|---|
45
- | `[booking /]` | The whole booking form, starting with the list of services |
46
- | `[booking service="consultation" /]` | Goes straight to one service (use the service's address name, shown in its editor) |
47
- | `[booking service="consultation" with="..." /]` | One service with one person or room already chosen |
48
-
49
- ## Changes and cancellations
50
-
51
- - **Customers** can move or cancel their own booking from the link in their emails, up to the notice you set (24 hours by default). Closer to the time, the page asks them to contact you instead. You can switch moving and cancelling off in the settings.
52
- - **You** can move, cancel, or mark a booking as completed or a no-show from the Diary or the booking itself. When you move or cancel a booking, tick **Email the customer** if you want them to be told.
53
- - If you pick a time that clashes with another booking, Booking asks before double-booking. Only staff can double-book; customers never can.
54
-
55
- ## Who can use it
56
-
57
- Booking has its own permission, **Booking**, which admins have by default. **See** lets someone view the Diary and bookings. **Manage** lets them make, move and cancel bookings, and edit services, people and rooms, and the settings. To give it to other roles, open **Users & Roles**.
58
-
59
- ## Booking Pro
60
-
61
- Booking Pro adds the following to the free Tool:
62
- - Online appointments, held as a video call on your site. What is typed in the call's chat is kept: open the booking and click **Call chat** to read it afterwards (a class shares one chat).
63
- - **Add people** during an online call: the person being booked clicks **Add people** in the call, searches their contacts and the team (or types a name and email), and sends each person their own Join link - by email, and for team members also as a notification and a message in Messages. They knock and you let them in. **Copy link** gives you a link to pass on yourself. This needs the person to be linked to their account on the site (**People & rooms**); without one, their call offers **Copy link** only.
64
- - **Call now**: open an online booking's call early, or start a video call with anyone straight away - from Booking, a contact or an email.
65
- - Services that need more than one person or room at once.
66
- - Classes and group sessions with places and a waiting list.
67
- - Recurring bookings.
68
- - Questions to ask customers when they book.
69
- - A daily limit per person or room, and one booking per customer every so many days.
70
-
71
- Taking payment or a deposit online, and booking reports, are planned for Booking Pro.
72
-
73
- Your bookings stay the same with or without Pro.
@@ -1 +0,0 @@
1
- <script type="module" src="/plugins/booking/public/booking.js?v=1.3.1"></script>
@@ -1,88 +0,0 @@
1
- /**
2
- * Online bookings (made online by Booking Pro): who may join which call, and
3
- * the addresses in the emails, the .ics, the customer's page and the admin.
4
- *
5
- * The call itself is the engine's (`_lib/call`). A room is a SESSION - the
6
- * same service, start and person - so everyone booked into an online class
7
- * shares one call, and a one-to-one appointment is a session of one. Links
8
- * name the session and the booking: `?b=<booking>&t=<customer token>` for the
9
- * customer, `&h=<host key>` for the person they booked, `&g=<invite pass>` for
10
- * someone the host added while the call runs ("Add people", 1.6: a pass under
11
- * the session's `callExtraKey` - never the customer's token or the host key -
12
- * who names themselves and knocks). Booking (free) serves
13
- * these for any booking that is already online, so a lapsed Pro licence
14
- * strands nobody; only Pro can make a service online in the first place.
15
- *
16
- * @module booking/lib/call
17
- */
18
-
19
- import {createHash, timingSafeEqual} from 'crypto';
20
-
21
- // Add people (1.6) needs a core with _lib/call/invite.js; an older one has no invite passes.
22
- let invite = null;
23
- try { invite = await import('../../_lib/call/invite.js'); } catch { invite = null; }
24
- /** Does this core have "Add people"? */
25
- export const invitesAvailable = () => Boolean(invite);
26
-
27
- export const OPENS_BEFORE_MIN = 10;
28
- export const CLOSES_AFTER_MIN = 60;
29
- const HOLDING = new Set(['pending', 'confirmed', 'completed', 'no-show']);
30
-
31
- /** The room a booking's call happens in. */
32
- export const sessionOf = (b) => createHash('sha256').update(`${b.serviceId}|${b.startAt}|${b.bookableId}`).digest('base64url').slice(0, 22);
33
-
34
- const same = (a, b) => {
35
- const x = Buffer.from(String(a || ''));
36
- const y = Buffer.from(String(b || ''));
37
- return x.length === y.length && x.length > 0 && timingSafeEqual(x, y);
38
- };
39
-
40
- /** The customer's join address (relative to the site). */
41
- export const joinPath = (settings, b) => `${settings.bookingPath}/call/${sessionOf(b)}?b=${encodeURIComponent(b.id)}&t=${encodeURIComponent(b.token)}`;
42
- /** The host's (the person booked) - never shown to the customer. */
43
- export const hostPath = (settings, b) => `${settings.bookingPath}/call/${sessionOf(b)}?b=${encodeURIComponent(b.id)}&h=${encodeURIComponent(b.hostKey)}`;
44
-
45
- /** A Join link for someone added to the call (1.6): a new pass under the session's extra key. */
46
- export const invitePath = (settings, b, key) => (invite && key
47
- ? `${settings.bookingPath}/call/${sessionOf(b)}?b=${encodeURIComponent(b.id)}&g=${encodeURIComponent(invite.invitePass(key, sessionOf(b)))}` : '');
48
-
49
- /** How long a call opened early ("Call now", Booking 1.4) stays open at least. */
50
- export const OPENED_EARLY_HOURS = 2;
51
-
52
- /**
53
- * When the call opens and closes, for a booking. Staff may open it early
54
- * (`callOpenedAt`, "Call now"): it opens then, and stays open at least
55
- * OPENED_EARLY_HOURS after, even when the booking itself is later.
56
- */
57
- export function callWindow(b, now = Date.now()) {
58
- const opens = Date.parse(b.startAt) - OPENS_BEFORE_MIN * 60000;
59
- const closes = Date.parse(b.endAt) + CLOSES_AFTER_MIN * 60000;
60
- const early = Date.parse(b.callOpenedAt || '');
61
- const iso = (a, z) => ({opensAt: new Date(a).toISOString(), closesAt: new Date(z).toISOString()});
62
- // Opened early ("Call now"): open for OPENED_EARLY_HOURS from then - not all the way to the booking,
63
- // which may be days off - joined up with the booking's own window when the two meet.
64
- if (Number.isFinite(early) && now >= early && now <= early + OPENED_EARLY_HOURS * 3600000) {
65
- const earlyEnd = early + OPENED_EARLY_HOURS * 3600000;
66
- return iso(Math.min(early, opens), earlyEnd >= opens ? Math.max(earlyEnd, closes) : earlyEnd);
67
- }
68
- return iso(opens, closes);
69
- }
70
-
71
- /**
72
- * Who the caller is in a room, or null. `cred` is what the join link carried.
73
- *
74
- * @param {object|null} b - the booking named by `cred.b`
75
- * @param {string} room - the room in the address
76
- * @param {{t?: string, h?: string, g?: string}} cred
77
- */
78
- export function whoIsCalling(b, room, cred = {}, now = Date.now()) {
79
- if (!b || b.online !== true || !HOLDING.has(b.status) || sessionOf(b) !== room) return null;
80
- const base = {title: b.serviceName, recordingAllowed: b.recordingAllowed === true, max: 6, ...callWindow(b, now)};
81
- // identity: a link the host turns away cannot knock again (the engine remembers it per room).
82
- if (cred.h && same(cred.h, b.hostKey)) return {...base, host: true, name: b.bookableName || 'Host', identity: `${b.id}:host`};
83
- if (cred.t && same(cred.t, b.token)) return {...base, host: false, name: b.name || 'Guest', identity: `${b.id}:guest`};
84
- // Someone the host added (1.6): their own pass, their own name, and they knock.
85
- const nonce = cred.g && b.callExtraKey && invite ? invite.checkInvitePass(b.callExtraKey, room, cred.g) : null;
86
- if (nonce) return {...base, host: false, name: '', identity: `${room}:inv:${nonce}`, invited: true};
87
- return null;
88
- }