@sprucelabs/spruce-calendar-components 25.1.4 → 25.2.2
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/schemas/schemas.types.d.ts +1619 -1619
- package/build/calendar/Calendar.vc.d.ts +3 -3
- package/build/calendar/Calendar.vc.js +8 -24
- package/build/calendar/CalendarEventManager.d.ts +1 -1
- package/build/calendar/CalendarEventManager.js +16 -10
- package/build/esm/.spruce/schemas/schemas.types.d.ts +1619 -1619
- package/build/esm/calendar/Calendar.vc.d.ts +3 -3
- package/build/esm/calendar/Calendar.vc.js +8 -24
- package/build/esm/calendar/CalendarEventManager.d.ts +1 -1
- package/build/esm/calendar/CalendarEventManager.js +16 -10
- package/build/esm/skillViewControllers/Root.svc.js +7 -5
- package/build/skillViewControllers/Root.svc.js +7 -5
- package/package.json +1 -5
- package/build/calendar/StubPeopleSorter.d.ts +0 -4
- package/build/calendar/StubPeopleSorter.js +0 -9
- package/build/esm/calendar/StubPeopleSorter.d.ts +0 -4
- package/build/esm/calendar/StubPeopleSorter.js +0 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpruceSchemas, ViewControllerOptions, CalendarViewController as CoreCalendarViewController, ClickCalendarViewOptions, DropEventOptions, ClickEventOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { RemoteEventStore } from '../stores/RemoteEventStore';
|
|
3
|
-
import { UpdateEvent } from '../types/calendar.types';
|
|
3
|
+
import { CalendarPerson, UpdateEvent } from '../types/calendar.types';
|
|
4
4
|
export default class CalendarViewController extends CoreCalendarViewController {
|
|
5
5
|
static id: string;
|
|
6
6
|
private remoteEventStore?;
|
|
@@ -14,6 +14,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
|
|
|
14
14
|
private activelyPersisting;
|
|
15
15
|
private persistPromise?;
|
|
16
16
|
constructor(options: ViewControllerOptions & CalendarViewControllerOptions);
|
|
17
|
+
setPeople(people: CalendarPerson[]): void;
|
|
17
18
|
private handleTapView;
|
|
18
19
|
protected handleLongPressViewDrop(options: ClickCalendarViewOptions): Promise<void>;
|
|
19
20
|
private handleDropEvent;
|
|
@@ -33,11 +34,10 @@ export default class CalendarViewController extends CoreCalendarViewController {
|
|
|
33
34
|
}): any;
|
|
34
35
|
private persist;
|
|
35
36
|
waitForPendingSaves(): Promise<void>;
|
|
36
|
-
getPeople(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarPerson[];
|
|
37
37
|
private _persist;
|
|
38
38
|
render(): {
|
|
39
|
-
people: SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarPerson[];
|
|
40
39
|
controller?: import("@sprucelabs/heartwood-view-controllers").ViewController<SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Calendar> | null | undefined;
|
|
40
|
+
people?: SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarPerson[] | null | undefined;
|
|
41
41
|
minTime?: SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarTime | null | undefined;
|
|
42
42
|
maxTime?: SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarTime | null | undefined;
|
|
43
43
|
startDate?: number | null | undefined;
|
|
@@ -18,10 +18,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
+
import { PeopleSorter } from '@sprucelabs/calendar-utils';
|
|
21
22
|
import { CalendarViewController as CoreCalendarViewController, } from '@sprucelabs/heartwood-view-controllers';
|
|
22
23
|
import { assertOptions, SchemaError } from '@sprucelabs/schema';
|
|
23
24
|
import draftEventGenerator from '../utilities/draftGenerator.js';
|
|
24
|
-
import StubPeopleSorter from './StubPeopleSorter.js';
|
|
25
25
|
class CalendarViewController extends CoreCalendarViewController {
|
|
26
26
|
constructor(options) {
|
|
27
27
|
const { remoteEventStore, onDropEvent } = options, rest = __rest(options, ["remoteEventStore", "onDropEvent"]);
|
|
@@ -35,7 +35,7 @@ class CalendarViewController extends CoreCalendarViewController {
|
|
|
35
35
|
this.activelyPersisting = {};
|
|
36
36
|
this.isSwapping = false;
|
|
37
37
|
const { onAddDraftEvent, onRemoveDraftEvent, onEventSwapped } = assertOptions(options, ['onAddDraftEvent']);
|
|
38
|
-
this.sorter = new
|
|
38
|
+
this.sorter = new PeopleSorter();
|
|
39
39
|
this.draftAddedHandler = onAddDraftEvent;
|
|
40
40
|
this.draftRemovedHandler = onRemoveDraftEvent;
|
|
41
41
|
this.eventSwappedHandler = onEventSwapped;
|
|
@@ -44,6 +44,11 @@ class CalendarViewController extends CoreCalendarViewController {
|
|
|
44
44
|
this.model.onClickView = this.handleClickView.bind(this);
|
|
45
45
|
this.setDefaultControllerForEvents('calendar.universal-calendar-event');
|
|
46
46
|
}
|
|
47
|
+
setPeople(people) {
|
|
48
|
+
this.sorter.setPeople(people);
|
|
49
|
+
const sorted = this.sorter.sort();
|
|
50
|
+
return super.setPeople(sorted);
|
|
51
|
+
}
|
|
47
52
|
handleTapView() {
|
|
48
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
54
|
yield this.renderOnce(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -221,27 +226,6 @@ class CalendarViewController extends CoreCalendarViewController {
|
|
|
221
226
|
yield this.persistPromise;
|
|
222
227
|
});
|
|
223
228
|
}
|
|
224
|
-
getPeople() {
|
|
225
|
-
const people = super.getPeople();
|
|
226
|
-
this.sorter.setPeople(people !== null && people !== void 0 ? people : []);
|
|
227
|
-
this.sorter.setEvents(this.getEvents().map((e) => {
|
|
228
|
-
var _a;
|
|
229
|
-
return ({
|
|
230
|
-
id: e.id,
|
|
231
|
-
groupId: (_a = e.groupId) !== null && _a !== void 0 ? _a : undefined,
|
|
232
|
-
personId: e.target.personId,
|
|
233
|
-
startDateTimeMs: e.startDateTimeMs,
|
|
234
|
-
});
|
|
235
|
-
}));
|
|
236
|
-
const selectedEvent = this.getSelectedEvent();
|
|
237
|
-
if (selectedEvent && !draftEventGenerator.isDraftId(selectedEvent.id)) {
|
|
238
|
-
this.sorter.setSelectedEvents([selectedEvent.id]);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
this.sorter.setSelectedEvents([]);
|
|
242
|
-
}
|
|
243
|
-
return this.sorter.sort();
|
|
244
|
-
}
|
|
245
229
|
_persist(event) {
|
|
246
230
|
const _super = Object.create(null, {
|
|
247
231
|
updateEvent: { get: () => super.updateEvent }
|
|
@@ -288,7 +272,7 @@ class CalendarViewController extends CoreCalendarViewController {
|
|
|
288
272
|
});
|
|
289
273
|
}
|
|
290
274
|
render() {
|
|
291
|
-
return Object.assign(
|
|
275
|
+
return Object.assign({}, super.render());
|
|
292
276
|
}
|
|
293
277
|
}
|
|
294
278
|
CalendarViewController.id = 'calendar';
|
|
@@ -101,7 +101,7 @@ export default class CalendarEventManager {
|
|
|
101
101
|
hasEvent(id: string): boolean;
|
|
102
102
|
optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent, action?: RepeatingUpdateAction): Promise<boolean>;
|
|
103
103
|
}
|
|
104
|
-
export type EventManagerCalendarVc = Pick<CalendarViewController, 'replaceEventsInRange' | 'mixinEvents' | 'removeEvent' | 'addEvent' | 'hasEvent' | 'updateEvent' | 'setShifts' | 'getShifts' | 'getEvent' | 'getPeople' | 'setControllerForEventType' | 'setRemoteStore' | 'getSelectedEvent' | 'selectEvent' | 'deselectEvent' | 'removeEvents' | 'setStartDate'>;
|
|
104
|
+
export type EventManagerCalendarVc = Pick<CalendarViewController, 'replaceEventsInRange' | 'mixinEvents' | 'removeEvent' | 'addEvent' | 'hasEvent' | 'updateEvent' | 'setShifts' | 'getShifts' | 'getEvent' | 'getPeople' | 'setControllerForEventType' | 'setRemoteStore' | 'getSelectedEvent' | 'selectEvent' | 'deselectEvent' | 'removeEvents' | 'setStartDate' | 'renderOnce'>;
|
|
105
105
|
type EventManagerRemoteViewControllerFactory = Pick<RemoteViewControllerFactory, 'fetchRemoteController'>;
|
|
106
106
|
export type RepeatingUpdateAction = 'update' | 'cancel';
|
|
107
107
|
export interface CalendarEventManagerOptions {
|
|
@@ -216,17 +216,21 @@ export default class CalendarEventManager {
|
|
|
216
216
|
endDate,
|
|
217
217
|
peopleIds,
|
|
218
218
|
});
|
|
219
|
-
this.
|
|
220
|
-
|
|
221
|
-
this.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
var _a;
|
|
225
|
-
const type = (_a = this.eventTypes) === null || _a === void 0 ? void 0 : _a.find((t) => t.slug === e.eventTypeSlug);
|
|
226
|
-
if (type === null || type === void 0 ? void 0 : type.viewControllerId) {
|
|
227
|
-
yield this.setupVcForEventType(type.viewControllerId, type.slug);
|
|
219
|
+
yield this.calendarVc.renderOnce(() => __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
console.log('CalendarEventManager.loadEvents triggerRender start');
|
|
221
|
+
this.replaceEventsInRange(events, startDate, endDate);
|
|
222
|
+
if (!this.eventTypes) {
|
|
223
|
+
this.eventTypes = yield this.events.getEventTypes();
|
|
228
224
|
}
|
|
229
|
-
|
|
225
|
+
yield Promise.all(events.map((e) => __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
var _a;
|
|
227
|
+
const type = (_a = this.eventTypes) === null || _a === void 0 ? void 0 : _a.find((t) => t.slug === e.eventTypeSlug);
|
|
228
|
+
if (type === null || type === void 0 ? void 0 : type.viewControllerId) {
|
|
229
|
+
yield this.setupVcForEventType(type.viewControllerId, type.slug);
|
|
230
|
+
}
|
|
231
|
+
})));
|
|
232
|
+
console.log('CalendarEventManager.loadEvents triggerRender end');
|
|
233
|
+
}));
|
|
230
234
|
});
|
|
231
235
|
}
|
|
232
236
|
setCalendarVisibility(calendarId, shouldBeVisible) {
|
|
@@ -247,6 +251,7 @@ export default class CalendarEventManager {
|
|
|
247
251
|
}
|
|
248
252
|
this.hasVcForEventTypeBeenLoaded[key] = true;
|
|
249
253
|
yield this.remoteVc.fetchRemoteController(vcId);
|
|
254
|
+
console.log('set controller for type');
|
|
250
255
|
this.calendarVc.setControllerForEventType(typeSlug, vcId);
|
|
251
256
|
});
|
|
252
257
|
}
|
|
@@ -343,6 +348,7 @@ export default class CalendarEventManager {
|
|
|
343
348
|
}
|
|
344
349
|
setCurrentDate(dateMs) {
|
|
345
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
+
console.log('CalendarEventManager.setStartDate');
|
|
346
352
|
yield this.calendarVc.setStartDate(dateMs);
|
|
347
353
|
});
|
|
348
354
|
}
|
|
@@ -356,15 +356,16 @@ class RootSkillViewController extends AbstractSkillViewController {
|
|
|
356
356
|
return;
|
|
357
357
|
}
|
|
358
358
|
const { startDate = this.dates.getStartOfDay(), visiblePeopleIds } = args;
|
|
359
|
+
console.log('render once');
|
|
359
360
|
yield this.calendarVc.renderOnce(() => __awaiter(this, void 0, void 0, function* () {
|
|
360
361
|
this.syncOffsetWithLocale(locale);
|
|
361
362
|
yield this.events.setCurrentDate(startDate);
|
|
363
|
+
yield this.transitionToRoot();
|
|
364
|
+
if (visiblePeopleIds) {
|
|
365
|
+
yield this.people.setVisibilityMode('custom');
|
|
366
|
+
yield this.people.setVisiblePeopleIds(visiblePeopleIds);
|
|
367
|
+
}
|
|
362
368
|
}));
|
|
363
|
-
yield this.transitionToRoot();
|
|
364
|
-
if (visiblePeopleIds) {
|
|
365
|
-
yield this.people.setVisibilityMode('custom');
|
|
366
|
-
yield this.people.setVisiblePeopleIds(visiblePeopleIds);
|
|
367
|
-
}
|
|
368
369
|
if (RootSkillViewController.shouldUpdateOnInterval) {
|
|
369
370
|
this.loadEventInterval = setInterval(() => {
|
|
370
371
|
return this.loadEvents({
|
|
@@ -463,6 +464,7 @@ class RootSkillViewController extends AbstractSkillViewController {
|
|
|
463
464
|
}
|
|
464
465
|
loadEvents(options) {
|
|
465
466
|
return __awaiter(this, void 0, void 0, function* () {
|
|
467
|
+
console.log('load events');
|
|
466
468
|
this.loadEventsPromise = this._loadEvents(options);
|
|
467
469
|
yield this.loadEventsPromise;
|
|
468
470
|
});
|
|
@@ -315,15 +315,16 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
|
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
const { startDate = this.dates.getStartOfDay(), visiblePeopleIds } = args;
|
|
318
|
+
console.log('render once');
|
|
318
319
|
await this.calendarVc.renderOnce(async () => {
|
|
319
320
|
this.syncOffsetWithLocale(locale);
|
|
320
321
|
await this.events.setCurrentDate(startDate);
|
|
322
|
+
await this.transitionToRoot();
|
|
323
|
+
if (visiblePeopleIds) {
|
|
324
|
+
await this.people.setVisibilityMode('custom');
|
|
325
|
+
await this.people.setVisiblePeopleIds(visiblePeopleIds);
|
|
326
|
+
}
|
|
321
327
|
});
|
|
322
|
-
await this.transitionToRoot();
|
|
323
|
-
if (visiblePeopleIds) {
|
|
324
|
-
await this.people.setVisibilityMode('custom');
|
|
325
|
-
await this.people.setVisiblePeopleIds(visiblePeopleIds);
|
|
326
|
-
}
|
|
327
328
|
if (RootSkillViewController.shouldUpdateOnInterval) {
|
|
328
329
|
this.loadEventInterval = setInterval(() => {
|
|
329
330
|
return this.loadEvents({
|
|
@@ -404,6 +405,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
|
|
|
404
405
|
this.calendarVc.setTimezoneOffsetMs(offset * 60 * 1000);
|
|
405
406
|
}
|
|
406
407
|
async loadEvents(options) {
|
|
408
|
+
console.log('load events');
|
|
407
409
|
this.loadEventsPromise = this._loadEvents(options);
|
|
408
410
|
await this.loadEventsPromise;
|
|
409
411
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprucelabs/spruce-calendar-components",
|
|
3
3
|
"description": "Calendar components for working with calendars and Sprucebot.",
|
|
4
|
-
"version": "25.
|
|
4
|
+
"version": "25.2.2",
|
|
5
5
|
"skill": {
|
|
6
6
|
"namespace": "calendar"
|
|
7
7
|
},
|
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
"build/__tests__/support/CalendarToolBeltStateMachineTestFactory.d.ts",
|
|
19
19
|
"build/esm/__tests__/support/CalendarToolBeltStateMachineTestFactory.js",
|
|
20
20
|
"build/esm/__tests__/support/CalendarToolBeltStateMachineTestFactory.d.ts",
|
|
21
|
-
"build/calendar/StubPeopleSorter.js",
|
|
22
|
-
"build/calendar/StubPeopleSorter.d.ts",
|
|
23
|
-
"build/esm/calendar/StubPeopleSorter.js",
|
|
24
|
-
"build/esm/calendar/StubPeopleSorter.d.ts",
|
|
25
21
|
"build/__tests__/support/SpyEventManager.js",
|
|
26
22
|
"build/__tests__/support/SpyEventManager.d.ts",
|
|
27
23
|
"build/esm/__tests__/support/SpyEventManager.js",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
4
|
-
class StubPeopleSorter extends calendar_utils_1.PeopleSorter {
|
|
5
|
-
sort() {
|
|
6
|
-
return this.getPeople();
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.default = StubPeopleSorter;
|