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.
- package/CHANGELOG.md +6 -0
- package/bin/lib/left-free-tier.js +4 -1
- package/bin/update.js +4 -0
- package/docs/DommaFeatures.md +8 -6
- 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/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,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Diary's geometry (admin/lib/diary-layout.js).
|
|
3
|
-
*/
|
|
4
|
-
import {test} from 'node:test';
|
|
5
|
-
import assert from 'node:assert/strict';
|
|
6
|
-
import {datesFor, gridHours, layoutColumn, mergeWindows, minuteAt, placeOf, weekStart, dayLabel} from '../admin/lib/diary-layout.js';
|
|
7
|
-
|
|
8
|
-
test('weeks start on Monday', () => {
|
|
9
|
-
assert.equal(weekStart('2031-07-15'), '2031-07-14');
|
|
10
|
-
assert.equal(weekStart('2031-07-20'), '2031-07-14', 'Sunday belongs to the week before');
|
|
11
|
-
assert.deepEqual(datesFor('day', '2031-07-15'), ['2031-07-15']);
|
|
12
|
-
assert.equal(datesFor('week', '2031-07-15').length, 7);
|
|
13
|
-
assert.equal(dayLabel('2031-07-15'), 'Tue 15/07');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('grid hours: opening hours, widened by bookings, at least 8 hours', () => {
|
|
17
|
-
const bk = {hours: {tue: [{from: '09:30', to: '12:00'}]}};
|
|
18
|
-
assert.deepEqual(gridHours([bk], ['2031-07-15']), {from: 540, to: 1020});
|
|
19
|
-
assert.deepEqual(gridHours([bk], ['2031-07-15'], [{startMin: 1140, endMin: 1200}]), {from: 540, to: 1200});
|
|
20
|
-
assert.deepEqual(gridHours([], ['2031-07-15']), {from: 480, to: 1080});
|
|
21
|
-
assert.deepEqual(gridHours([{hours: {tue: [{from: '18:00', to: '23:30'}]}}], ['2031-07-15']), {from: 960, to: 1440});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('placing: London time, clipped at midnight', () => {
|
|
25
|
-
assert.deepEqual(placeOf({startAt: '2031-07-15T08:00:00Z', endAt: '2031-07-15T09:00:00Z'}, 'Europe/London'), {date: '2031-07-15', startMin: 540, endMin: 600});
|
|
26
|
-
assert.deepEqual(placeOf({startAt: '2031-07-15T22:30:00Z', endAt: '2031-07-16T00:30:00Z'}, 'Europe/London'), {date: '2031-07-15', startMin: 1410, endMin: 1440});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('lanes: overlapping items side by side, separate clusters apart', () => {
|
|
30
|
-
const out = layoutColumn([
|
|
31
|
-
{id: 'a', startMin: 540, endMin: 600},
|
|
32
|
-
{id: 'b', startMin: 570, endMin: 630},
|
|
33
|
-
{id: 'c', startMin: 600, endMin: 660},
|
|
34
|
-
{id: 'd', startMin: 700, endMin: 760}
|
|
35
|
-
]);
|
|
36
|
-
const by = Object.fromEntries(out.map(x => [x.id, [x.lane, x.lanes]]));
|
|
37
|
-
assert.deepEqual(by, {a: [0, 2], b: [1, 2], c: [0, 2], d: [0, 1]});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('click to minute', () => {
|
|
41
|
-
assert.equal(minuteAt(95, {from: 480, pxPerMin: 1}), 570);
|
|
42
|
-
assert.equal(minuteAt(-5, {from: 480, pxPerMin: 1}), 480);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
import {columnItems} from '../admin/lib/diary-layout.js';
|
|
46
|
-
import {answerRows, placesLabel, sourceLabel, withNames} from '../admin/lib/details.js';
|
|
47
|
-
|
|
48
|
-
test('diary columns: companions shown in every held column; a class is one item', () => {
|
|
49
|
-
const at = '2031-07-15T09:00:00.000Z';
|
|
50
|
-
const bs = [
|
|
51
|
-
{id: '1', serviceId: 'lesson', bookableId: 'tr', holds: ['tr', 'c1'], startAt: at, status: 'confirmed'},
|
|
52
|
-
{id: '2', serviceId: 'yoga', bookableId: 'tr2', startAt: at, status: 'confirmed'},
|
|
53
|
-
{id: '3', serviceId: 'yoga', bookableId: 'tr2', startAt: at, status: 'confirmed'},
|
|
54
|
-
{id: '4', serviceId: 'yoga', bookableId: 'tr2', startAt: at, status: 'cancelled'}
|
|
55
|
-
];
|
|
56
|
-
assert.deepEqual(columnItems(bs, {bookableId: 'c1'}).map(i => [i.b.id, i.companion, i.session]), [['1', true, false]]);
|
|
57
|
-
assert.deepEqual(columnItems(bs, {bookableId: 'tr'}).map(i => [i.b.id, i.companion]), [['1', false]]);
|
|
58
|
-
const yoga = columnItems(bs, {bookableId: 'tr2'});
|
|
59
|
-
assert.deepEqual(yoga.map(i => [i.bookings.map(b => b.id), i.session]), [[['2', '3'], true], [['4'], false]]);
|
|
60
|
-
assert.equal(columnItems(bs).length, 3, 'week view: no companion copies, the class once, the cancelled one alone');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('booking details: who, where from, answers, places', () => {
|
|
64
|
-
assert.equal(withNames({bookableName: 'Alex'}), 'Alex');
|
|
65
|
-
assert.equal(withNames({bookableName: 'Alex', alsoNames: ['Court 1']}), 'Alex and Court 1');
|
|
66
|
-
assert.equal(withNames({bookableName: 'Alex', alsoNames: ['Court 1', 'Balls']}), 'Alex, Court 1 and Balls');
|
|
67
|
-
assert.equal(sourceLabel('waitlist'), 'From the waiting list');
|
|
68
|
-
const svc = {ext: {'booking-pro': {questions: [{id: 'level', label: 'Level'}, {id: 'ok', label: 'Agreed'}]}}};
|
|
69
|
-
assert.deepEqual(answerRows({ok: true, level: 'Improver', gone: 3, empty: ''}, svc), [['Level', 'Improver'], ['Agreed', 'Yes'], ['gone', '3']]);
|
|
70
|
-
assert.deepEqual(answerRows(null), []);
|
|
71
|
-
assert.equal(placesLabel(1), '1 place left');
|
|
72
|
-
assert.equal(placesLabel(3), '3 places left');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('week bands: windows merged where they touch or overlap, sorted, inputs untouched', () => {
|
|
76
|
-
const input = [{from: 780, to: 1020}, {from: 540, to: 750}, {from: 600, to: 780}, {from: 1080, to: 1140}];
|
|
77
|
-
assert.deepEqual(mergeWindows(input), [{from: 540, to: 1020}, {from: 1080, to: 1140}]);
|
|
78
|
-
assert.deepEqual(input[0], {from: 780, to: 1020}, 'no input is changed');
|
|
79
|
-
assert.deepEqual(mergeWindows([]), []);
|
|
80
|
-
assert.deepEqual(mergeWindows(undefined), []);
|
|
81
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Drafts in the admin's slideovers - the pure part (admin/lib/drafts.js).
|
|
3
|
-
*/
|
|
4
|
-
import {test} from 'node:test';
|
|
5
|
-
import assert from 'node:assert/strict';
|
|
6
|
-
import {
|
|
7
|
-
agoText, draftsWith, draftsWithout, fingerprint, orphanDrafts, restorePlan, restoreText, stableStringify, staleDraftKeys, usableDraft
|
|
8
|
-
} from '../admin/lib/drafts.js';
|
|
9
|
-
|
|
10
|
-
const NOW = Date.parse('2031-07-15T12:00:00Z');
|
|
11
|
-
const at = (minAgo) => new Date(NOW - minAgo * 60_000).toISOString();
|
|
12
|
-
|
|
13
|
-
test('stable JSON and fingerprints ignore key order, see every change', () => {
|
|
14
|
-
assert.equal(stableStringify({b: 1, a: [2, {d: 3, c: 4}]}), '{"a":[2,{"c":4,"d":3}],"b":1}');
|
|
15
|
-
assert.equal(fingerprint({a: 1, b: 2}), fingerprint({b: 2, a: 1}));
|
|
16
|
-
assert.notEqual(fingerprint({a: 1, b: 2}), fingerprint({a: 1, b: 3}));
|
|
17
|
-
assert.notEqual(fingerprint({closures: []}), fingerprint({closures: [{from: '2031-12-25'}]}));
|
|
18
|
-
assert.match(fingerprint({}), /^f[0-9a-z]+$/);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('a stored draft is used only when it looks like one and is not too old', () => {
|
|
22
|
-
assert.equal(usableDraft(null, {now: NOW}), null);
|
|
23
|
-
assert.equal(usableDraft('x', {now: NOW}), null);
|
|
24
|
-
assert.equal(usableDraft({values: [1]}, {now: NOW}), null);
|
|
25
|
-
assert.equal(usableDraft({values: {a: 1}}, {now: NOW}), null, 'no date: not trusted');
|
|
26
|
-
assert.equal(usableDraft({values: {a: 1}, at: at(15 * 24 * 60)}, {now: NOW}), null, 'older than 14 days');
|
|
27
|
-
assert.deepEqual(usableDraft({values: {a: 1}, at: at(5), was: 'w1', label: 'Haircut'}, {now: NOW}),
|
|
28
|
-
{values: {a: 1}, at: at(5), was: 'w1', label: 'Haircut'});
|
|
29
|
-
assert.deepEqual(usableDraft({values: {}, at: at(5), was: 7}, {now: NOW}).was, '', 'a non-string was is none');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('restore plan: nothing, put back, or ask', () => {
|
|
33
|
-
const d = {values: {name: 'Sam'}, at: at(3), was: '2031-07-15T10:00:00Z', label: 'Haircut'};
|
|
34
|
-
assert.equal(restorePlan({draft: null}), 'none');
|
|
35
|
-
assert.equal(restorePlan({draft: d, was: d.was, opening: {name: 'Sam'}}), 'none', 'the same as the form already holds');
|
|
36
|
-
assert.equal(restorePlan({draft: d, was: d.was, opening: {name: ''}}), 'auto');
|
|
37
|
-
assert.equal(restorePlan({draft: d, was: '2031-07-15T11:30:00Z', opening: {name: ''}}), 'changed', 'saved since');
|
|
38
|
-
assert.equal(restorePlan({draft: {...d, was: ''}, was: '', opening: {}, prefilled: true}), 'prefilled');
|
|
39
|
-
assert.equal(restorePlan({draft: {...d, was: ''}, was: 'x', opening: {}, prefilled: true}), 'changed', 'a change outranks the prefill');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('the words', () => {
|
|
43
|
-
assert.equal(agoText(at(0.2), NOW), 'just now');
|
|
44
|
-
assert.equal(agoText(at(12), NOW), '12 min ago');
|
|
45
|
-
assert.equal(agoText(at(60 * 26), NOW), 'yesterday');
|
|
46
|
-
assert.equal(agoText('nonsense', NOW), 'earlier');
|
|
47
|
-
assert.equal(restoreText('auto', {label: 'Haircut', at: at(2), now: NOW}), 'Unsaved changes from 2 min ago put back (Haircut).');
|
|
48
|
-
assert.match(restoreText('changed', {label: 'Haircut', at: at(2), now: NOW}), /to “Haircut” 2 min ago, and it has been saved since.*Discard your changes, or keep them/);
|
|
49
|
-
assert.match(restoreText('deleted', {label: 'Room 1', at: at(2), now: NOW}), /deleted since\. Discard them, or start a new one/);
|
|
50
|
-
assert.match(restoreText('prefilled', {label: 'Sam', at: at(2), now: NOW, kind: 'a new booking'}), /^You started a new booking \(Sam\) 2 min ago.*Discard it and start this one/);
|
|
51
|
-
assert.equal(restoreText('none'), '');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('the stored map: set, remove, orphans, stale', () => {
|
|
55
|
-
const live = {values: {}, at: at(1)};
|
|
56
|
-
let map = draftsWith(null, 'service:a', live);
|
|
57
|
-
map = draftsWith(map, 'service:gone', {...live, label: 'Old'});
|
|
58
|
-
map = draftsWith(map, 'service:new', live);
|
|
59
|
-
map = draftsWith(map, 'bookable:gone', live);
|
|
60
|
-
map = draftsWith(map, 'service:old', {values: {}, at: at(20 * 24 * 60)});
|
|
61
|
-
const before = {...map};
|
|
62
|
-
assert.deepEqual(Object.keys(draftsWithout(map, 'service:a')).sort(), ['bookable:gone', 'service:gone', 'service:new', 'service:old']);
|
|
63
|
-
assert.deepEqual(map, before, 'not changed in place');
|
|
64
|
-
const o = orphanDrafts(map, 'service:', ['a'], {now: NOW});
|
|
65
|
-
assert.deepEqual(o.map(x => [x.key, x.id, x.draft.label]), [['service:gone', 'gone', 'Old']], 'new, live and stale ones are not orphans');
|
|
66
|
-
assert.deepEqual(staleDraftKeys(map, {now: NOW}), ['service:old']);
|
|
67
|
-
});
|