@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;
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
17
18
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
18
19
|
const schema_1 = require("@sprucelabs/schema");
|
|
19
20
|
const draftGenerator_1 = __importDefault(require("../utilities/draftGenerator"));
|
|
20
|
-
const StubPeopleSorter_1 = __importDefault(require("./StubPeopleSorter"));
|
|
21
21
|
class CalendarViewController extends heartwood_view_controllers_1.CalendarViewController {
|
|
22
22
|
constructor(options) {
|
|
23
23
|
const { remoteEventStore, onDropEvent } = options, rest = __rest(options, ["remoteEventStore", "onDropEvent"]);
|
|
@@ -31,7 +31,7 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
31
31
|
this.activelyPersisting = {};
|
|
32
32
|
this.isSwapping = false;
|
|
33
33
|
const { onAddDraftEvent, onRemoveDraftEvent, onEventSwapped } = (0, schema_1.assertOptions)(options, ['onAddDraftEvent']);
|
|
34
|
-
this.sorter = new
|
|
34
|
+
this.sorter = new calendar_utils_1.PeopleSorter();
|
|
35
35
|
this.draftAddedHandler = onAddDraftEvent;
|
|
36
36
|
this.draftRemovedHandler = onRemoveDraftEvent;
|
|
37
37
|
this.eventSwappedHandler = onEventSwapped;
|
|
@@ -40,6 +40,11 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
40
40
|
this.model.onClickView = this.handleClickView.bind(this);
|
|
41
41
|
this.setDefaultControllerForEvents('calendar.universal-calendar-event');
|
|
42
42
|
}
|
|
43
|
+
setPeople(people) {
|
|
44
|
+
this.sorter.setPeople(people);
|
|
45
|
+
const sorted = this.sorter.sort();
|
|
46
|
+
return super.setPeople(sorted);
|
|
47
|
+
}
|
|
43
48
|
async handleTapView() {
|
|
44
49
|
await this.renderOnce(async () => {
|
|
45
50
|
await this.deselectEvent();
|
|
@@ -194,27 +199,6 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
194
199
|
async waitForPendingSaves() {
|
|
195
200
|
await this.persistPromise;
|
|
196
201
|
}
|
|
197
|
-
getPeople() {
|
|
198
|
-
const people = super.getPeople();
|
|
199
|
-
this.sorter.setPeople(people !== null && people !== void 0 ? people : []);
|
|
200
|
-
this.sorter.setEvents(this.getEvents().map((e) => {
|
|
201
|
-
var _a;
|
|
202
|
-
return ({
|
|
203
|
-
id: e.id,
|
|
204
|
-
groupId: (_a = e.groupId) !== null && _a !== void 0 ? _a : undefined,
|
|
205
|
-
personId: e.target.personId,
|
|
206
|
-
startDateTimeMs: e.startDateTimeMs,
|
|
207
|
-
});
|
|
208
|
-
}));
|
|
209
|
-
const selectedEvent = this.getSelectedEvent();
|
|
210
|
-
if (selectedEvent && !draftGenerator_1.default.isDraftId(selectedEvent.id)) {
|
|
211
|
-
this.sorter.setSelectedEvents([selectedEvent.id]);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
this.sorter.setSelectedEvents([]);
|
|
215
|
-
}
|
|
216
|
-
return this.sorter.sort();
|
|
217
|
-
}
|
|
218
202
|
async _persist(event) {
|
|
219
203
|
var _a, _b;
|
|
220
204
|
let updated = event;
|
|
@@ -256,7 +240,7 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
256
240
|
return event;
|
|
257
241
|
}
|
|
258
242
|
render() {
|
|
259
|
-
return Object.assign(
|
|
243
|
+
return Object.assign({}, super.render());
|
|
260
244
|
}
|
|
261
245
|
}
|
|
262
246
|
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 {
|
|
@@ -195,17 +195,21 @@ class CalendarEventManager {
|
|
|
195
195
|
endDate,
|
|
196
196
|
peopleIds,
|
|
197
197
|
});
|
|
198
|
-
this.
|
|
199
|
-
|
|
200
|
-
this.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var _a;
|
|
204
|
-
const type = (_a = this.eventTypes) === null || _a === void 0 ? void 0 : _a.find((t) => t.slug === e.eventTypeSlug);
|
|
205
|
-
if (type === null || type === void 0 ? void 0 : type.viewControllerId) {
|
|
206
|
-
await this.setupVcForEventType(type.viewControllerId, type.slug);
|
|
198
|
+
await this.calendarVc.renderOnce(async () => {
|
|
199
|
+
console.log('CalendarEventManager.loadEvents triggerRender start');
|
|
200
|
+
this.replaceEventsInRange(events, startDate, endDate);
|
|
201
|
+
if (!this.eventTypes) {
|
|
202
|
+
this.eventTypes = await this.events.getEventTypes();
|
|
207
203
|
}
|
|
208
|
-
|
|
204
|
+
await Promise.all(events.map(async (e) => {
|
|
205
|
+
var _a;
|
|
206
|
+
const type = (_a = this.eventTypes) === null || _a === void 0 ? void 0 : _a.find((t) => t.slug === e.eventTypeSlug);
|
|
207
|
+
if (type === null || type === void 0 ? void 0 : type.viewControllerId) {
|
|
208
|
+
await this.setupVcForEventType(type.viewControllerId, type.slug);
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
console.log('CalendarEventManager.loadEvents triggerRender end');
|
|
212
|
+
});
|
|
209
213
|
}
|
|
210
214
|
async setCalendarVisibility(calendarId, shouldBeVisible) {
|
|
211
215
|
if (shouldBeVisible) {
|
|
@@ -222,6 +226,7 @@ class CalendarEventManager {
|
|
|
222
226
|
}
|
|
223
227
|
this.hasVcForEventTypeBeenLoaded[key] = true;
|
|
224
228
|
await this.remoteVc.fetchRemoteController(vcId);
|
|
229
|
+
console.log('set controller for type');
|
|
225
230
|
this.calendarVc.setControllerForEventType(typeSlug, vcId);
|
|
226
231
|
}
|
|
227
232
|
assertValidCalendarId(calendarId) {
|
|
@@ -302,6 +307,7 @@ class CalendarEventManager {
|
|
|
302
307
|
await this.calendarVc.deselectEvent();
|
|
303
308
|
}
|
|
304
309
|
async setCurrentDate(dateMs) {
|
|
310
|
+
console.log('CalendarEventManager.setStartDate');
|
|
305
311
|
await this.calendarVc.setStartDate(dateMs);
|
|
306
312
|
}
|
|
307
313
|
async handleDidUpdateContext() {
|