@sprucelabs/spruce-calendar-components 28.3.103 → 29.0.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/build/.spruce/errors/errors.types.d.ts +12 -12
- package/build/.spruce/errors/errors.types.js +0 -2
- package/build/.spruce/errors/options.types.d.ts +2 -2
- package/build/.spruce/schemas/schemas.types.d.ts +3287 -2737
- package/build/.spruce/schemas/schemas.types.js +1 -2
- package/build/__tests__/support/CalendarToolBeltStateMachineTestFactory.js +24 -13
- package/build/__tests__/support/SpyEventManager.js +1 -1
- package/build/__tests__/support/SpyPeopleManager.js +4 -4
- package/build/__tests__/support/SpyRemoteEventStore.js +4 -4
- package/build/__tests__/support/utilities/calendarAssert.js +2 -4
- package/build/__tests__/support/utilities/calendarSkillAssert.js +25 -10
- package/build/__tests__/support/utilities/calendarToolBeltInteractor.js +3 -1
- package/build/calendar/Calendar.vc.js +52 -43
- package/build/calendar/CalendarEventManager.js +86 -66
- package/build/calendar/CalendarPeopleManager.js +17 -16
- package/build/calendar/CalendarPersister.d.ts +2 -2
- package/build/calendar/CalendarPersister.js +13 -8
- package/build/calendar/calculateCalendarEventDifferences.js +6 -3
- package/build/constants.js +1 -2
- package/build/errors/SpruceError.d.ts +1 -1
- package/build/errors/SpruceError.js +1 -1
- package/build/esm/.spruce/errors/errors.types.d.ts +12 -12
- package/build/esm/.spruce/errors/errors.types.js +0 -2
- package/build/esm/.spruce/errors/options.types.d.ts +2 -2
- package/build/esm/.spruce/schemas/schemas.types.d.ts +3287 -2737
- package/build/esm/.spruce/schemas/schemas.types.js +1 -2
- package/build/esm/__tests__/support/utilities/calendarAssert.js +0 -1
- package/build/esm/__tests__/support/utilities/calendarSkillAssert.js +2 -2
- package/build/esm/calendar/Calendar.vc.js +0 -3
- package/build/esm/calendar/CalendarEventManager.js +3 -2
- package/build/esm/calendar/CalendarPeopleManager.js +0 -2
- package/build/esm/calendar/CalendarPersister.d.ts +2 -2
- package/build/esm/errors/SpruceError.d.ts +1 -1
- package/build/esm/noSchedules/peopleToPeopleWithoutSchedules.d.ts +1 -1
- package/build/esm/root/Root.svc.d.ts +2 -2
- package/build/esm/root/Root.svc.js +4 -2
- package/build/esm/stores/RemoteEventStore.js +7 -4
- package/build/esm/toolBelt/CalendarToolRegistrar.js +4 -1
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +5 -2
- package/build/esm/toolBelt/states/RootToolBeltState.js +2 -1
- package/build/esm/tools/CalendarSelectTool.vc.js +5 -2
- package/build/esm/tools/EventRepeatingTool.vc.js +3 -1
- package/build/esm/tools/PersonSelectTool.vc.js +8 -3
- package/build/esm/viewControllers/DateSelectCard.vc.js +1 -4
- package/build/esm/viewControllers/RepeatingControlsList.vc.js +2 -1
- package/build/noSchedules/peopleToPeopleWithoutSchedules.d.ts +1 -1
- package/build/root/Root.svc.d.ts +2 -2
- package/build/root/Root.svc.js +73 -48
- package/build/stores/RemoteEventStore.js +60 -38
- package/build/stores/RemotePreferencesStore.js +10 -4
- package/build/toolBelt/CalendarToolRegistrar.js +8 -9
- package/build/toolBelt/CalendarToolTestFactory.js +10 -4
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +37 -27
- package/build/toolBelt/states/PrerequisitesToolBeltState.js +31 -22
- package/build/toolBelt/states/RootToolBeltState.js +23 -19
- package/build/toolBelt/states/UniversalEventToolBeltState.js +1 -4
- package/build/toolBelt/states/makeEventTyped.js +1 -2
- package/build/tools/CalendarSelectTool.vc.js +12 -6
- package/build/tools/EventDateTimeTool.vc.js +10 -6
- package/build/tools/EventDurationTool.vc.js +8 -5
- package/build/tools/EventRepeatingTool.vc.js +23 -7
- package/build/tools/EventTitleTool.vc.js +8 -5
- package/build/tools/PersonSelectTool.vc.js +17 -9
- package/build/utilities/draftGenerator.js +1 -1
- package/build/viewControllers/DateSelectCard.vc.js +12 -7
- package/build/viewControllers/EventControlsCard.vc.js +9 -5
- package/build/viewControllers/RepeatingControlsList.vc.js +52 -58
- package/build/viewControllers/SelectUpdateRepeatingStrategyCard.vc.js +7 -4
- package/build/viewControllers/UniversalCalendarEvent.vc.js +1 -1
- package/package.json +1 -1
|
@@ -15,30 +15,36 @@ const SpyPeopleManager_1 = __importDefault(require("./SpyPeopleManager"));
|
|
|
15
15
|
const mixinViewControllersForTests_1 = __importDefault(require("./utilities/mixinViewControllersForTests"));
|
|
16
16
|
class CalendarToolBeltStateMachineTestFactory {
|
|
17
17
|
static async StateMachine(views, options) {
|
|
18
|
-
const { EventManagerClass, calendarVc: passedCalendarVc } = options
|
|
18
|
+
const { EventManagerClass, calendarVc: passedCalendarVc } = options ?? {};
|
|
19
19
|
const factory = views.getFactory();
|
|
20
20
|
(0, mixinViewControllersForTests_1.default)(factory);
|
|
21
21
|
const toolBeltVc = views.Controller('toolBelt', {});
|
|
22
22
|
const event = heartwood_view_controllers_1.calendarSeeder.generateEventValues();
|
|
23
|
-
const calendarVc = passedCalendarVc
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
const calendarVc = passedCalendarVc ??
|
|
24
|
+
views.Controller('calendar.calendar', {
|
|
25
|
+
onAddDraftEvent: async (event) => {
|
|
26
|
+
await events.addDraftEvent(event);
|
|
27
|
+
},
|
|
28
|
+
onEventSwapped(draft, saved) {
|
|
29
|
+
return events.silentlySwapEvent(draft.id, saved);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
31
32
|
calendarVc.addEvent(event);
|
|
32
33
|
const sm = new heartwood_view_controllers_1.ToolBeltStateMachine({
|
|
33
34
|
vcFactory: views.getFactory(),
|
|
34
35
|
toolBeltVc,
|
|
35
36
|
connectToApi: async () => spruce_test_fixtures_1.fake.getClient(),
|
|
36
|
-
context:
|
|
37
|
+
context: {
|
|
38
|
+
...views.getRouter().buildLoadOptions(),
|
|
39
|
+
event,
|
|
40
|
+
calendarVc: calendarVc,
|
|
41
|
+
cancelEvent: () => { },
|
|
42
|
+
},
|
|
37
43
|
});
|
|
38
44
|
const connectToApi = async () => spruce_test_fixtures_1.fake.getClient();
|
|
39
45
|
const preferences = new FakeRemotePreferences({ connectToApi });
|
|
40
46
|
const remoteEventsStore = new FakeRemoteEventStore();
|
|
41
|
-
const events = new (EventManagerClass
|
|
47
|
+
const events = new (EventManagerClass ?? SpyEventManager_1.default)({
|
|
42
48
|
calendarVc,
|
|
43
49
|
sm,
|
|
44
50
|
dates: calendar_utils_1.dateUtil,
|
|
@@ -75,9 +81,15 @@ class FakeRemotePreferences extends RemotePreferencesStore_1.default {
|
|
|
75
81
|
async save() { }
|
|
76
82
|
}
|
|
77
83
|
class FakeRemoteEventStore {
|
|
84
|
+
static calendars = [];
|
|
85
|
+
lastPersistedEvent;
|
|
78
86
|
async load(_options) { }
|
|
79
87
|
async persist(event) {
|
|
80
|
-
const e =
|
|
88
|
+
const e = {
|
|
89
|
+
dateCreated: new Date().getTime(),
|
|
90
|
+
...heartwood_view_controllers_1.calendarSeeder.generateEventValues(),
|
|
91
|
+
...event,
|
|
92
|
+
};
|
|
81
93
|
if (draftGenerator_1.default.isDraftId(e.id)) {
|
|
82
94
|
e.id = (0, test_utils_1.generateId)();
|
|
83
95
|
}
|
|
@@ -106,4 +118,3 @@ class FakeRemoteEventStore {
|
|
|
106
118
|
setStreamHandler(_cb) { }
|
|
107
119
|
}
|
|
108
120
|
exports.FakeRemoteEventStore = FakeRemoteEventStore;
|
|
109
|
-
FakeRemoteEventStore.calendars = [];
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const CalendarEventManager_1 = __importDefault(require("../../calendar/CalendarEventManager"));
|
|
7
7
|
class SpyEventManager extends CalendarEventManager_1.default {
|
|
8
|
+
wereShiftsRefreshed = false;
|
|
8
9
|
getShouldIgnoreNextContextUpdate() {
|
|
9
10
|
return this.shouldIgnoreNextContextUpdate;
|
|
10
11
|
}
|
|
11
12
|
constructor(options) {
|
|
12
13
|
super(options);
|
|
13
|
-
this.wereShiftsRefreshed = false;
|
|
14
14
|
}
|
|
15
15
|
refreshShifts() {
|
|
16
16
|
this.wereShiftsRefreshed = true;
|
|
@@ -5,16 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const CalendarPeopleManager_1 = __importDefault(require("../../calendar/CalendarPeopleManager"));
|
|
7
7
|
class SpyPeopleManager extends CalendarPeopleManager_1.default {
|
|
8
|
+
visiblePeopleIds;
|
|
9
|
+
peopleVisibilityMode;
|
|
8
10
|
constructor(options) {
|
|
9
11
|
super(options);
|
|
10
12
|
}
|
|
11
13
|
getVisiblePeopleIds() {
|
|
12
|
-
|
|
13
|
-
return (_a = this.visiblePeopleIds) !== null && _a !== void 0 ? _a : super.getVisiblePeopleIds();
|
|
14
|
+
return this.visiblePeopleIds ?? super.getVisiblePeopleIds();
|
|
14
15
|
}
|
|
15
16
|
getVisibilityMode() {
|
|
16
|
-
|
|
17
|
-
return (_a = this.peopleVisibilityMode) !== null && _a !== void 0 ? _a : super.getVisibilityMode();
|
|
17
|
+
return this.peopleVisibilityMode ?? super.getVisibilityMode();
|
|
18
18
|
}
|
|
19
19
|
async setVisiblePeopleIds(ids, options) {
|
|
20
20
|
return super.setVisiblePeopleIds(ids, options);
|
|
@@ -6,21 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
7
7
|
const RemoteEventStore_1 = __importDefault(require("../../stores/RemoteEventStore"));
|
|
8
8
|
class SpyRemoteEventStore extends RemoteEventStore_1.default {
|
|
9
|
+
lastPersistedEvent;
|
|
9
10
|
constructor(options) {
|
|
10
11
|
const { calendars, client, locationId, organizationId } = options;
|
|
11
12
|
super({ connectToApi: async () => client });
|
|
12
13
|
this.client = client;
|
|
13
14
|
this.calendars = calendars;
|
|
14
|
-
this.locationId = locationId
|
|
15
|
-
this.organizationId = organizationId
|
|
15
|
+
this.locationId = locationId ?? (0, test_utils_1.generateId)();
|
|
16
|
+
this.organizationId = organizationId ?? (0, test_utils_1.generateId)();
|
|
16
17
|
}
|
|
17
18
|
setOrganizationId(id) {
|
|
18
19
|
this.organizationId = id;
|
|
19
20
|
}
|
|
20
21
|
async cancelEvent(_id, _options) { }
|
|
21
22
|
async getCalendars() {
|
|
22
|
-
|
|
23
|
-
return (_a = this.calendars) !== null && _a !== void 0 ? _a : super.getCalendars();
|
|
23
|
+
return this.calendars ?? super.getCalendars();
|
|
24
24
|
}
|
|
25
25
|
async persist(event) {
|
|
26
26
|
const results = await super.persist(event);
|
|
@@ -29,9 +29,8 @@ const calendarAssert = {
|
|
|
29
29
|
try {
|
|
30
30
|
test_utils_1.assert.doesInclude(e, lookup);
|
|
31
31
|
return e;
|
|
32
|
-
// eslint-disable-next-line no-empty
|
|
33
32
|
}
|
|
34
|
-
catch
|
|
33
|
+
catch { }
|
|
35
34
|
return null;
|
|
36
35
|
});
|
|
37
36
|
test_utils_1.assert.isTruthy(match, `I could not find an event that matched:\n\n${test_utils_1.assertUtil.stringify(lookup)}`);
|
|
@@ -59,11 +58,10 @@ const calendarAssert = {
|
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
eventEquals(actual, expected) {
|
|
62
|
-
var _a, _b, _c, _d;
|
|
63
61
|
test_utils_1.assert.isTruthy(actual, 'Event is missing');
|
|
64
62
|
test_utils_1.assert.isTruthy(expected, 'Event is missing');
|
|
65
63
|
test_utils_1.assert.isEqual(actual.startDateTimeMs, expected.startDateTimeMs, 'startDateTimeMs does not match');
|
|
66
|
-
test_utils_1.assert.isEqual(
|
|
64
|
+
test_utils_1.assert.isEqual(actual.isBusy ?? false, expected.isBusy ?? false, `isBusy does not match, needs to be '${expected.isBusy ?? false}' but got '${actual.isBusy ?? false}'`);
|
|
67
65
|
const cleanedActual = (0, just_clone_1.default)(actual);
|
|
68
66
|
const cleanedExpected = (0, just_clone_1.default)(expected);
|
|
69
67
|
cleanEvent(cleanedActual);
|
|
@@ -45,7 +45,6 @@ const calendarSkillAssert = {
|
|
|
45
45
|
await fakeCalendarEvents(this.createdCalendars);
|
|
46
46
|
},
|
|
47
47
|
async createsCalendarOnInstall(calendarSlug, client, typeSlugs) {
|
|
48
|
-
var _a, _b, _c, _d;
|
|
49
48
|
assertRanBeforeEach(this);
|
|
50
49
|
(0, schema_1.assertOptions)({
|
|
51
50
|
calendarSlug,
|
|
@@ -67,7 +66,7 @@ const calendarSkillAssert = {
|
|
|
67
66
|
},
|
|
68
67
|
});
|
|
69
68
|
if (responses.totalErrors > 0) {
|
|
70
|
-
throw
|
|
69
|
+
throw responses.responses[0].errors?.[0] ?? `did-instal error`;
|
|
71
70
|
}
|
|
72
71
|
if (responses.totalResponses === 0) {
|
|
73
72
|
test_utils_1.assert.fail(`did-install listener missing! To get this test passing your skill will need to be listening to did-install, try 'spruce create.listener' and look under Mercury. You may also need to boot your skill with 'await this.bootSkill()'`);
|
|
@@ -99,7 +98,7 @@ await client.emitAndFlattenResponses(
|
|
|
99
98
|
slug: '${calendarSlug}',
|
|
100
99
|
},
|
|
101
100
|
}
|
|
102
|
-
)\n\nOh, and here's the original error: ${
|
|
101
|
+
)\n\nOh, and here's the original error: ${err.stack ?? err.message ?? err}`);
|
|
103
102
|
}
|
|
104
103
|
if (typeSlugs) {
|
|
105
104
|
test_utils_1.assert.isEqualDeep(cal.eventTypes, typeSlugs, `Your calendar does not have types set to: [${typeSlugs.join(', ')}]`);
|
|
@@ -139,12 +138,12 @@ try {
|
|
|
139
138
|
},
|
|
140
139
|
async createsEventTypesOnBoot(types, client, boot) {
|
|
141
140
|
assertRanBeforeEach(this);
|
|
142
|
-
await
|
|
141
|
+
await boot?.();
|
|
143
142
|
test_utils_1.assert.isTruthy(
|
|
144
143
|
//@ts-ignore
|
|
145
144
|
client.auth.skill, `You gotta be logged in as a skill! Try 'const { client } = await this.skills.loginAsCurrentSkill()'`);
|
|
146
|
-
const typeSlugs = types.map((t) =>
|
|
147
|
-
const vcIds = types.map((t) =>
|
|
145
|
+
const typeSlugs = types.map((t) => typeof t === 'string' ? t : t.typeSlug);
|
|
146
|
+
const vcIds = types.map((t) => typeof t === 'string' ? undefined : t.vcId);
|
|
148
147
|
function sort(a, b) {
|
|
149
148
|
return a.typeSlug > b.typeSlug ? 1 : -1;
|
|
150
149
|
}
|
|
@@ -287,14 +286,19 @@ await tools.fetchAndAddCards()
|
|
|
287
286
|
exports.default = calendarSkillAssert;
|
|
288
287
|
async function fakeEventTypeEvents(eventTypes) {
|
|
289
288
|
await spruce_test_fixtures_1.eventFaker.on('calendar.list-calendar-event-types::v2021_05_19', ({ source }) => {
|
|
290
|
-
const matches = eventTypes.filter((t) => t.source.skillId ===
|
|
289
|
+
const matches = eventTypes.filter((t) => t.source.skillId === source?.skillId);
|
|
291
290
|
return {
|
|
292
291
|
calendarEventTypes: matches,
|
|
293
292
|
count: matches.length,
|
|
294
293
|
};
|
|
295
294
|
});
|
|
296
295
|
await spruce_test_fixtures_1.eventFaker.on('calendar.create-calendar-event-type::v2021_05_19', ({ payload, source }) => {
|
|
297
|
-
const type =
|
|
296
|
+
const type = {
|
|
297
|
+
id: (0, test_utils_2.generateId)(),
|
|
298
|
+
source: source,
|
|
299
|
+
viewControllerId: null,
|
|
300
|
+
...payload,
|
|
301
|
+
};
|
|
298
302
|
eventTypes.push(type);
|
|
299
303
|
return {
|
|
300
304
|
calendarEventType: type,
|
|
@@ -308,7 +312,13 @@ async function fakeEventTypeEvents(eventTypes) {
|
|
|
308
312
|
calendarEventType: match,
|
|
309
313
|
};
|
|
310
314
|
}
|
|
311
|
-
const type =
|
|
315
|
+
const type = {
|
|
316
|
+
id: (0, test_utils_2.generateId)(),
|
|
317
|
+
source: source,
|
|
318
|
+
viewControllerId: null,
|
|
319
|
+
slug: target.slug,
|
|
320
|
+
...payload,
|
|
321
|
+
};
|
|
312
322
|
eventTypes.push(type);
|
|
313
323
|
return {
|
|
314
324
|
calendarEventType: type,
|
|
@@ -319,7 +329,12 @@ async function fakeCalendarEvents(calendars) {
|
|
|
319
329
|
await spruce_test_fixtures_1.eventFaker.on('calendar.create-calendar::v2021_05_19', ({ payload, source, target }) => {
|
|
320
330
|
const matches = calendars.filter((c) => c.slug === payload.slug);
|
|
321
331
|
test_utils_1.assert.isLength(matches, 0, `You already created a calendar the slug: ${payload.slug}!`);
|
|
322
|
-
const calendar =
|
|
332
|
+
const calendar = {
|
|
333
|
+
id: (0, test_utils_2.generateId)(),
|
|
334
|
+
source: source,
|
|
335
|
+
target,
|
|
336
|
+
...payload,
|
|
337
|
+
};
|
|
323
338
|
calendars.push(calendar);
|
|
324
339
|
return { calendar };
|
|
325
340
|
});
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
4
4
|
const calendarToolBeltInteractor = {
|
|
5
5
|
async makeRandomUpdatesToEvent(sm) {
|
|
6
|
-
await this.updateEvent(sm,
|
|
6
|
+
await this.updateEvent(sm, {
|
|
7
|
+
...heartwood_view_controllers_1.calendarSeeder.generateEventValues(),
|
|
8
|
+
});
|
|
7
9
|
return sm.getContext();
|
|
8
10
|
},
|
|
9
11
|
async updateEvent(sm, event) {
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -20,15 +9,29 @@ const schema_1 = require("@sprucelabs/schema");
|
|
|
20
9
|
const draftGenerator_1 = __importDefault(require("../utilities/draftGenerator"));
|
|
21
10
|
const CalendarPersister_1 = __importDefault(require("./CalendarPersister"));
|
|
22
11
|
class CalendarViewController extends heartwood_view_controllers_1.CalendarViewController {
|
|
12
|
+
static id = 'calendar';
|
|
13
|
+
draftAddedHandler;
|
|
14
|
+
sorter;
|
|
15
|
+
dropEventHandler;
|
|
16
|
+
isSwapping;
|
|
17
|
+
persister;
|
|
18
|
+
draftRemovedHandler;
|
|
19
|
+
eventSwappedHandler;
|
|
23
20
|
constructor(options) {
|
|
24
|
-
const { remoteEventStore, onDropEvent
|
|
25
|
-
super(
|
|
21
|
+
const { remoteEventStore, onDropEvent, ...rest } = options;
|
|
22
|
+
super({
|
|
23
|
+
view: 'day',
|
|
24
|
+
...rest,
|
|
25
|
+
onDropEvent: (options) => {
|
|
26
26
|
return this.handleDropEvent(options);
|
|
27
|
-
},
|
|
27
|
+
},
|
|
28
|
+
onLongPressViewDrop: (options) => {
|
|
28
29
|
return this.handleLongPressViewDrop(options);
|
|
29
|
-
},
|
|
30
|
+
},
|
|
31
|
+
onTapView: () => {
|
|
30
32
|
return this.handleTapView();
|
|
31
|
-
}
|
|
33
|
+
},
|
|
34
|
+
});
|
|
32
35
|
this.isSwapping = false;
|
|
33
36
|
const { onAddDraftEvent, onRemoveDraftEvent, onEventSwapped } = (0, schema_1.assertOptions)(options, ['onAddDraftEvent']);
|
|
34
37
|
this.sorter = new calendar_utils_1.PeopleSorter();
|
|
@@ -64,14 +67,16 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
64
67
|
await this.addDraftEventFromClick(options);
|
|
65
68
|
}
|
|
66
69
|
async handleDropEvent(options) {
|
|
67
|
-
var _a;
|
|
68
70
|
const { event, blockUpdates, newPersonId, newStartDateTimeMs } = options;
|
|
69
71
|
const updates = {};
|
|
70
72
|
if (newStartDateTimeMs) {
|
|
71
73
|
updates.startDateTimeMs = newStartDateTimeMs;
|
|
72
74
|
}
|
|
73
75
|
if (newPersonId) {
|
|
74
|
-
updates.target =
|
|
76
|
+
updates.target = {
|
|
77
|
+
...event.target,
|
|
78
|
+
personId: newPersonId,
|
|
79
|
+
};
|
|
75
80
|
}
|
|
76
81
|
if (blockUpdates) {
|
|
77
82
|
updates.timeBlocks = [...event.timeBlocks];
|
|
@@ -80,7 +85,7 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
80
85
|
update.durationSec / 60;
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
|
-
const results = await
|
|
88
|
+
const results = await this.dropEventHandler?.(event.id, { ...updates });
|
|
84
89
|
return results !== false;
|
|
85
90
|
}
|
|
86
91
|
getCalendarVc() {
|
|
@@ -94,8 +99,7 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
94
99
|
});
|
|
95
100
|
}
|
|
96
101
|
getRemoteStore() {
|
|
97
|
-
|
|
98
|
-
return (_a = this.persister) === null || _a === void 0 ? void 0 : _a.getRemoteStore();
|
|
102
|
+
return this.persister?.getRemoteStore();
|
|
99
103
|
}
|
|
100
104
|
async handleClickView(options) {
|
|
101
105
|
const selected = this.getSelectedEvent();
|
|
@@ -123,20 +127,20 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
123
127
|
return draft;
|
|
124
128
|
}
|
|
125
129
|
async removeDraftEvent(id) {
|
|
126
|
-
var _a, _b, _c;
|
|
127
130
|
await this.removeEvent(id);
|
|
128
|
-
await
|
|
131
|
+
await this.draftRemovedHandler?.();
|
|
129
132
|
try {
|
|
130
|
-
await
|
|
131
|
-
// eslint-disable-next-line no-empty
|
|
133
|
+
await this.persister?.cancelEvent(id);
|
|
132
134
|
}
|
|
133
135
|
catch (err) {
|
|
134
|
-
console.error(
|
|
136
|
+
console.error(err.stack ?? err.message);
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
async addDraftEventFromClick(options) {
|
|
138
140
|
const { personId, dateTimeMs } = options;
|
|
139
|
-
const event =
|
|
141
|
+
const event = {
|
|
142
|
+
...draftGenerator_1.default.generate(dateTimeMs ?? 0, personId ?? '**missing**'),
|
|
143
|
+
};
|
|
140
144
|
//@ts-ignore
|
|
141
145
|
delete event.id;
|
|
142
146
|
return await this.addDraftEvent(event);
|
|
@@ -152,12 +156,15 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
152
156
|
parameters: ['id'],
|
|
153
157
|
});
|
|
154
158
|
}
|
|
155
|
-
const event =
|
|
159
|
+
const event = {
|
|
160
|
+
...e,
|
|
161
|
+
id: draftGenerator_1.default.generateId(),
|
|
162
|
+
};
|
|
156
163
|
this.addEvent(event);
|
|
157
164
|
const draftAddedPromise = this.draftAddedHandler(event);
|
|
158
165
|
const saved = await this.persist(event);
|
|
159
166
|
await draftAddedPromise;
|
|
160
|
-
return saved
|
|
167
|
+
return saved ?? event;
|
|
161
168
|
}
|
|
162
169
|
getIsSwappingEvent() {
|
|
163
170
|
return this.isSwapping;
|
|
@@ -181,37 +188,39 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
181
188
|
await this.selectEvent(to.id);
|
|
182
189
|
}
|
|
183
190
|
});
|
|
184
|
-
// eslint-disable-next-line no-empty
|
|
185
191
|
}
|
|
186
|
-
catch
|
|
192
|
+
catch { }
|
|
187
193
|
this.isSwapping = false;
|
|
188
194
|
}
|
|
189
195
|
updateEvent(id, updates) {
|
|
190
|
-
const { shouldPersist = true
|
|
196
|
+
const { shouldPersist = true, ...rest } = updates;
|
|
191
197
|
try {
|
|
192
|
-
const updated = super.updateEvent(id,
|
|
198
|
+
const updated = super.updateEvent(id, {
|
|
199
|
+
...rest,
|
|
200
|
+
isBusy: shouldPersist,
|
|
201
|
+
});
|
|
193
202
|
if (shouldPersist) {
|
|
194
203
|
void this.persist(updated);
|
|
195
204
|
}
|
|
196
205
|
return updated;
|
|
197
|
-
// eslint-disable-next-line no-empty
|
|
198
206
|
}
|
|
199
|
-
catch
|
|
200
|
-
return
|
|
207
|
+
catch { }
|
|
208
|
+
return { ...updates };
|
|
201
209
|
}
|
|
202
210
|
async persist(event) {
|
|
203
|
-
|
|
204
|
-
return (_a = this.persister) === null || _a === void 0 ? void 0 : _a.persist(event);
|
|
211
|
+
return this.persister?.persist(event);
|
|
205
212
|
}
|
|
206
213
|
async waitForPendingSaves() {
|
|
207
|
-
|
|
208
|
-
await ((_a = this.persister) === null || _a === void 0 ? void 0 : _a.waitForPendingSaves());
|
|
214
|
+
await this.persister?.waitForPendingSaves();
|
|
209
215
|
}
|
|
210
216
|
render() {
|
|
211
|
-
var _a, _b;
|
|
212
217
|
const model = super.render();
|
|
213
|
-
return
|
|
218
|
+
return {
|
|
219
|
+
...model,
|
|
220
|
+
onLongPressEvent: () => this.getDevice().vibrate(),
|
|
221
|
+
onLongPressView: () => this.getDevice().vibrate(),
|
|
222
|
+
shouldEnableSwipeNav: (model.people?.length ?? 0) === 1,
|
|
223
|
+
};
|
|
214
224
|
}
|
|
215
225
|
}
|
|
216
|
-
CalendarViewController.id = 'calendar';
|
|
217
226
|
exports.default = CalendarViewController;
|