@sprucelabs/spruce-calendar-components 22.9.13 → 22.10.1
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.js +2 -2
- package/build/esm/stores/RemoteEventStore.d.ts +3 -3
- package/build/esm/stores/RemoteEventStore.js +2 -1
- 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.js +2 -1
- 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.js +2 -2
- package/build/stores/RemoteEventStore.d.ts +3 -3
- package/build/stores/RemoteEventStore.js +2 -1
- 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.js +2 -1
- 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() {
|
|
@@ -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
|
}
|
|
@@ -337,7 +337,7 @@ 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
|
}
|
|
@@ -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;
|
|
@@ -32,7 +32,7 @@ export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
|
32
32
|
clearCalendarId(): void;
|
|
33
33
|
getCalendarId(): string | undefined;
|
|
34
34
|
waitForPendingSaves(): Promise<void>;
|
|
35
|
-
cancelEvent(id: string): Promise<void>;
|
|
35
|
+
cancelEvent(id: string, options: CancelEventRecurringOptions): Promise<void>;
|
|
36
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
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
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>>[]>;
|
|
@@ -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[]>;
|
|
@@ -211,7 +211,7 @@ export default class RemoteEventStoreImpl {
|
|
|
211
211
|
yield Promise.all(this.promises);
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
-
cancelEvent(id) {
|
|
214
|
+
cancelEvent(id, options) {
|
|
215
215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
216
|
if (this.pendingEvents[id]) {
|
|
217
217
|
delete this.pendingEvents[id];
|
|
@@ -222,6 +222,7 @@ export default class RemoteEventStoreImpl {
|
|
|
222
222
|
locationId: this.locationId,
|
|
223
223
|
calendarEventId: id,
|
|
224
224
|
},
|
|
225
|
+
payload: Object.assign({}, options),
|
|
225
226
|
});
|
|
226
227
|
}
|
|
227
228
|
});
|
|
@@ -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 {};
|
|
@@ -133,7 +133,8 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
134
|
if (values.startDateTime) {
|
|
135
135
|
yield ((_a = this.updateContext) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
136
|
-
|
|
136
|
+
//@ts-ignore
|
|
137
|
+
'event.startDateTimeMs': values.startDateTime,
|
|
137
138
|
}));
|
|
138
139
|
}
|
|
139
140
|
});
|
|
@@ -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 {};
|
|
@@ -9,20 +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 formSchema = buildSchema({
|
|
13
|
-
id: 'titleSubtitle',
|
|
14
|
-
fields: {
|
|
15
|
-
title: {
|
|
16
|
-
type: 'text',
|
|
17
|
-
isRequired: true,
|
|
18
|
-
label: 'Title',
|
|
19
|
-
},
|
|
20
|
-
subtitle: {
|
|
21
|
-
type: 'text',
|
|
22
|
-
label: 'Subtitle',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
12
|
export default class EventTitleToolViewController extends AbstractViewController {
|
|
27
13
|
constructor(options) {
|
|
28
14
|
super(options);
|
|
@@ -44,7 +30,8 @@ export default class EventTitleToolViewController extends AbstractViewController
|
|
|
44
30
|
});
|
|
45
31
|
}
|
|
46
32
|
FormVc() {
|
|
47
|
-
var _a, _b
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const timeBlock = (_b = (_a = this.getContext().event) === null || _a === void 0 ? void 0 : _a.timeBlocks) === null || _b === void 0 ? void 0 : _b[0];
|
|
48
35
|
return this.Controller('form', buildForm({
|
|
49
36
|
schema: formSchema,
|
|
50
37
|
shouldShowSubmitControls: false,
|
|
@@ -55,17 +42,19 @@ export default class EventTitleToolViewController extends AbstractViewController
|
|
|
55
42
|
},
|
|
56
43
|
],
|
|
57
44
|
values: {
|
|
58
|
-
title:
|
|
59
|
-
subtitle:
|
|
45
|
+
title: timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.title,
|
|
46
|
+
subtitle: timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.subtitle,
|
|
60
47
|
},
|
|
61
48
|
}));
|
|
62
49
|
}
|
|
63
50
|
handleChangeForm() {
|
|
64
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
const {
|
|
66
|
-
event.timeBlocks[0] = Object.assign(Object.assign({}, event.timeBlocks[0]), this.formVc.getValues());
|
|
52
|
+
const { title, subtitle } = this.formVc.getValues();
|
|
67
53
|
yield this.updateContextHandler({
|
|
68
|
-
|
|
54
|
+
//@ts-ignore
|
|
55
|
+
'event.timeBlocks[0].title': title,
|
|
56
|
+
//@ts-ignore
|
|
57
|
+
'event.timeBlocks[0].subtitle': subtitle,
|
|
69
58
|
});
|
|
70
59
|
});
|
|
71
60
|
}
|
|
@@ -85,3 +74,17 @@ export default class EventTitleToolViewController extends AbstractViewController
|
|
|
85
74
|
}
|
|
86
75
|
}
|
|
87
76
|
EventTitleToolViewController.id = 'event-title-card';
|
|
77
|
+
const formSchema = buildSchema({
|
|
78
|
+
id: 'titleSubtitle',
|
|
79
|
+
fields: {
|
|
80
|
+
title: {
|
|
81
|
+
type: 'text',
|
|
82
|
+
isRequired: true,
|
|
83
|
+
label: 'Title',
|
|
84
|
+
},
|
|
85
|
+
subtitle: {
|
|
86
|
+
type: 'text',
|
|
87
|
+
label: 'Subtitle',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { AbstractViewController, CalendarEvent, CalendarViewController,
|
|
2
|
-
declare type List = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.List;
|
|
3
|
-
export declare type RepeatingOptions = Partial<Pick<CalendarEvent, 'repeats' | 'interval' | 'repeatsUntil' | 'occurrences' | 'startDateTimeMs' | 'daysOfWeek' | 'daysOfMonth'> & {
|
|
4
|
-
repeatAmount?: 'forever' | 'until' | 'after';
|
|
5
|
-
}>;
|
|
6
|
-
declare type Row = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.ListRow;
|
|
1
|
+
import { AbstractViewController, CalendarEvent, CalendarViewController, List, ListRow, ListViewController, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
7
2
|
export default class RepeatingControlsListViewController extends AbstractViewController<List> {
|
|
8
3
|
static id: string;
|
|
9
4
|
private listVc;
|
|
@@ -15,13 +10,13 @@ export default class RepeatingControlsListViewController extends AbstractViewCon
|
|
|
15
10
|
didChangeRepeating: (values: RepeatingOptions) => void;
|
|
16
11
|
});
|
|
17
12
|
private ListVc;
|
|
18
|
-
renderRows():
|
|
19
|
-
renderRepeatRow():
|
|
13
|
+
renderRows(): ListRow[];
|
|
14
|
+
renderRepeatRow(): ListRow;
|
|
20
15
|
private renderRepeatingControlsRow;
|
|
21
|
-
renderRepeatEveryRow():
|
|
22
|
-
renderWeekDayRow():
|
|
23
|
-
renderCalendarRow():
|
|
24
|
-
renderRepeatAmountRow():
|
|
16
|
+
renderRepeatEveryRow(): ListRow;
|
|
17
|
+
renderWeekDayRow(): ListRow;
|
|
18
|
+
renderCalendarRow(): ListRow;
|
|
19
|
+
renderRepeatAmountRow(): ListRow;
|
|
25
20
|
private handleRepeatsChange;
|
|
26
21
|
private resetRows;
|
|
27
22
|
private changeRepeatingControlsRow;
|
|
@@ -45,6 +40,8 @@ export default class RepeatingControlsListViewController extends AbstractViewCon
|
|
|
45
40
|
private setCalendarSelectedDatesFromDate;
|
|
46
41
|
private getSelectedDatesFromDate;
|
|
47
42
|
private changeCalendarSelectedDate;
|
|
48
|
-
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.List;
|
|
43
|
+
render(): import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.List;
|
|
49
44
|
}
|
|
50
|
-
export {
|
|
45
|
+
export declare type RepeatingOptions = Partial<Pick<CalendarEvent, 'repeats' | 'interval' | 'repeatsUntil' | 'occurrences' | 'startDateTimeMs' | 'daysOfWeek' | 'daysOfMonth'> & {
|
|
46
|
+
repeatAmount?: 'forever' | 'until' | 'after';
|
|
47
|
+
}>;
|