@sprucelabs/spruce-calendar-components 22.3.17 → 22.3.20
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.d.ts +1 -1
- package/build/esm/skillViewControllers/Root.svc.js +1 -2
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.d.ts +3 -1
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +12 -3
- package/build/esm/toolBelt/states/RootToolBeltState.d.ts +1 -1
- package/build/esm/types/calendar.types.d.ts +1 -1
- package/build/esm/utilities/CalendarEventManager.d.ts +33 -5
- package/build/esm/utilities/CalendarEventManager.js +13 -3
- package/build/esm/viewControllers/CalendarSelectTool.vc.d.ts +1 -1
- package/build/skillViewControllers/Root.svc.d.ts +1 -1
- package/build/skillViewControllers/Root.svc.js +2 -3
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.d.ts +3 -1
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +12 -3
- package/build/toolBelt/states/RootToolBeltState.d.ts +1 -1
- package/build/types/calendar.types.d.ts +1 -1
- package/build/utilities/CalendarEventManager.d.ts +33 -5
- package/build/utilities/CalendarEventManager.js +13 -4
- package/build/viewControllers/CalendarSelectTool.vc.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { AbstractSkillViewController, SkillViewControllerLoadOptions, SpruceSche
|
|
|
2
2
|
import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
|
|
3
3
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
4
4
|
import { CalendarToolBeltStateMachine } from '../types/calendar.types';
|
|
5
|
-
import
|
|
5
|
+
import CalendarEventManager from '../utilities/CalendarEventManager';
|
|
6
6
|
import CalendarPeopleManager from '../utilities/CalendarPeopleManager';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
8
8
|
export default class RootSkillViewController extends AbstractSkillViewController<Args> {
|
|
@@ -13,7 +13,7 @@ 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';
|
|
16
|
-
import
|
|
16
|
+
import CalendarEventManager from '../utilities/CalendarEventManager.js';
|
|
17
17
|
import CalendarPeopleManager from '../utilities/CalendarPeopleManager.js';
|
|
18
18
|
export default class RootSkillViewController extends AbstractSkillViewController {
|
|
19
19
|
constructor(options) {
|
|
@@ -249,7 +249,6 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
249
249
|
}
|
|
250
250
|
handleDraftEventAdded(event) {
|
|
251
251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
-
console.log('handle draft event added');
|
|
253
252
|
yield this.events.addDraftEvent(event, !event.eventTypeSlug);
|
|
254
253
|
if (!event.eventTypeSlug) {
|
|
255
254
|
this.toolBeltVc.open({ shouldStayOpen: true });
|
|
@@ -12,8 +12,10 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
12
12
|
private vcs;
|
|
13
13
|
private pendingContextUpdates;
|
|
14
14
|
private controlsVc;
|
|
15
|
-
private
|
|
15
|
+
private isLoaded;
|
|
16
|
+
private events;
|
|
16
17
|
load(sm: CalendarToolBeltStateMachine): Promise<void>;
|
|
18
|
+
getIsLoaded(): boolean;
|
|
17
19
|
protected loadRemoteCards(): Promise<void>;
|
|
18
20
|
protected handleClickSave(): Promise<void>;
|
|
19
21
|
private deselectEvent;
|
|
@@ -14,15 +14,20 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
this.vcs = [];
|
|
16
16
|
this.pendingContextUpdates = {};
|
|
17
|
-
|
|
18
|
-
this._isLoaded = false;
|
|
17
|
+
this.isLoaded = false;
|
|
19
18
|
}
|
|
20
19
|
load(sm) {
|
|
21
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
21
|
this.sm = sm;
|
|
23
22
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
24
|
-
this.
|
|
23
|
+
this.isLoaded = true;
|
|
25
24
|
this.controlsVc = sm.Controller('calendar.event-controls-card', Object.assign(Object.assign({ onCancel: this.clearPendingContextChanges.bind(this), onSave: this.handleClickSave.bind(this) }, this.buildVcConstructorOptions('controls')), { onCancelEvent: this.sm.getContext().cancelEvent }));
|
|
25
|
+
this.events = sm.getContext().events;
|
|
26
|
+
this.events.setUpdateContextHandler((updates) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return this.handleUpdateContextFromTool(updates, 'eventManager', {
|
|
28
|
+
shouldPersistContextChangesImmediately: true,
|
|
29
|
+
});
|
|
30
|
+
}));
|
|
26
31
|
this.toolBeltVc.clearTools();
|
|
27
32
|
this.toolBeltVc.setStickyTool({
|
|
28
33
|
card: this.controlsVc.render(),
|
|
@@ -33,6 +38,9 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
33
38
|
yield this.sm.on('did-update-context', this.handleDidUpdateContext);
|
|
34
39
|
});
|
|
35
40
|
}
|
|
41
|
+
getIsLoaded() {
|
|
42
|
+
return this.isLoaded;
|
|
43
|
+
}
|
|
36
44
|
loadRemoteCards() {
|
|
37
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
46
|
const registrar = new CalendarToolRegistrar(this.sm, (vc) => {
|
|
@@ -173,6 +181,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
173
181
|
destroy() {
|
|
174
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
183
|
yield this.sm.off('did-update-context', this.handleDidUpdateContext);
|
|
184
|
+
this.events.clearUpdateContextHandler();
|
|
176
185
|
});
|
|
177
186
|
}
|
|
178
187
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpruceSchemas, ToolBeltState } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarToolBeltStateMachine } from '../../types/calendar.types';
|
|
3
|
-
import
|
|
3
|
+
import CalendarEventManager from '../../utilities/CalendarEventManager';
|
|
4
4
|
import CalendarPeopleManager from '../../utilities/CalendarPeopleManager';
|
|
5
5
|
import CalendarSelectCardViewController from '../../viewControllers/CalendarSelectTool.vc';
|
|
6
6
|
import DateSelectCardViewController from '../../viewControllers/DateSelectCard.vc';
|
|
@@ -2,7 +2,7 @@ import { AbstractViewController, LineIcon, SkillViewControllerLoadOptions, ToolB
|
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
3
|
import { EventTarget } from '@sprucelabs/spruce-event-utils';
|
|
4
4
|
import { UpdateRepeatingStrategy } from '../constants';
|
|
5
|
-
import
|
|
5
|
+
import CalendarEventManager from '../utilities/CalendarEventManager';
|
|
6
6
|
import CalendarPeopleManager from '../utilities/CalendarPeopleManager';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
8
8
|
export interface Schedule {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateUtil } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { CalendarEvent } from '@sprucelabs/heartwood-view-controllers';
|
|
3
3
|
import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
|
|
4
4
|
import { RemoteEventStore } from '../stores/RemoteEventStore';
|
|
5
5
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
6
|
-
import { CalendarToolBeltStateMachine, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
|
|
6
|
+
import { CalendarToolBeltContext, CalendarToolBeltStateMachine, UpdateCalendarToolBeltContextHandler, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
8
|
-
export
|
|
8
|
+
export default class CalendarEventManager {
|
|
9
9
|
private calendarVc;
|
|
10
10
|
protected allEvents: CalendarEvent[];
|
|
11
11
|
private inclusiveCalendarIds;
|
|
@@ -23,6 +23,7 @@ export declare class CalendarEventManager {
|
|
|
23
23
|
private calendars;
|
|
24
24
|
private shouldUpdateContextOnNextSave;
|
|
25
25
|
private isLoaded;
|
|
26
|
+
protected updateContext?: UpdateCalendarToolBeltContextHandler<CalendarToolBeltContext>;
|
|
26
27
|
protected get calendarIds(): string[];
|
|
27
28
|
protected get visibleCalendarIds(): string[];
|
|
28
29
|
constructor(options: CalendarEventManagerOptions);
|
|
@@ -54,8 +55,35 @@ export declare class CalendarEventManager {
|
|
|
54
55
|
setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
|
|
55
56
|
setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
|
|
56
57
|
private assertValidCalendarId;
|
|
57
|
-
|
|
58
|
+
protected updateEventInContext(updates: Partial<CalendarEvent>): Promise<{
|
|
59
|
+
isBusy: boolean;
|
|
60
|
+
id: string;
|
|
61
|
+
target: import("@sprucelabs/calendar-utils").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventTarget;
|
|
62
|
+
calendarId: string;
|
|
63
|
+
eventTypeSlug?: string | null | undefined;
|
|
64
|
+
startDateTimeMs: number;
|
|
65
|
+
isResizeable?: boolean | null | undefined;
|
|
66
|
+
style?: "active" | "blocked" | "draft" | "tentative" | "upcoming" | "unavailable" | "past" | "warn" | "critical" | null | undefined;
|
|
67
|
+
groupId?: string | null | undefined;
|
|
68
|
+
timeBlocks: import("@sprucelabs/calendar-utils").SpruceSchemas.CalendarUtils.v2021_05_19.EventTimeBlock[];
|
|
69
|
+
repeats?: "weekly" | "monthly" | "daily" | null | undefined;
|
|
70
|
+
daysOfWeek?: ("sun" | "mon" | "tue" | "wed" | "thur" | "fri" | "sat")[] | null | undefined;
|
|
71
|
+
daysOfMonth?: ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "30" | "31")[] | null | undefined;
|
|
72
|
+
repeatsUntil?: number | null | undefined;
|
|
73
|
+
occurrences?: number | null | undefined;
|
|
74
|
+
interval?: number | null | undefined;
|
|
75
|
+
nthOccurrences?: number[] | null | undefined;
|
|
76
|
+
activeUntilDate?: number | null | undefined;
|
|
77
|
+
exclusionDates?: import("@sprucelabs/calendar-utils").SpruceSchemas.CalendarUtils.v2021_05_19.EventExclusionDate[] | null | undefined;
|
|
78
|
+
nthInRepeating?: number | null | undefined;
|
|
79
|
+
totalInRepeating?: number | null | undefined;
|
|
80
|
+
error?: Error | null | undefined;
|
|
81
|
+
isSelected?: boolean | null | undefined;
|
|
82
|
+
controller?: import("@sprucelabs/heartwood-view-controllers").CalendarEventViewController | null | undefined;
|
|
83
|
+
}>;
|
|
58
84
|
private setEventInContext;
|
|
85
|
+
setUpdateContextHandler(handler: UpdateCalendarToolBeltContextHandler<CalendarToolBeltContext>): void;
|
|
86
|
+
clearUpdateContextHandler(): void;
|
|
59
87
|
selectEvent(eventId: string): Promise<void>;
|
|
60
88
|
load(): Promise<void>;
|
|
61
89
|
getEvent(id: string): CalendarEvent;
|
|
@@ -75,7 +103,7 @@ export interface CalendarEventManagerOptions {
|
|
|
75
103
|
events: RemoteEventStore;
|
|
76
104
|
remoteVc: EventManagerRemoteViewControllerFactory;
|
|
77
105
|
sm: CalendarToolBeltStateMachine;
|
|
78
|
-
dates:
|
|
106
|
+
dates: DateUtil;
|
|
79
107
|
preferences: RemotePreferencesStore;
|
|
80
108
|
askForUpdateStrategy: (event: UpdateEvent) => Promise<UpdateRepeatingStrategyWithCancel>;
|
|
81
109
|
}
|
|
@@ -12,7 +12,7 @@ import { assertOptions, normalizeSchemaValues } from '@sprucelabs/schema';
|
|
|
12
12
|
import SpruceError from '../errors/SpruceError.js';
|
|
13
13
|
import calendarShiftGenerator from './calendarShiftGenerator.js';
|
|
14
14
|
import draftEventGenerator from './draftGenerator.js';
|
|
15
|
-
export class CalendarEventManager {
|
|
15
|
+
export default class CalendarEventManager {
|
|
16
16
|
constructor(options) {
|
|
17
17
|
this.allEvents = [];
|
|
18
18
|
this.inclusiveCalendarIds = [];
|
|
@@ -90,10 +90,13 @@ export class CalendarEventManager {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
silentlySwapEvent(oldId, event) {
|
|
93
|
+
var _a;
|
|
93
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
95
|
const events = this.getEvents().filter((e) => e.id !== oldId);
|
|
95
96
|
this.allEvents = [...events, event];
|
|
96
|
-
|
|
97
|
+
if (((_a = this.sm.getContext().event) === null || _a === void 0 ? void 0 : _a.id) === oldId) {
|
|
98
|
+
yield this.updateEventInContext(event);
|
|
99
|
+
}
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
102
|
handleDropEvent(id, updates) {
|
|
@@ -235,14 +238,21 @@ export class CalendarEventManager {
|
|
|
235
238
|
});
|
|
236
239
|
}
|
|
237
240
|
setEventInContext(newEvent, options) {
|
|
241
|
+
var _a;
|
|
238
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
243
|
this.shouldIgnoreNextContextUpdate =
|
|
240
244
|
(options === null || options === void 0 ? void 0 : options.shouldHandleDidUpdateContext) !== false;
|
|
241
|
-
yield this.sm.updateContext({
|
|
245
|
+
yield ((_a = this.updateContext) !== null && _a !== void 0 ? _a : this.sm.updateContext.bind(this.sm))({
|
|
242
246
|
event: newEvent,
|
|
243
247
|
});
|
|
244
248
|
});
|
|
245
249
|
}
|
|
250
|
+
setUpdateContextHandler(handler) {
|
|
251
|
+
this.updateContext = handler;
|
|
252
|
+
}
|
|
253
|
+
clearUpdateContextHandler() {
|
|
254
|
+
delete this.updateContext;
|
|
255
|
+
}
|
|
246
256
|
selectEvent(eventId) {
|
|
247
257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
258
|
const lastSelected = this.calendarVc.getSelectedEvent();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractViewController, ActiveRecordCardViewController, Scope, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
import
|
|
2
|
+
import CalendarEventManager from '../utilities/CalendarEventManager';
|
|
3
3
|
export default class CalendarSelectCardViewController extends AbstractViewController<Card> {
|
|
4
4
|
static id: string;
|
|
5
5
|
private isLoaded;
|
|
@@ -2,7 +2,7 @@ import { AbstractSkillViewController, SkillViewControllerLoadOptions, SpruceSche
|
|
|
2
2
|
import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
|
|
3
3
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
4
4
|
import { CalendarToolBeltStateMachine } from '../types/calendar.types';
|
|
5
|
-
import
|
|
5
|
+
import CalendarEventManager from '../utilities/CalendarEventManager';
|
|
6
6
|
import CalendarPeopleManager from '../utilities/CalendarPeopleManager';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
8
8
|
export default class RootSkillViewController extends AbstractSkillViewController<Args> {
|
|
@@ -9,7 +9,7 @@ const RemoteEventStore_1 = __importDefault(require("../stores/RemoteEventStore")
|
|
|
9
9
|
const RemotePreferencesStore_1 = __importDefault(require("../stores/RemotePreferencesStore"));
|
|
10
10
|
const PrerequisitesToolBeltState_1 = require("../toolBelt/states/PrerequisitesToolBeltState");
|
|
11
11
|
const RootToolBeltState_1 = require("../toolBelt/states/RootToolBeltState");
|
|
12
|
-
const CalendarEventManager_1 = require("../utilities/CalendarEventManager");
|
|
12
|
+
const CalendarEventManager_1 = __importDefault(require("../utilities/CalendarEventManager"));
|
|
13
13
|
const CalendarPeopleManager_1 = __importDefault(require("../utilities/CalendarPeopleManager"));
|
|
14
14
|
class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkillViewController {
|
|
15
15
|
constructor(options) {
|
|
@@ -34,7 +34,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
|
|
|
34
34
|
calendarVc: this.calendarVc,
|
|
35
35
|
getVisibleEvents: this.getVisibleEvents.bind(this),
|
|
36
36
|
});
|
|
37
|
-
this.events = new CalendarEventManager_1.
|
|
37
|
+
this.events = new CalendarEventManager_1.default({
|
|
38
38
|
calendarVc: this.calendarVc,
|
|
39
39
|
events: this.remoteEventStore,
|
|
40
40
|
remoteVc: this.remoteVc,
|
|
@@ -220,7 +220,6 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
async handleDraftEventAdded(event) {
|
|
223
|
-
console.log('handle draft event added');
|
|
224
223
|
await this.events.addDraftEvent(event, !event.eventTypeSlug);
|
|
225
224
|
if (!event.eventTypeSlug) {
|
|
226
225
|
this.toolBeltVc.open({ shouldStayOpen: true });
|
|
@@ -12,8 +12,10 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
12
12
|
private vcs;
|
|
13
13
|
private pendingContextUpdates;
|
|
14
14
|
private controlsVc;
|
|
15
|
-
private
|
|
15
|
+
private isLoaded;
|
|
16
|
+
private events;
|
|
16
17
|
load(sm: CalendarToolBeltStateMachine): Promise<void>;
|
|
18
|
+
getIsLoaded(): boolean;
|
|
17
19
|
protected loadRemoteCards(): Promise<void>;
|
|
18
20
|
protected handleClickSave(): Promise<void>;
|
|
19
21
|
private deselectEvent;
|
|
@@ -10,14 +10,19 @@ class AbstractCalendarEventToolBeltState {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
this.vcs = [];
|
|
12
12
|
this.pendingContextUpdates = {};
|
|
13
|
-
|
|
14
|
-
this._isLoaded = false;
|
|
13
|
+
this.isLoaded = false;
|
|
15
14
|
}
|
|
16
15
|
async load(sm) {
|
|
17
16
|
this.sm = sm;
|
|
18
17
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
19
|
-
this.
|
|
18
|
+
this.isLoaded = true;
|
|
20
19
|
this.controlsVc = sm.Controller('calendar.event-controls-card', Object.assign(Object.assign({ onCancel: this.clearPendingContextChanges.bind(this), onSave: this.handleClickSave.bind(this) }, this.buildVcConstructorOptions('controls')), { onCancelEvent: this.sm.getContext().cancelEvent }));
|
|
20
|
+
this.events = sm.getContext().events;
|
|
21
|
+
this.events.setUpdateContextHandler(async (updates) => {
|
|
22
|
+
return this.handleUpdateContextFromTool(updates, 'eventManager', {
|
|
23
|
+
shouldPersistContextChangesImmediately: true,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
21
26
|
this.toolBeltVc.clearTools();
|
|
22
27
|
this.toolBeltVc.setStickyTool({
|
|
23
28
|
card: this.controlsVc.render(),
|
|
@@ -27,6 +32,9 @@ class AbstractCalendarEventToolBeltState {
|
|
|
27
32
|
this.handleDidUpdateContext = this.handleDidUpdateContext.bind(this);
|
|
28
33
|
await this.sm.on('did-update-context', this.handleDidUpdateContext);
|
|
29
34
|
}
|
|
35
|
+
getIsLoaded() {
|
|
36
|
+
return this.isLoaded;
|
|
37
|
+
}
|
|
30
38
|
async loadRemoteCards() {
|
|
31
39
|
const registrar = new CalendarToolRegistrar_1.default(this.sm, (vc) => {
|
|
32
40
|
//@ts-ignore
|
|
@@ -148,6 +156,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
148
156
|
}
|
|
149
157
|
async destroy() {
|
|
150
158
|
await this.sm.off('did-update-context', this.handleDidUpdateContext);
|
|
159
|
+
this.events.clearUpdateContextHandler();
|
|
151
160
|
}
|
|
152
161
|
}
|
|
153
162
|
exports.default = AbstractCalendarEventToolBeltState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpruceSchemas, ToolBeltState } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarToolBeltStateMachine } from '../../types/calendar.types';
|
|
3
|
-
import
|
|
3
|
+
import CalendarEventManager from '../../utilities/CalendarEventManager';
|
|
4
4
|
import CalendarPeopleManager from '../../utilities/CalendarPeopleManager';
|
|
5
5
|
import CalendarSelectCardViewController from '../../viewControllers/CalendarSelectTool.vc';
|
|
6
6
|
import DateSelectCardViewController from '../../viewControllers/DateSelectCard.vc';
|
|
@@ -2,7 +2,7 @@ import { AbstractViewController, LineIcon, SkillViewControllerLoadOptions, ToolB
|
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
3
|
import { EventTarget } from '@sprucelabs/spruce-event-utils';
|
|
4
4
|
import { UpdateRepeatingStrategy } from '../constants';
|
|
5
|
-
import
|
|
5
|
+
import CalendarEventManager from '../utilities/CalendarEventManager';
|
|
6
6
|
import CalendarPeopleManager from '../utilities/CalendarPeopleManager';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
8
8
|
export interface Schedule {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateUtil } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { CalendarEvent } from '@sprucelabs/heartwood-view-controllers';
|
|
3
3
|
import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
|
|
4
4
|
import { RemoteEventStore } from '../stores/RemoteEventStore';
|
|
5
5
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
6
|
-
import { CalendarToolBeltStateMachine, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
|
|
6
|
+
import { CalendarToolBeltContext, CalendarToolBeltStateMachine, UpdateCalendarToolBeltContextHandler, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
|
|
7
7
|
import CalendarViewController from '../viewControllers/Calendar.vc';
|
|
8
|
-
export
|
|
8
|
+
export default class CalendarEventManager {
|
|
9
9
|
private calendarVc;
|
|
10
10
|
protected allEvents: CalendarEvent[];
|
|
11
11
|
private inclusiveCalendarIds;
|
|
@@ -23,6 +23,7 @@ export declare class CalendarEventManager {
|
|
|
23
23
|
private calendars;
|
|
24
24
|
private shouldUpdateContextOnNextSave;
|
|
25
25
|
private isLoaded;
|
|
26
|
+
protected updateContext?: UpdateCalendarToolBeltContextHandler<CalendarToolBeltContext>;
|
|
26
27
|
protected get calendarIds(): string[];
|
|
27
28
|
protected get visibleCalendarIds(): string[];
|
|
28
29
|
constructor(options: CalendarEventManagerOptions);
|
|
@@ -54,8 +55,35 @@ export declare class CalendarEventManager {
|
|
|
54
55
|
setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
|
|
55
56
|
setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
|
|
56
57
|
private assertValidCalendarId;
|
|
57
|
-
|
|
58
|
+
protected updateEventInContext(updates: Partial<CalendarEvent>): Promise<{
|
|
59
|
+
isBusy: boolean;
|
|
60
|
+
id: string;
|
|
61
|
+
target: import("@sprucelabs/calendar-utils").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventTarget;
|
|
62
|
+
calendarId: string;
|
|
63
|
+
eventTypeSlug?: string | null | undefined;
|
|
64
|
+
startDateTimeMs: number;
|
|
65
|
+
isResizeable?: boolean | null | undefined;
|
|
66
|
+
style?: "active" | "blocked" | "draft" | "tentative" | "upcoming" | "unavailable" | "past" | "warn" | "critical" | null | undefined;
|
|
67
|
+
groupId?: string | null | undefined;
|
|
68
|
+
timeBlocks: import("@sprucelabs/calendar-utils").SpruceSchemas.CalendarUtils.v2021_05_19.EventTimeBlock[];
|
|
69
|
+
repeats?: "weekly" | "monthly" | "daily" | null | undefined;
|
|
70
|
+
daysOfWeek?: ("sun" | "mon" | "tue" | "wed" | "thur" | "fri" | "sat")[] | null | undefined;
|
|
71
|
+
daysOfMonth?: ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "30" | "31")[] | null | undefined;
|
|
72
|
+
repeatsUntil?: number | null | undefined;
|
|
73
|
+
occurrences?: number | null | undefined;
|
|
74
|
+
interval?: number | null | undefined;
|
|
75
|
+
nthOccurrences?: number[] | null | undefined;
|
|
76
|
+
activeUntilDate?: number | null | undefined;
|
|
77
|
+
exclusionDates?: import("@sprucelabs/calendar-utils").SpruceSchemas.CalendarUtils.v2021_05_19.EventExclusionDate[] | null | undefined;
|
|
78
|
+
nthInRepeating?: number | null | undefined;
|
|
79
|
+
totalInRepeating?: number | null | undefined;
|
|
80
|
+
error?: Error | null | undefined;
|
|
81
|
+
isSelected?: boolean | null | undefined;
|
|
82
|
+
controller?: import("@sprucelabs/heartwood-view-controllers").CalendarEventViewController | null | undefined;
|
|
83
|
+
}>;
|
|
58
84
|
private setEventInContext;
|
|
85
|
+
setUpdateContextHandler(handler: UpdateCalendarToolBeltContextHandler<CalendarToolBeltContext>): void;
|
|
86
|
+
clearUpdateContextHandler(): void;
|
|
59
87
|
selectEvent(eventId: string): Promise<void>;
|
|
60
88
|
load(): Promise<void>;
|
|
61
89
|
getEvent(id: string): CalendarEvent;
|
|
@@ -75,7 +103,7 @@ export interface CalendarEventManagerOptions {
|
|
|
75
103
|
events: RemoteEventStore;
|
|
76
104
|
remoteVc: EventManagerRemoteViewControllerFactory;
|
|
77
105
|
sm: CalendarToolBeltStateMachine;
|
|
78
|
-
dates:
|
|
106
|
+
dates: DateUtil;
|
|
79
107
|
preferences: RemotePreferencesStore;
|
|
80
108
|
askForUpdateStrategy: (event: UpdateEvent) => Promise<UpdateRepeatingStrategyWithCancel>;
|
|
81
109
|
}
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CalendarEventManager = void 0;
|
|
7
6
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
8
7
|
const schema_1 = require("@sprucelabs/schema");
|
|
9
8
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
@@ -85,9 +84,12 @@ class CalendarEventManager {
|
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
async silentlySwapEvent(oldId, event) {
|
|
87
|
+
var _a;
|
|
88
88
|
const events = this.getEvents().filter((e) => e.id !== oldId);
|
|
89
89
|
this.allEvents = [...events, event];
|
|
90
|
-
|
|
90
|
+
if (((_a = this.sm.getContext().event) === null || _a === void 0 ? void 0 : _a.id) === oldId) {
|
|
91
|
+
await this.updateEventInContext(event);
|
|
92
|
+
}
|
|
91
93
|
}
|
|
92
94
|
async handleDropEvent(id, updates) {
|
|
93
95
|
const event = Object.assign(Object.assign({}, this.calendarVc.getEvent(id)), updates);
|
|
@@ -208,12 +210,19 @@ class CalendarEventManager {
|
|
|
208
210
|
return updated;
|
|
209
211
|
}
|
|
210
212
|
async setEventInContext(newEvent, options) {
|
|
213
|
+
var _a;
|
|
211
214
|
this.shouldIgnoreNextContextUpdate =
|
|
212
215
|
(options === null || options === void 0 ? void 0 : options.shouldHandleDidUpdateContext) !== false;
|
|
213
|
-
await this.sm.updateContext({
|
|
216
|
+
await ((_a = this.updateContext) !== null && _a !== void 0 ? _a : this.sm.updateContext.bind(this.sm))({
|
|
214
217
|
event: newEvent,
|
|
215
218
|
});
|
|
216
219
|
}
|
|
220
|
+
setUpdateContextHandler(handler) {
|
|
221
|
+
this.updateContext = handler;
|
|
222
|
+
}
|
|
223
|
+
clearUpdateContextHandler() {
|
|
224
|
+
delete this.updateContext;
|
|
225
|
+
}
|
|
217
226
|
async selectEvent(eventId) {
|
|
218
227
|
const lastSelected = this.calendarVc.getSelectedEvent();
|
|
219
228
|
const event = this.calendarVc.getEvent(eventId);
|
|
@@ -310,4 +319,4 @@ class CalendarEventManager {
|
|
|
310
319
|
return true;
|
|
311
320
|
}
|
|
312
321
|
}
|
|
313
|
-
exports.
|
|
322
|
+
exports.default = CalendarEventManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractViewController, ActiveRecordCardViewController, Scope, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
import
|
|
2
|
+
import CalendarEventManager from '../utilities/CalendarEventManager';
|
|
3
3
|
export default class CalendarSelectCardViewController extends AbstractViewController<Card> {
|
|
4
4
|
static id: string;
|
|
5
5
|
private isLoaded;
|