@sprucelabs/spruce-calendar-components 22.9.12 → 22.10.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/schemas/schemas.types.d.ts +556 -594
- package/build/__tests__/support/SpyEventManager.d.ts +10 -1
- package/build/__tests__/support/SpyEventManager.js +14 -0
- package/build/__tests__/support/SpyRemoteEventStore.d.ts +2 -2
- package/build/__tests__/support/SpyRemoteEventStore.js +1 -1
- package/build/esm/.spruce/schemas/schemas.types.d.ts +556 -594
- package/build/esm/__tests__/support/SpyEventManager.d.ts +10 -1
- package/build/esm/__tests__/support/SpyEventManager.js +19 -0
- package/build/esm/__tests__/support/SpyRemoteEventStore.d.ts +2 -2
- package/build/esm/__tests__/support/SpyRemoteEventStore.js +1 -1
- package/build/esm/skillViewControllers/Root.svc.d.ts +1 -1
- package/build/esm/skillViewControllers/Root.svc.js +5 -5
- package/build/esm/stores/RemoteEventStore.d.ts +2 -2
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.d.ts +6 -8
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +1 -1
- package/build/esm/types/calendar.types.d.ts +2 -0
- package/build/esm/utilities/CalendarEventManager.d.ts +8 -4
- package/build/esm/utilities/CalendarEventManager.js +23 -4
- package/build/esm/viewControllers/EventControlsCard.vc.d.ts +7 -9
- package/build/esm/viewControllers/EventDateTimeTool.vc.d.ts +2 -1
- package/build/esm/viewControllers/EventDateTimeTool.vc.js +24 -17
- package/build/esm/viewControllers/EventRepeatingTool.vc.d.ts +24 -24
- package/build/esm/viewControllers/EventRepeatingTool.vc.js +33 -24
- package/build/esm/viewControllers/EventTitleTool.vc.d.ts +15 -16
- package/build/esm/viewControllers/EventTitleTool.vc.js +23 -20
- package/build/esm/viewControllers/RepeatingControlsList.vc.d.ts +11 -14
- package/build/skillViewControllers/Root.svc.d.ts +1 -1
- package/build/skillViewControllers/Root.svc.js +5 -5
- package/build/stores/RemoteEventStore.d.ts +2 -2
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.d.ts +6 -8
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +1 -1
- package/build/types/calendar.types.d.ts +2 -0
- package/build/utilities/CalendarEventManager.d.ts +8 -4
- package/build/utilities/CalendarEventManager.js +23 -4
- package/build/viewControllers/EventControlsCard.vc.d.ts +7 -9
- package/build/viewControllers/EventDateTimeTool.vc.d.ts +2 -1
- package/build/viewControllers/EventDateTimeTool.vc.js +22 -17
- package/build/viewControllers/EventRepeatingTool.vc.d.ts +24 -24
- package/build/viewControllers/EventRepeatingTool.vc.js +33 -24
- package/build/viewControllers/EventTitleTool.vc.d.ts +15 -16
- package/build/viewControllers/EventTitleTool.vc.js +23 -20
- package/build/viewControllers/RepeatingControlsList.vc.d.ts +11 -14
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CalendarEvent, CalendarToolBeltContext, UpdateCalendarToolBeltContextHandler } from '../../types/calendar.types';
|
|
2
|
-
import CalendarEventManager, { CalendarEventManagerOptions } from '../../utilities/CalendarEventManager';
|
|
2
|
+
import CalendarEventManager, { CalendarEventManagerOptions, SavedEvent } from '../../utilities/CalendarEventManager';
|
|
3
3
|
import SpyRemoteEventStore from './SpyRemoteEventStore';
|
|
4
4
|
import SpyRemotePreferencesStore from './SpyRemotePreferencesStore';
|
|
5
5
|
export default class SpyEventManager extends CalendarEventManager {
|
|
@@ -12,6 +12,15 @@ export default class SpyEventManager extends CalendarEventManager {
|
|
|
12
12
|
silentlySetAllEvents(events: CalendarEvent[]): void;
|
|
13
13
|
silentlyMixinEvents(events: CalendarEvent[]): void;
|
|
14
14
|
silentlyAddEvent(event: CalendarEvent): void;
|
|
15
|
+
saveEvent(event: SavedEvent): Promise<void>;
|
|
16
|
+
setSaveRepeatingOptions(options: {
|
|
17
|
+
dateToUpdate: number;
|
|
18
|
+
shouldUpdateAllEventsGoingForward: boolean;
|
|
19
|
+
}): void;
|
|
20
|
+
getSaveRepeatingOptions(): {
|
|
21
|
+
dateToUpdate: number | undefined;
|
|
22
|
+
shouldUpdateAllEventsGoingForward: boolean | undefined;
|
|
23
|
+
};
|
|
15
24
|
updateEventInContext(updates: Partial<CalendarEvent>): Promise<{
|
|
16
25
|
isBusy: boolean;
|
|
17
26
|
id: string;
|
|
@@ -33,6 +33,25 @@ export default class SpyEventManager extends CalendarEventManager {
|
|
|
33
33
|
silentlyAddEvent(event) {
|
|
34
34
|
this.allEvents.push(event);
|
|
35
35
|
}
|
|
36
|
+
saveEvent(event) {
|
|
37
|
+
const _super = Object.create(null, {
|
|
38
|
+
saveEvent: { get: () => super.saveEvent }
|
|
39
|
+
});
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return _super.saveEvent.call(this, event);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
setSaveRepeatingOptions(options) {
|
|
45
|
+
this.dateToUpdate = options.dateToUpdate;
|
|
46
|
+
this.shouldUpdateAllEventsGoingForward =
|
|
47
|
+
options.shouldUpdateAllEventsGoingForward;
|
|
48
|
+
}
|
|
49
|
+
getSaveRepeatingOptions() {
|
|
50
|
+
return {
|
|
51
|
+
dateToUpdate: this.dateToUpdate,
|
|
52
|
+
shouldUpdateAllEventsGoingForward: this.shouldUpdateAllEventsGoingForward,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
36
55
|
updateEventInContext(updates) {
|
|
37
56
|
const _super = Object.create(null, {
|
|
38
57
|
updateEventInContext: { get: () => super.updateEventInContext }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/spruce-core-schemas';
|
|
3
3
|
import RemoteEventStoreImpl, { RemoteEventStoreOptions } from '../../stores/RemoteEventStore';
|
|
4
|
-
import { Calendar, UpdateEvent } from '../../types/calendar.types';
|
|
4
|
+
import { Calendar, CancelEventRecurringOptions, UpdateEvent } from '../../types/calendar.types';
|
|
5
5
|
export default class SpyRemoteEventStore extends RemoteEventStoreImpl {
|
|
6
6
|
private calendars?;
|
|
7
7
|
lastPersistedEvent?: SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
|
|
@@ -12,7 +12,7 @@ export default class SpyRemoteEventStore extends RemoteEventStoreImpl {
|
|
|
12
12
|
client: MercuryClient;
|
|
13
13
|
});
|
|
14
14
|
setOrganizationId(id: string): void;
|
|
15
|
-
cancelEvent(_id: string): Promise<void>;
|
|
15
|
+
cancelEvent(_id: string, _options?: CancelEventRecurringOptions): Promise<void>;
|
|
16
16
|
getCalendars(): Promise<SpruceSchemas.Calendar.v2021_05_19.Calendar[] | 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>>[]>;
|
|
17
17
|
persist(event: UpdateEvent): Promise<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent>;
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ export default class SpyRemoteEventStore extends RemoteEventStoreImpl {
|
|
|
21
21
|
setOrganizationId(id) {
|
|
22
22
|
this.organizationId = id;
|
|
23
23
|
}
|
|
24
|
-
cancelEvent(_id) {
|
|
24
|
+
cancelEvent(_id, _options) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
26
26
|
}
|
|
27
27
|
getCalendars() {
|
|
@@ -59,7 +59,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
59
59
|
load(options: SkillViewControllerLoadOptions<RootArgs>): Promise<void>;
|
|
60
60
|
private setupCalendarEventListeners;
|
|
61
61
|
private handleDidCancelEvent;
|
|
62
|
-
private
|
|
62
|
+
private handleDidCreateOrUpdateRemoteEvent;
|
|
63
63
|
private loadEventStore;
|
|
64
64
|
private loadPeople;
|
|
65
65
|
private loadScope;
|
|
@@ -81,7 +81,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
81
81
|
});
|
|
82
82
|
if (confirm) {
|
|
83
83
|
yield this.resetToRootState();
|
|
84
|
-
yield this.events.
|
|
84
|
+
yield this.events.cancelEvent(eventId);
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
}
|
|
@@ -327,8 +327,8 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
327
327
|
setupCalendarEventListeners() {
|
|
328
328
|
return __awaiter(this, void 0, void 0, function* () {
|
|
329
329
|
yield Promise.all([
|
|
330
|
-
this.client.on('calendar.did-create-calendar-event::v2021_05_19', this.
|
|
331
|
-
this.client.on('calendar.did-update-calendar-event::v2021_05_19', this.
|
|
330
|
+
this.client.on('calendar.did-create-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent.bind(this)),
|
|
331
|
+
this.client.on('calendar.did-update-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent.bind(this)),
|
|
332
332
|
this.client.on('calendar.did-cancel-calendar-event::v2021_05_19', this.handleDidCancelEvent.bind(this)),
|
|
333
333
|
]);
|
|
334
334
|
});
|
|
@@ -337,11 +337,11 @@ export default class RootSkillViewController extends AbstractSkillViewController
|
|
|
337
337
|
return __awaiter(this, void 0, void 0, function* () {
|
|
338
338
|
const { calendarEventId } = target;
|
|
339
339
|
if (this.events.hasEvent(calendarEventId)) {
|
|
340
|
-
yield this.events.
|
|
340
|
+
yield this.events.cancelEvent(calendarEventId, { shouldPersist: false });
|
|
341
341
|
}
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
handleDidCreateOrUpdateRemoteEvent({ payload, target, }) {
|
|
345
345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
346
346
|
const { calendarEvent } = payload;
|
|
347
347
|
const { locationId } = target;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
3
|
-
import { Calendar, CalendarEvent, CalendarEventType, UpdateEvent } from '../types/calendar.types';
|
|
3
|
+
import { Calendar, CalendarEvent, CalendarEventType, CancelEventRecurringOptions, UpdateEvent } from '../types/calendar.types';
|
|
4
4
|
export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
5
5
|
private connectToApi;
|
|
6
6
|
protected calendarId?: string;
|
|
@@ -52,7 +52,7 @@ export interface RemoteEventStore {
|
|
|
52
52
|
clearCalendarId(): void;
|
|
53
53
|
getCalendarId(): string | undefined;
|
|
54
54
|
waitForPendingSaves(): Promise<void>;
|
|
55
|
-
cancelEvent(id: string): Promise<void>;
|
|
55
|
+
cancelEvent(id: string, options?: CancelEventRecurringOptions): Promise<void>;
|
|
56
56
|
getSchedules(options: GetScheduleOptions): Promise<CalendarEvent[]>;
|
|
57
57
|
getEventTypes(): Promise<CalendarEventType[]>;
|
|
58
58
|
getCalendars(): Promise<Calendar[]>;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CalendarTool, CalendarToolBeltContext, CalendarToolBeltStateMachine, CalendarToolOptions, GetPersonFromEventHandler, UpdateCalendarContextOptions } from '../../types/calendar.types';
|
|
1
|
+
import { ToolBeltState, ViewControllerId } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
+
import { CalendarTool, CalendarToolBeltContext, CalendarToolBeltStateMachine, CalendarToolOptions, GetPersonFromEventHandler, Tool, UpdateCalendarContextOptions } from '../../types/calendar.types';
|
|
3
3
|
import EventControlsCardViewController from '../../viewControllers/EventControlsCard.vc';
|
|
4
|
-
declare type Tool = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.ToolBeltTool;
|
|
5
|
-
export declare type AddToolOptions = Omit<Tool, 'card'> & {
|
|
6
|
-
cardVcId: ViewControllerId;
|
|
7
|
-
};
|
|
8
4
|
export default abstract class AbstractCalendarEventToolBeltState implements ToolBeltState {
|
|
9
5
|
abstract id: string;
|
|
10
6
|
protected sm: CalendarToolBeltStateMachine;
|
|
@@ -20,7 +16,7 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
20
16
|
protected handleClickSave(): Promise<void>;
|
|
21
17
|
private deselectEvent;
|
|
22
18
|
private handleDidUpdateContext;
|
|
23
|
-
|
|
19
|
+
protected getContext(): CalendarToolBeltContext;
|
|
24
20
|
clearPendingContextChanges(shouldEmitDidUpdate?: boolean): Promise<void>;
|
|
25
21
|
addTool(options: AddToolOptions): Promise<CalendarTool>;
|
|
26
22
|
protected buildVcConstructorOptions(id: string): CalendarToolOptions;
|
|
@@ -33,4 +29,6 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
33
29
|
getControlsVc(): EventControlsCardViewController;
|
|
34
30
|
destroy(): Promise<void>;
|
|
35
31
|
}
|
|
36
|
-
export {
|
|
32
|
+
export declare type AddToolOptions = Omit<Tool, 'card'> & {
|
|
33
|
+
cardVcId: ViewControllerId;
|
|
34
|
+
};
|
|
@@ -75,7 +75,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
getContext() {
|
|
78
|
-
return Object.assign(
|
|
78
|
+
return Object.assign({}, this.sm.getContext(this.pendingContextUpdates));
|
|
79
79
|
}
|
|
80
80
|
clearPendingContextChanges(shouldEmitDidUpdate = true) {
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -52,6 +52,7 @@ export interface UpdateCalendarContextOptions {
|
|
|
52
52
|
shouldPersistContextChangesImmediately?: boolean;
|
|
53
53
|
}
|
|
54
54
|
export declare type UpdateCalendarToolBeltContextHandler<Context extends CalendarToolBeltContext = CalendarToolBeltContext> = (context: Partial<Context>, options?: UpdateCalendarContextOptions) => Promise<boolean>;
|
|
55
|
+
export declare type Tool = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.ToolBeltTool;
|
|
55
56
|
export declare type GetCalendarToolBeltContextHandler = () => CalendarToolBeltContext;
|
|
56
57
|
export declare type GetPersonFromEventHandler = () => Promise<Person | null>;
|
|
57
58
|
export declare type GetHasPendingContextChangesHandler = () => boolean;
|
|
@@ -63,6 +64,7 @@ export interface CalendarToolOptions {
|
|
|
63
64
|
getPersonFromEvent: GetPersonFromEventHandler;
|
|
64
65
|
getHasPendingContextChanges: GetHasPendingContextChangesHandler;
|
|
65
66
|
}
|
|
67
|
+
export declare type CancelEventRecurringOptions = SpruceSchemas.Calendar.v2021_05_19.CancelCalendarEventEmitPayload;
|
|
66
68
|
export interface EventWithToolBeltState {
|
|
67
69
|
getToolBeltState(): ToolBeltState;
|
|
68
70
|
}
|
|
@@ -16,8 +16,8 @@ export default class CalendarEventManager {
|
|
|
16
16
|
protected sm: CalendarToolBeltStateMachine<CalendarToolBeltContext>;
|
|
17
17
|
protected shouldIgnoreNextContextUpdate: boolean;
|
|
18
18
|
private askForUpdateStrategy;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
protected dateToUpdate?: number;
|
|
20
|
+
protected shouldUpdateAllEventsGoingForward?: boolean;
|
|
21
21
|
private dates;
|
|
22
22
|
protected prefs: RemotePreferencesStore;
|
|
23
23
|
private calendars;
|
|
@@ -45,7 +45,7 @@ export default class CalendarEventManager {
|
|
|
45
45
|
reset(): Promise<void>;
|
|
46
46
|
restoreEventToDraftOnStateLoadError(): Promise<void>;
|
|
47
47
|
getVisibleCalendarIds(): string[];
|
|
48
|
-
|
|
48
|
+
cancelEvent(id: string, options?: {
|
|
49
49
|
shouldPersist?: boolean;
|
|
50
50
|
}): Promise<void>;
|
|
51
51
|
makeCalendarVisible(calendarId: string): Promise<void>;
|
|
@@ -95,7 +95,8 @@ export default class CalendarEventManager {
|
|
|
95
95
|
private handleWillUpdateContext;
|
|
96
96
|
deselectEvent(): Promise<void>;
|
|
97
97
|
private handleDidUpdateContext;
|
|
98
|
-
|
|
98
|
+
protected saveEvent(event: SavedEvent): Promise<void>;
|
|
99
|
+
private clearPersistRepeatingOptions;
|
|
99
100
|
getIsLoaded(): boolean;
|
|
100
101
|
hasEvent(id: string): boolean;
|
|
101
102
|
optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent): Promise<boolean>;
|
|
@@ -111,4 +112,7 @@ export interface CalendarEventManagerOptions {
|
|
|
111
112
|
preferences: RemotePreferencesStore;
|
|
112
113
|
askForUpdateStrategy: (event: UpdateEvent) => Promise<UpdateRepeatingStrategyWithCancel>;
|
|
113
114
|
}
|
|
115
|
+
export declare type SavedEvent = Partial<CalendarEvent> & {
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
114
118
|
export {};
|
|
@@ -144,22 +144,33 @@ export default class CalendarEventManager {
|
|
|
144
144
|
getVisibleCalendarIds() {
|
|
145
145
|
return this.visibleCalendarIds;
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
cancelEvent(id, options) {
|
|
148
148
|
var _a;
|
|
149
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
|
|
150
|
+
const { shouldPersist = true } = options !== null && options !== void 0 ? options : {};
|
|
151
151
|
const event = this.calendarVc.getEvent(id);
|
|
152
|
+
if (shouldPersist) {
|
|
153
|
+
const accepted = yield this.optionallyAskForUpdateRepeatingStrategy(event);
|
|
154
|
+
if (!accepted) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this.allEvents = this.allEvents.filter((e) => e.id !== id);
|
|
152
159
|
yield this.calendarVc.removeEvent(id);
|
|
153
|
-
if (
|
|
160
|
+
if (!shouldPersist) {
|
|
154
161
|
return;
|
|
155
162
|
}
|
|
156
163
|
try {
|
|
157
|
-
yield this.events.cancelEvent(event.id
|
|
164
|
+
yield this.events.cancelEvent(event.id, {
|
|
165
|
+
shouldCancelAllEventsGoingForward: this.shouldUpdateAllEventsGoingForward,
|
|
166
|
+
dateToCancel: this.dateToUpdate,
|
|
167
|
+
});
|
|
158
168
|
}
|
|
159
169
|
catch (err) {
|
|
160
170
|
console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
|
|
161
171
|
this.calendarVc.addEvent(Object.assign(Object.assign({}, event), { error: err }));
|
|
162
172
|
}
|
|
173
|
+
this.clearPersistRepeatingOptions();
|
|
163
174
|
});
|
|
164
175
|
}
|
|
165
176
|
makeCalendarVisible(calendarId) {
|
|
@@ -348,8 +359,13 @@ export default class CalendarEventManager {
|
|
|
348
359
|
catch (err) {
|
|
349
360
|
console.error('Updating event in context from root failed because:\n\n', err);
|
|
350
361
|
}
|
|
362
|
+
this.clearPersistRepeatingOptions();
|
|
351
363
|
});
|
|
352
364
|
}
|
|
365
|
+
clearPersistRepeatingOptions() {
|
|
366
|
+
this.dateToUpdate = undefined;
|
|
367
|
+
this.shouldUpdateAllEventsGoingForward = undefined;
|
|
368
|
+
}
|
|
353
369
|
getIsLoaded() {
|
|
354
370
|
return this.isLoaded;
|
|
355
371
|
}
|
|
@@ -359,6 +375,9 @@ export default class CalendarEventManager {
|
|
|
359
375
|
optionallyAskForUpdateRepeatingStrategy(event) {
|
|
360
376
|
var _a;
|
|
361
377
|
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
+
if (!event.id) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
362
381
|
const cleaned = normalizeSchemaValues(calendarEventSchema, event, {});
|
|
363
382
|
if (((_a = cleaned.totalInRepeating) !== null && _a !== void 0 ? _a : 0) > 1) {
|
|
364
383
|
let strategy = yield this.askForUpdateStrategy(cleaned);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { AbstractViewController,
|
|
1
|
+
import { AbstractViewController, Card, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarTool, CalendarToolOptions, CancelEventHandler } from '../types/calendar.types';
|
|
3
|
-
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
4
|
-
export interface EventControlsCardOptions extends CalendarToolOptions {
|
|
5
|
-
onCancel: () => Promise<void | boolean> | void | boolean;
|
|
6
|
-
onCancelEvent: CancelEventHandler;
|
|
7
|
-
onSave: () => Promise<void | boolean> | void | boolean;
|
|
8
|
-
}
|
|
9
3
|
export default class EventControlsCardViewController extends AbstractViewController<Card> implements CalendarTool {
|
|
10
4
|
static id: string;
|
|
11
5
|
private cardVc;
|
|
@@ -25,6 +19,10 @@ export default class EventControlsCardViewController extends AbstractViewControl
|
|
|
25
19
|
handleUpdateContext(): void;
|
|
26
20
|
private shouldFooterBeEnabled;
|
|
27
21
|
private optionallyDropInCancelButton;
|
|
28
|
-
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
22
|
+
render(): import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
23
|
+
}
|
|
24
|
+
export interface EventControlsCardOptions extends CalendarToolOptions {
|
|
25
|
+
onCancel: () => Promise<void | boolean> | void | boolean;
|
|
26
|
+
onCancelEvent: CancelEventHandler;
|
|
27
|
+
onSave: () => Promise<void | boolean> | void | boolean;
|
|
29
28
|
}
|
|
30
|
-
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractViewController, CalendarViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarTool, CalendarToolBeltContext, CalendarToolOptions } from '../types/calendar.types';
|
|
3
|
-
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
4
3
|
export default class EventDateTimeToolViewController extends AbstractViewController<Card> implements CalendarTool {
|
|
5
4
|
static id: string;
|
|
6
5
|
shouldPersistContextChangesImmediately: boolean;
|
|
@@ -11,6 +10,7 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
11
10
|
private calendarVc;
|
|
12
11
|
constructor(options: ViewControllerOptions & CalendarToolOptions);
|
|
13
12
|
private handleSelectDateFromCalendar;
|
|
13
|
+
private promptForNavigationPreference;
|
|
14
14
|
private getSelectedDate;
|
|
15
15
|
private CardVc;
|
|
16
16
|
getCalendarVc(): CalendarViewController;
|
|
@@ -38,4 +38,5 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
38
38
|
}, false>;
|
|
39
39
|
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
40
40
|
}
|
|
41
|
+
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
41
42
|
export {};
|
|
@@ -10,15 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { dateUtil } from '@sprucelabs/calendar-utils';
|
|
11
11
|
import { AbstractViewController, buildForm, } from '@sprucelabs/heartwood-view-controllers';
|
|
12
12
|
import { buildSchema } from '@sprucelabs/schema';
|
|
13
|
-
const schema = buildSchema({
|
|
14
|
-
id: ' startDateTime',
|
|
15
|
-
fields: {
|
|
16
|
-
startDateTime: {
|
|
17
|
-
type: 'dateTime',
|
|
18
|
-
isRequired: true,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
13
|
export default class EventDateTimeToolViewController extends AbstractViewController {
|
|
23
14
|
constructor(options) {
|
|
24
15
|
super(options);
|
|
@@ -34,6 +25,17 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
34
25
|
this.cardVc = this.CardVc();
|
|
35
26
|
}
|
|
36
27
|
handleSelectDateFromCalendar({ dateTimeMs, }) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
let shouldBail = yield this.promptForNavigationPreference(dateTimeMs);
|
|
30
|
+
if (shouldBail) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const { hour, minute } = dateUtil.splitDate(this.getContext().event.startDateTimeMs);
|
|
34
|
+
yield this.formVc.setValue('startDateTime', dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
|
|
35
|
+
this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
promptForNavigationPreference(dateTimeMs) {
|
|
37
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
40
|
let shouldBail = false;
|
|
39
41
|
const formattedDestination = dateUtil.format(dateTimeMs, 'MMM do');
|
|
@@ -78,16 +80,11 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
78
80
|
},
|
|
79
81
|
});
|
|
80
82
|
yield dlg.wait();
|
|
81
|
-
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const { hour, minute } = dateUtil.splitDate(this.getContext().event.startDateTimeMs);
|
|
85
|
-
yield this.formVc.setValue('startDateTime', dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
|
|
86
|
-
this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
|
|
83
|
+
return shouldBail;
|
|
87
84
|
});
|
|
88
85
|
}
|
|
89
86
|
getSelectedDate(dateTimeMs) {
|
|
90
|
-
const { year, month, day } =
|
|
87
|
+
const { year, month, day } = this.dates.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
|
|
91
88
|
return { year, month, day };
|
|
92
89
|
}
|
|
93
90
|
CardVc() {
|
|
@@ -136,7 +133,8 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
136
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
134
|
if (values.startDateTime) {
|
|
138
135
|
yield ((_a = this.updateContext) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
139
|
-
|
|
136
|
+
//@ts-ignore
|
|
137
|
+
'event.startDateTimeMs': values.startDateTime,
|
|
140
138
|
}));
|
|
141
139
|
}
|
|
142
140
|
});
|
|
@@ -155,3 +153,12 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
155
153
|
}
|
|
156
154
|
}
|
|
157
155
|
EventDateTimeToolViewController.id = 'event-date-time-tool';
|
|
156
|
+
const schema = buildSchema({
|
|
157
|
+
id: ' startDateTime',
|
|
158
|
+
fields: {
|
|
159
|
+
startDateTime: {
|
|
160
|
+
type: 'dateTime',
|
|
161
|
+
isRequired: true,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
});
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
import { AbstractViewController,
|
|
1
|
+
import { AbstractViewController, Card, FormViewController, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarTool } from '../index-components';
|
|
3
3
|
import { CalendarToolBeltContext, CalendarToolOptions } from '../types/calendar.types';
|
|
4
4
|
import RepeatingControlsListViewController, { RepeatingOptions } from './RepeatingControlsList.vc';
|
|
5
|
-
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
6
|
-
declare const schema: {
|
|
7
|
-
id: string;
|
|
8
|
-
fields: {
|
|
9
|
-
repeat: {
|
|
10
|
-
type: "text";
|
|
11
|
-
isRequired: true;
|
|
12
|
-
defaultValue: string;
|
|
13
|
-
};
|
|
14
|
-
repeatEvery: {
|
|
15
|
-
type: "text";
|
|
16
|
-
};
|
|
17
|
-
repeatAmount: {
|
|
18
|
-
type: "text";
|
|
19
|
-
};
|
|
20
|
-
repeatUntilMs: {
|
|
21
|
-
type: "dateTime";
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
declare type Schema = typeof schema;
|
|
26
|
-
export declare type FormVc = FormViewController<Schema>;
|
|
27
5
|
export default class EventRepeatingToolViewController extends AbstractViewController<Card> implements CalendarTool {
|
|
28
6
|
static id: string;
|
|
29
7
|
private cardVc;
|
|
@@ -35,6 +13,7 @@ export default class EventRepeatingToolViewController extends AbstractViewContro
|
|
|
35
13
|
handleUpdateContext(_context: CalendarToolBeltContext): void | Promise<void>;
|
|
36
14
|
private CardVc;
|
|
37
15
|
private ControlsListVc;
|
|
16
|
+
private handleDidChangeRepeating;
|
|
38
17
|
private removeExtraRepeatingFields;
|
|
39
18
|
private FormVc;
|
|
40
19
|
getControlsListVc(): RepeatingControlsListViewController;
|
|
@@ -51,6 +30,27 @@ export default class EventRepeatingToolViewController extends AbstractViewContro
|
|
|
51
30
|
};
|
|
52
31
|
setValues(repeating: RepeatingOptions): void;
|
|
53
32
|
getCalendarVc(): import("@sprucelabs/heartwood-view-controllers").CalendarViewController | undefined;
|
|
54
|
-
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
33
|
+
render(): import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
55
34
|
}
|
|
35
|
+
declare const schema: {
|
|
36
|
+
id: string;
|
|
37
|
+
fields: {
|
|
38
|
+
repeat: {
|
|
39
|
+
type: "text";
|
|
40
|
+
isRequired: true;
|
|
41
|
+
defaultValue: string;
|
|
42
|
+
};
|
|
43
|
+
repeatEvery: {
|
|
44
|
+
type: "text";
|
|
45
|
+
};
|
|
46
|
+
repeatAmount: {
|
|
47
|
+
type: "text";
|
|
48
|
+
};
|
|
49
|
+
repeatUntilMs: {
|
|
50
|
+
type: "dateTime";
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
declare type Schema = typeof schema;
|
|
55
|
+
export declare type FormVc = FormViewController<Schema>;
|
|
56
56
|
export {};
|
|
@@ -9,25 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { AbstractViewController, buildForm, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
11
|
import { buildSchema } from '@sprucelabs/schema';
|
|
12
|
-
const schema = buildSchema({
|
|
13
|
-
id: 'repeatingSchema',
|
|
14
|
-
fields: {
|
|
15
|
-
repeat: {
|
|
16
|
-
type: 'text',
|
|
17
|
-
isRequired: true,
|
|
18
|
-
defaultValue: 'doesntRepeat',
|
|
19
|
-
},
|
|
20
|
-
repeatEvery: {
|
|
21
|
-
type: 'text',
|
|
22
|
-
},
|
|
23
|
-
repeatAmount: {
|
|
24
|
-
type: 'text',
|
|
25
|
-
},
|
|
26
|
-
repeatUntilMs: {
|
|
27
|
-
type: 'dateTime',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
12
|
export default class EventRepeatingToolViewController extends AbstractViewController {
|
|
32
13
|
constructor(options) {
|
|
33
14
|
super(options);
|
|
@@ -55,14 +36,23 @@ export default class EventRepeatingToolViewController extends AbstractViewContro
|
|
|
55
36
|
return this.Controller('calendar.repeating-controls-list', {
|
|
56
37
|
repeating: Object.assign({}, this.getEvent()),
|
|
57
38
|
didChangeRepeating: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return (_a = this.updateContextHandler) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
61
|
-
event: Object.assign(Object.assign(Object.assign({}, this.removeExtraRepeatingFields(this.getEvent())), { repeats: undefined, interval: undefined, repeatsUntil: undefined, occurrences: undefined, daysOfWeek: undefined, daysOfMonth: undefined }), cleaned),
|
|
62
|
-
});
|
|
39
|
+
const pass = this.handleDidChangeRepeating(value);
|
|
40
|
+
return pass;
|
|
63
41
|
}),
|
|
64
42
|
});
|
|
65
43
|
}
|
|
44
|
+
handleDidChangeRepeating(value) {
|
|
45
|
+
var _a;
|
|
46
|
+
const cleaned = this.removeExtraRepeatingFields(value);
|
|
47
|
+
const updates = Object.assign({ repeats: undefined, interval: undefined, repeatsUntil: undefined, occurrences: undefined, daysOfWeek: undefined, daysOfMonth: undefined }, cleaned);
|
|
48
|
+
const keyedUpdates = {};
|
|
49
|
+
Object.keys(updates).forEach((k) => {
|
|
50
|
+
//@ts-ignore
|
|
51
|
+
keyedUpdates[`event.${k}`] = updates[k];
|
|
52
|
+
});
|
|
53
|
+
const pass = (_a = this.updateContextHandler) === null || _a === void 0 ? void 0 : _a.call(this, Object.assign({}, keyedUpdates));
|
|
54
|
+
return pass;
|
|
55
|
+
}
|
|
66
56
|
removeExtraRepeatingFields(value) {
|
|
67
57
|
const cleaned = Object.assign({}, value);
|
|
68
58
|
delete cleaned.repeatAmount;
|
|
@@ -101,3 +91,22 @@ export default class EventRepeatingToolViewController extends AbstractViewContro
|
|
|
101
91
|
}
|
|
102
92
|
}
|
|
103
93
|
EventRepeatingToolViewController.id = 'event-repeating-tool';
|
|
94
|
+
const schema = buildSchema({
|
|
95
|
+
id: 'repeatingSchema',
|
|
96
|
+
fields: {
|
|
97
|
+
repeat: {
|
|
98
|
+
type: 'text',
|
|
99
|
+
isRequired: true,
|
|
100
|
+
defaultValue: 'doesntRepeat',
|
|
101
|
+
},
|
|
102
|
+
repeatEvery: {
|
|
103
|
+
type: 'text',
|
|
104
|
+
},
|
|
105
|
+
repeatAmount: {
|
|
106
|
+
type: 'text',
|
|
107
|
+
},
|
|
108
|
+
repeatUntilMs: {
|
|
109
|
+
type: 'dateTime',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import { AbstractViewController,
|
|
1
|
+
import { AbstractViewController, Card, FormViewController, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarTool, CalendarToolBeltContext, CalendarToolOptions } from '../types/calendar.types';
|
|
3
|
-
|
|
3
|
+
export default class EventTitleToolViewController extends AbstractViewController<Card> implements CalendarTool {
|
|
4
|
+
static id: string;
|
|
5
|
+
private cardVc;
|
|
6
|
+
private formVc;
|
|
7
|
+
private getContext;
|
|
8
|
+
private updateContextHandler;
|
|
9
|
+
constructor(options: ViewControllerOptions & CalendarToolOptions);
|
|
10
|
+
private CardVc;
|
|
11
|
+
private FormVc;
|
|
12
|
+
private handleChangeForm;
|
|
13
|
+
handleUpdateContext(context: CalendarToolBeltContext): Promise<void>;
|
|
14
|
+
getFormVc(): FormVc;
|
|
15
|
+
render(): import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
16
|
+
}
|
|
4
17
|
declare const formSchema: {
|
|
5
18
|
id: string;
|
|
6
19
|
fields: {
|
|
@@ -17,18 +30,4 @@ declare const formSchema: {
|
|
|
17
30
|
};
|
|
18
31
|
declare type FormSchema = typeof formSchema;
|
|
19
32
|
declare type FormVc = FormViewController<FormSchema>;
|
|
20
|
-
export default class EventTitleToolViewController extends AbstractViewController<Card> implements CalendarTool {
|
|
21
|
-
static id: string;
|
|
22
|
-
private cardVc;
|
|
23
|
-
private formVc;
|
|
24
|
-
private getContext;
|
|
25
|
-
private updateContextHandler;
|
|
26
|
-
constructor(options: ViewControllerOptions & CalendarToolOptions);
|
|
27
|
-
private CardVc;
|
|
28
|
-
private FormVc;
|
|
29
|
-
private handleChangeForm;
|
|
30
|
-
handleUpdateContext(context: CalendarToolBeltContext): Promise<void>;
|
|
31
|
-
getFormVc(): FormVc;
|
|
32
|
-
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
33
|
-
}
|
|
34
33
|
export {};
|