@sprucelabs/spruce-calendar-components 21.1.1 → 22.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/esm/skillViewControllers/Root.svc.js +2 -2
- package/build/esm/stores/RemoteEventStore.d.ts +26 -10
- package/build/esm/stores/RemoteEventStore.js +3 -3
- package/build/esm/types/calendar.types.d.ts +1 -0
- package/build/esm/utilities/CalendarEventManager.d.ts +3 -1
- package/build/esm/utilities/CalendarEventManager.js +7 -2
- package/build/esm/viewControllers/Calendar.vc.d.ts +1 -1
- package/build/stores/RemoteEventStore.d.ts +26 -10
- package/build/stores/RemoteEventStore.js +4 -4
- package/build/types/calendar.types.d.ts +1 -0
- package/build/utilities/CalendarEventManager.d.ts +3 -1
- package/build/utilities/CalendarEventManager.js +7 -2
- package/build/viewControllers/Calendar.vc.d.ts +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { AbstractSkillViewController, ToolBeltStateMachine, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
11
|
import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
|
|
12
|
-
import
|
|
12
|
+
import RemoteEventStoreImpl from '../stores/RemoteEventStore.js';
|
|
13
13
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore.js';
|
|
14
14
|
import { PrerequisitesToolBeltState } from '../toolBelt/states/PrerequisitesToolBeltState.js';
|
|
15
15
|
import { RootToolBeltState } from '../toolBelt/states/RootToolBeltState.js';
|
|
@@ -26,7 +26,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
26
26
|
connectToApi: this.connectToApi.bind(this),
|
|
27
27
|
vcFactory: this.getVcFactory(),
|
|
28
28
|
});
|
|
29
|
-
this.remoteEventStore = new
|
|
29
|
+
this.remoteEventStore = new RemoteEventStoreImpl({
|
|
30
30
|
connectToApi: this.connectToApi.bind(this),
|
|
31
31
|
});
|
|
32
32
|
this.preferences = new RemotePreferencesStore({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
3
|
-
import { UpdateEvent } from '../types/calendar.types';
|
|
4
|
-
export default class RemoteEventStore {
|
|
3
|
+
import { Calendar, CalendarEvent, CalendarEventType, UpdateEvent } from '../types/calendar.types';
|
|
4
|
+
export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
5
5
|
private connectToApi;
|
|
6
6
|
protected calendarId?: string;
|
|
7
7
|
protected locationId: string;
|
|
@@ -33,18 +33,34 @@ export default class RemoteEventStore {
|
|
|
33
33
|
getCalendarId(): string | undefined;
|
|
34
34
|
waitForPendingSaves(): Promise<void>;
|
|
35
35
|
cancelEvent(id: string): Promise<void>;
|
|
36
|
-
getSchedules(options:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
startDate: number;
|
|
40
|
-
endDate: number;
|
|
41
|
-
}): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
|
|
42
|
-
loadEventTypes(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false>>[]>;
|
|
43
|
-
loadCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
|
|
36
|
+
getSchedules(options: GetScheduleOptions): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
|
|
37
|
+
getEventTypes(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false>>[]>;
|
|
38
|
+
getCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
|
|
44
39
|
}
|
|
45
40
|
export interface RemoteEventStoreOptions {
|
|
46
41
|
connectToApi: () => Promise<MercuryClient>;
|
|
47
42
|
calendarId?: string;
|
|
48
43
|
}
|
|
49
44
|
declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
|
|
45
|
+
export interface RemoteEventStore {
|
|
46
|
+
load(options: {
|
|
47
|
+
organizationId: string;
|
|
48
|
+
locationId: string;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
persist(event: UpdateEvent): Promise<FullEvent>;
|
|
51
|
+
setCalendarId(id: string): void;
|
|
52
|
+
clearCalendarId(): void;
|
|
53
|
+
getCalendarId(): string | undefined;
|
|
54
|
+
waitForPendingSaves(): Promise<void>;
|
|
55
|
+
cancelEvent(id: string): Promise<void>;
|
|
56
|
+
getSchedules(options: GetScheduleOptions): Promise<CalendarEvent[]>;
|
|
57
|
+
getEventTypes(): Promise<CalendarEventType[]>;
|
|
58
|
+
getCalendars(): Promise<Calendar[]>;
|
|
59
|
+
}
|
|
60
|
+
export declare type GetScheduleOptions = {
|
|
61
|
+
calendarIds: string[];
|
|
62
|
+
peopleIds: string[];
|
|
63
|
+
startDate: number;
|
|
64
|
+
endDate: number;
|
|
65
|
+
};
|
|
50
66
|
export {};
|
|
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
import { calendarEventSchema } from '@sprucelabs/calendar-utils';
|
|
22
22
|
import { assertOptions, normalizeSchemaValues } from '@sprucelabs/schema';
|
|
23
23
|
import draftEventGenerator from '../utilities/draftGenerator.js';
|
|
24
|
-
export default class
|
|
24
|
+
export default class RemoteEventStoreImpl {
|
|
25
25
|
constructor(options) {
|
|
26
26
|
this.pendingEvents = {};
|
|
27
27
|
this.draftIdMap = {};
|
|
@@ -243,13 +243,13 @@ export default class RemoteEventStore {
|
|
|
243
243
|
return events;
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
|
|
246
|
+
getEventTypes() {
|
|
247
247
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
248
|
const [{ calendarEventTypes }] = yield this.client.emitAndFlattenResponses('calendar.list-calendar-event-types::v2021_05_19');
|
|
249
249
|
return calendarEventTypes;
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
getCalendars() {
|
|
253
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
254
254
|
const [{ calendars }] = yield this.client.emitAndFlattenResponses('calendar.list-calendars::v2021_05_19', {
|
|
255
255
|
target: {
|
|
@@ -17,6 +17,7 @@ export declare type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
|
17
17
|
export declare type CalendarPerson = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarPerson;
|
|
18
18
|
export declare type EventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
19
19
|
export declare type Calendar = SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
20
|
+
export declare type CalendarEventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
20
21
|
export declare type SimpleCalendar = Pick<Calendar, 'id' | 'availableTimeSlotBehavior'>;
|
|
21
22
|
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
22
23
|
declare type ICalendarToolBeltContext = SkillViewControllerLoadOptions & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateUtils } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { CalendarEvent } from '@sprucelabs/heartwood-view-controllers';
|
|
3
3
|
import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
|
|
4
|
-
import RemoteEventStore from '../stores/RemoteEventStore';
|
|
4
|
+
import { RemoteEventStore } from '../stores/RemoteEventStore';
|
|
5
5
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
6
6
|
import { CalendarToolBeltStateMachine, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
@@ -22,6 +22,7 @@ export declare class CalendarEventManager {
|
|
|
22
22
|
protected prefs: RemotePreferencesStore;
|
|
23
23
|
private calendars;
|
|
24
24
|
private shouldUpdateContextOnNextSave;
|
|
25
|
+
private isLoaded;
|
|
25
26
|
protected get calendarIds(): string[];
|
|
26
27
|
protected get visibleCalendarIds(): string[];
|
|
27
28
|
constructor(options: CalendarEventManagerOptions);
|
|
@@ -57,6 +58,7 @@ export declare class CalendarEventManager {
|
|
|
57
58
|
private handleWillUpdateContext;
|
|
58
59
|
private handleDidUpdateContext;
|
|
59
60
|
private saveEvent;
|
|
61
|
+
getIsLoaded(): boolean;
|
|
60
62
|
optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent): Promise<boolean>;
|
|
61
63
|
}
|
|
62
64
|
export declare type EventManagerCalendarVc = Pick<CalendarViewController, 'replaceEventsInRange' | 'mixinEvents' | 'removeEvent' | 'addEvent' | 'hasEvent' | 'updateEvent' | 'setShifts' | 'getShifts' | 'getEvent' | 'getPeople' | 'setControllerForEventType' | 'setRemoteStore' | 'getSelectedEvent' | 'selectEvent'>;
|
|
@@ -20,6 +20,7 @@ export class CalendarEventManager {
|
|
|
20
20
|
this.shouldIgnoreNextContextUpdate = false;
|
|
21
21
|
this.calendars = [];
|
|
22
22
|
this.shouldUpdateContextOnNextSave = true;
|
|
23
|
+
this.isLoaded = false;
|
|
23
24
|
const { calendarVc, events, remoteVc, sm, askForUpdateStrategy, dates, preferences, } = assertOptions(options, [
|
|
24
25
|
'calendarVc',
|
|
25
26
|
'events',
|
|
@@ -173,7 +174,7 @@ export class CalendarEventManager {
|
|
|
173
174
|
});
|
|
174
175
|
this.replaceEventsInRange(events, startDate, endDate);
|
|
175
176
|
if (!this.eventTypes) {
|
|
176
|
-
this.eventTypes = yield this.events.
|
|
177
|
+
this.eventTypes = yield this.events.getEventTypes();
|
|
177
178
|
}
|
|
178
179
|
yield Promise.all(events.map((e) => __awaiter(this, void 0, void 0, function* () {
|
|
179
180
|
var _a;
|
|
@@ -247,6 +248,7 @@ export class CalendarEventManager {
|
|
|
247
248
|
this.inclusiveCalendarIds = this.calendars
|
|
248
249
|
.filter((c) => c.availableTimeSlotBehavior === 'include')
|
|
249
250
|
.map((c) => c.id);
|
|
251
|
+
this.isLoaded = true;
|
|
250
252
|
});
|
|
251
253
|
}
|
|
252
254
|
getEvent(id) {
|
|
@@ -261,7 +263,7 @@ export class CalendarEventManager {
|
|
|
261
263
|
}
|
|
262
264
|
loadCalendars() {
|
|
263
265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
264
|
-
this.calendars = yield this.events.
|
|
266
|
+
this.calendars = yield this.events.getCalendars();
|
|
265
267
|
});
|
|
266
268
|
}
|
|
267
269
|
handleWillUpdateContext(options) {
|
|
@@ -303,6 +305,9 @@ export class CalendarEventManager {
|
|
|
303
305
|
}
|
|
304
306
|
});
|
|
305
307
|
}
|
|
308
|
+
getIsLoaded() {
|
|
309
|
+
return this.isLoaded;
|
|
310
|
+
}
|
|
306
311
|
optionallyAskForUpdateRepeatingStrategy(event) {
|
|
307
312
|
var _a;
|
|
308
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpruceSchemas, ViewControllerOptions, CalendarViewController as CoreCalendarViewController, ClickCalendarViewOptions, DropEventOptions, ClickEventOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
import RemoteEventStore from '../stores/RemoteEventStore';
|
|
2
|
+
import { RemoteEventStore } from '../stores/RemoteEventStore';
|
|
3
3
|
import { UpdateEvent } from '../types/calendar.types';
|
|
4
4
|
declare type Calendar = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Calendar;
|
|
5
5
|
declare type Event = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
3
|
-
import { UpdateEvent } from '../types/calendar.types';
|
|
4
|
-
export default class RemoteEventStore {
|
|
3
|
+
import { Calendar, CalendarEvent, CalendarEventType, UpdateEvent } from '../types/calendar.types';
|
|
4
|
+
export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
5
5
|
private connectToApi;
|
|
6
6
|
protected calendarId?: string;
|
|
7
7
|
protected locationId: string;
|
|
@@ -33,18 +33,34 @@ export default class RemoteEventStore {
|
|
|
33
33
|
getCalendarId(): string | undefined;
|
|
34
34
|
waitForPendingSaves(): Promise<void>;
|
|
35
35
|
cancelEvent(id: string): Promise<void>;
|
|
36
|
-
getSchedules(options:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
startDate: number;
|
|
40
|
-
endDate: number;
|
|
41
|
-
}): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
|
|
42
|
-
loadEventTypes(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false>>[]>;
|
|
43
|
-
loadCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
|
|
36
|
+
getSchedules(options: GetScheduleOptions): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
|
|
37
|
+
getEventTypes(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false>>[]>;
|
|
38
|
+
getCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
|
|
44
39
|
}
|
|
45
40
|
export interface RemoteEventStoreOptions {
|
|
46
41
|
connectToApi: () => Promise<MercuryClient>;
|
|
47
42
|
calendarId?: string;
|
|
48
43
|
}
|
|
49
44
|
declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
|
|
45
|
+
export interface RemoteEventStore {
|
|
46
|
+
load(options: {
|
|
47
|
+
organizationId: string;
|
|
48
|
+
locationId: string;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
persist(event: UpdateEvent): Promise<FullEvent>;
|
|
51
|
+
setCalendarId(id: string): void;
|
|
52
|
+
clearCalendarId(): void;
|
|
53
|
+
getCalendarId(): string | undefined;
|
|
54
|
+
waitForPendingSaves(): Promise<void>;
|
|
55
|
+
cancelEvent(id: string): Promise<void>;
|
|
56
|
+
getSchedules(options: GetScheduleOptions): Promise<CalendarEvent[]>;
|
|
57
|
+
getEventTypes(): Promise<CalendarEventType[]>;
|
|
58
|
+
getCalendars(): Promise<Calendar[]>;
|
|
59
|
+
}
|
|
60
|
+
export declare type GetScheduleOptions = {
|
|
61
|
+
calendarIds: string[];
|
|
62
|
+
peopleIds: string[];
|
|
63
|
+
startDate: number;
|
|
64
|
+
endDate: number;
|
|
65
|
+
};
|
|
50
66
|
export {};
|
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
18
18
|
const schema_1 = require("@sprucelabs/schema");
|
|
19
19
|
const draftGenerator_1 = __importDefault(require("../utilities/draftGenerator"));
|
|
20
|
-
class
|
|
20
|
+
class RemoteEventStoreImpl {
|
|
21
21
|
constructor(options) {
|
|
22
22
|
this.pendingEvents = {};
|
|
23
23
|
this.draftIdMap = {};
|
|
@@ -221,11 +221,11 @@ class RemoteEventStore {
|
|
|
221
221
|
});
|
|
222
222
|
return events;
|
|
223
223
|
}
|
|
224
|
-
async
|
|
224
|
+
async getEventTypes() {
|
|
225
225
|
const [{ calendarEventTypes }] = await this.client.emitAndFlattenResponses('calendar.list-calendar-event-types::v2021_05_19');
|
|
226
226
|
return calendarEventTypes;
|
|
227
227
|
}
|
|
228
|
-
async
|
|
228
|
+
async getCalendars() {
|
|
229
229
|
const [{ calendars }] = await this.client.emitAndFlattenResponses('calendar.list-calendars::v2021_05_19', {
|
|
230
230
|
target: {
|
|
231
231
|
organizationId: this.organizationId,
|
|
@@ -234,7 +234,7 @@ class RemoteEventStore {
|
|
|
234
234
|
return calendars;
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
exports.default =
|
|
237
|
+
exports.default = RemoteEventStoreImpl;
|
|
238
238
|
const equals = (a, b) => {
|
|
239
239
|
if (a === b) {
|
|
240
240
|
return true;
|
|
@@ -17,6 +17,7 @@ export declare type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
|
17
17
|
export declare type CalendarPerson = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarPerson;
|
|
18
18
|
export declare type EventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
19
19
|
export declare type Calendar = SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
20
|
+
export declare type CalendarEventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
20
21
|
export declare type SimpleCalendar = Pick<Calendar, 'id' | 'availableTimeSlotBehavior'>;
|
|
21
22
|
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
22
23
|
declare type ICalendarToolBeltContext = SkillViewControllerLoadOptions & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateUtils } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { CalendarEvent } from '@sprucelabs/heartwood-view-controllers';
|
|
3
3
|
import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
|
|
4
|
-
import RemoteEventStore from '../stores/RemoteEventStore';
|
|
4
|
+
import { RemoteEventStore } from '../stores/RemoteEventStore';
|
|
5
5
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
6
6
|
import { CalendarToolBeltStateMachine, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
@@ -22,6 +22,7 @@ export declare class CalendarEventManager {
|
|
|
22
22
|
protected prefs: RemotePreferencesStore;
|
|
23
23
|
private calendars;
|
|
24
24
|
private shouldUpdateContextOnNextSave;
|
|
25
|
+
private isLoaded;
|
|
25
26
|
protected get calendarIds(): string[];
|
|
26
27
|
protected get visibleCalendarIds(): string[];
|
|
27
28
|
constructor(options: CalendarEventManagerOptions);
|
|
@@ -57,6 +58,7 @@ export declare class CalendarEventManager {
|
|
|
57
58
|
private handleWillUpdateContext;
|
|
58
59
|
private handleDidUpdateContext;
|
|
59
60
|
private saveEvent;
|
|
61
|
+
getIsLoaded(): boolean;
|
|
60
62
|
optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent): Promise<boolean>;
|
|
61
63
|
}
|
|
62
64
|
export declare type EventManagerCalendarVc = Pick<CalendarViewController, 'replaceEventsInRange' | 'mixinEvents' | 'removeEvent' | 'addEvent' | 'hasEvent' | 'updateEvent' | 'setShifts' | 'getShifts' | 'getEvent' | 'getPeople' | 'setControllerForEventType' | 'setRemoteStore' | 'getSelectedEvent' | 'selectEvent'>;
|
|
@@ -17,6 +17,7 @@ class CalendarEventManager {
|
|
|
17
17
|
this.shouldIgnoreNextContextUpdate = false;
|
|
18
18
|
this.calendars = [];
|
|
19
19
|
this.shouldUpdateContextOnNextSave = true;
|
|
20
|
+
this.isLoaded = false;
|
|
20
21
|
const { calendarVc, events, remoteVc, sm, askForUpdateStrategy, dates, preferences, } = (0, schema_1.assertOptions)(options, [
|
|
21
22
|
'calendarVc',
|
|
22
23
|
'events',
|
|
@@ -153,7 +154,7 @@ class CalendarEventManager {
|
|
|
153
154
|
});
|
|
154
155
|
this.replaceEventsInRange(events, startDate, endDate);
|
|
155
156
|
if (!this.eventTypes) {
|
|
156
|
-
this.eventTypes = await this.events.
|
|
157
|
+
this.eventTypes = await this.events.getEventTypes();
|
|
157
158
|
}
|
|
158
159
|
await Promise.all(events.map(async (e) => {
|
|
159
160
|
var _a;
|
|
@@ -215,6 +216,7 @@ class CalendarEventManager {
|
|
|
215
216
|
this.inclusiveCalendarIds = this.calendars
|
|
216
217
|
.filter((c) => c.availableTimeSlotBehavior === 'include')
|
|
217
218
|
.map((c) => c.id);
|
|
219
|
+
this.isLoaded = true;
|
|
218
220
|
}
|
|
219
221
|
getEvent(id) {
|
|
220
222
|
const event = this.allEvents.find((e) => e.id === id);
|
|
@@ -227,7 +229,7 @@ class CalendarEventManager {
|
|
|
227
229
|
return event;
|
|
228
230
|
}
|
|
229
231
|
async loadCalendars() {
|
|
230
|
-
this.calendars = await this.events.
|
|
232
|
+
this.calendars = await this.events.getCalendars();
|
|
231
233
|
}
|
|
232
234
|
async handleWillUpdateContext(options) {
|
|
233
235
|
const { event: originalEvent } = options.current;
|
|
@@ -262,6 +264,9 @@ class CalendarEventManager {
|
|
|
262
264
|
console.error('Updating event in context from root failed because:\n\n', err);
|
|
263
265
|
}
|
|
264
266
|
}
|
|
267
|
+
getIsLoaded() {
|
|
268
|
+
return this.isLoaded;
|
|
269
|
+
}
|
|
265
270
|
async optionallyAskForUpdateRepeatingStrategy(event) {
|
|
266
271
|
var _a;
|
|
267
272
|
const cleaned = (0, schema_1.normalizeSchemaValues)(heartwood_view_controllers_1.calendarEventSchema, event, {});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpruceSchemas, ViewControllerOptions, CalendarViewController as CoreCalendarViewController, ClickCalendarViewOptions, DropEventOptions, ClickEventOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
import RemoteEventStore from '../stores/RemoteEventStore';
|
|
2
|
+
import { RemoteEventStore } from '../stores/RemoteEventStore';
|
|
3
3
|
import { UpdateEvent } from '../types/calendar.types';
|
|
4
4
|
declare type Calendar = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Calendar;
|
|
5
5
|
declare type Event = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|