@sprucelabs/spruce-calendar-components 22.9.13 → 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.js +2 -2
- 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.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 +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.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,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
|
+
};
|
|
@@ -61,7 +61,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
61
61
|
this.controlsVc.handleUpdateContext();
|
|
62
62
|
}
|
|
63
63
|
getContext() {
|
|
64
|
-
return Object.assign(
|
|
64
|
+
return Object.assign({}, this.sm.getContext(this.pendingContextUpdates));
|
|
65
65
|
}
|
|
66
66
|
async clearPendingContextChanges(shouldEmitDidUpdate = true) {
|
|
67
67
|
this.pendingContextUpdates = {};
|
|
@@ -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 {};
|
|
@@ -130,21 +130,32 @@ class CalendarEventManager {
|
|
|
130
130
|
getVisibleCalendarIds() {
|
|
131
131
|
return this.visibleCalendarIds;
|
|
132
132
|
}
|
|
133
|
-
async
|
|
133
|
+
async cancelEvent(id, options) {
|
|
134
134
|
var _a;
|
|
135
|
-
|
|
135
|
+
const { shouldPersist = true } = options !== null && options !== void 0 ? options : {};
|
|
136
136
|
const event = this.calendarVc.getEvent(id);
|
|
137
|
+
if (shouldPersist) {
|
|
138
|
+
const accepted = await this.optionallyAskForUpdateRepeatingStrategy(event);
|
|
139
|
+
if (!accepted) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
this.allEvents = this.allEvents.filter((e) => e.id !== id);
|
|
137
144
|
await this.calendarVc.removeEvent(id);
|
|
138
|
-
if (
|
|
145
|
+
if (!shouldPersist) {
|
|
139
146
|
return;
|
|
140
147
|
}
|
|
141
148
|
try {
|
|
142
|
-
await this.events.cancelEvent(event.id
|
|
149
|
+
await this.events.cancelEvent(event.id, {
|
|
150
|
+
shouldCancelAllEventsGoingForward: this.shouldUpdateAllEventsGoingForward,
|
|
151
|
+
dateToCancel: this.dateToUpdate,
|
|
152
|
+
});
|
|
143
153
|
}
|
|
144
154
|
catch (err) {
|
|
145
155
|
console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
|
|
146
156
|
this.calendarVc.addEvent(Object.assign(Object.assign({}, event), { error: err }));
|
|
147
157
|
}
|
|
158
|
+
this.clearPersistRepeatingOptions();
|
|
148
159
|
}
|
|
149
160
|
async makeCalendarVisible(calendarId) {
|
|
150
161
|
this.assertValidCalendarId(calendarId);
|
|
@@ -305,6 +316,11 @@ class CalendarEventManager {
|
|
|
305
316
|
catch (err) {
|
|
306
317
|
console.error('Updating event in context from root failed because:\n\n', err);
|
|
307
318
|
}
|
|
319
|
+
this.clearPersistRepeatingOptions();
|
|
320
|
+
}
|
|
321
|
+
clearPersistRepeatingOptions() {
|
|
322
|
+
this.dateToUpdate = undefined;
|
|
323
|
+
this.shouldUpdateAllEventsGoingForward = undefined;
|
|
308
324
|
}
|
|
309
325
|
getIsLoaded() {
|
|
310
326
|
return this.isLoaded;
|
|
@@ -314,6 +330,9 @@ class CalendarEventManager {
|
|
|
314
330
|
}
|
|
315
331
|
async optionallyAskForUpdateRepeatingStrategy(event) {
|
|
316
332
|
var _a;
|
|
333
|
+
if (!event.id) {
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
317
336
|
const cleaned = (0, schema_1.normalizeSchemaValues)(heartwood_view_controllers_1.calendarEventSchema, event, {});
|
|
318
337
|
if (((_a = cleaned.totalInRepeating) !== null && _a !== void 0 ? _a : 0) > 1) {
|
|
319
338
|
let strategy = await 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 {};
|
|
@@ -119,7 +119,8 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
|
|
|
119
119
|
var _a;
|
|
120
120
|
if (values.startDateTime) {
|
|
121
121
|
await ((_a = this.updateContext) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
122
|
-
|
|
122
|
+
//@ts-ignore
|
|
123
|
+
'event.startDateTimeMs': values.startDateTime,
|
|
123
124
|
}));
|
|
124
125
|
}
|
|
125
126
|
}
|
|
@@ -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 {};
|
|
@@ -2,25 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
4
4
|
const schema_1 = require("@sprucelabs/schema");
|
|
5
|
-
const schema = (0, schema_1.buildSchema)({
|
|
6
|
-
id: 'repeatingSchema',
|
|
7
|
-
fields: {
|
|
8
|
-
repeat: {
|
|
9
|
-
type: 'text',
|
|
10
|
-
isRequired: true,
|
|
11
|
-
defaultValue: 'doesntRepeat',
|
|
12
|
-
},
|
|
13
|
-
repeatEvery: {
|
|
14
|
-
type: 'text',
|
|
15
|
-
},
|
|
16
|
-
repeatAmount: {
|
|
17
|
-
type: 'text',
|
|
18
|
-
},
|
|
19
|
-
repeatUntilMs: {
|
|
20
|
-
type: 'dateTime',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
5
|
class EventRepeatingToolViewController extends heartwood_view_controllers_1.AbstractViewController {
|
|
25
6
|
constructor(options) {
|
|
26
7
|
super(options);
|
|
@@ -48,14 +29,23 @@ class EventRepeatingToolViewController extends heartwood_view_controllers_1.Abst
|
|
|
48
29
|
return this.Controller('calendar.repeating-controls-list', {
|
|
49
30
|
repeating: Object.assign({}, this.getEvent()),
|
|
50
31
|
didChangeRepeating: async (value) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return (_a = this.updateContextHandler) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
54
|
-
event: Object.assign(Object.assign(Object.assign({}, this.removeExtraRepeatingFields(this.getEvent())), { repeats: undefined, interval: undefined, repeatsUntil: undefined, occurrences: undefined, daysOfWeek: undefined, daysOfMonth: undefined }), cleaned),
|
|
55
|
-
});
|
|
32
|
+
const pass = this.handleDidChangeRepeating(value);
|
|
33
|
+
return pass;
|
|
56
34
|
},
|
|
57
35
|
});
|
|
58
36
|
}
|
|
37
|
+
handleDidChangeRepeating(value) {
|
|
38
|
+
var _a;
|
|
39
|
+
const cleaned = this.removeExtraRepeatingFields(value);
|
|
40
|
+
const updates = Object.assign({ repeats: undefined, interval: undefined, repeatsUntil: undefined, occurrences: undefined, daysOfWeek: undefined, daysOfMonth: undefined }, cleaned);
|
|
41
|
+
const keyedUpdates = {};
|
|
42
|
+
Object.keys(updates).forEach((k) => {
|
|
43
|
+
//@ts-ignore
|
|
44
|
+
keyedUpdates[`event.${k}`] = updates[k];
|
|
45
|
+
});
|
|
46
|
+
const pass = (_a = this.updateContextHandler) === null || _a === void 0 ? void 0 : _a.call(this, Object.assign({}, keyedUpdates));
|
|
47
|
+
return pass;
|
|
48
|
+
}
|
|
59
49
|
removeExtraRepeatingFields(value) {
|
|
60
50
|
const cleaned = Object.assign({}, value);
|
|
61
51
|
delete cleaned.repeatAmount;
|
|
@@ -95,3 +85,22 @@ class EventRepeatingToolViewController extends heartwood_view_controllers_1.Abst
|
|
|
95
85
|
}
|
|
96
86
|
exports.default = EventRepeatingToolViewController;
|
|
97
87
|
EventRepeatingToolViewController.id = 'event-repeating-tool';
|
|
88
|
+
const schema = (0, schema_1.buildSchema)({
|
|
89
|
+
id: 'repeatingSchema',
|
|
90
|
+
fields: {
|
|
91
|
+
repeat: {
|
|
92
|
+
type: 'text',
|
|
93
|
+
isRequired: true,
|
|
94
|
+
defaultValue: 'doesntRepeat',
|
|
95
|
+
},
|
|
96
|
+
repeatEvery: {
|
|
97
|
+
type: 'text',
|
|
98
|
+
},
|
|
99
|
+
repeatAmount: {
|
|
100
|
+
type: 'text',
|
|
101
|
+
},
|
|
102
|
+
repeatUntilMs: {
|
|
103
|
+
type: 'dateTime',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
});
|
|
@@ -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 {};
|
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
4
4
|
const schema_1 = require("@sprucelabs/schema");
|
|
5
|
-
const formSchema = (0, schema_1.buildSchema)({
|
|
6
|
-
id: 'titleSubtitle',
|
|
7
|
-
fields: {
|
|
8
|
-
title: {
|
|
9
|
-
type: 'text',
|
|
10
|
-
isRequired: true,
|
|
11
|
-
label: 'Title',
|
|
12
|
-
},
|
|
13
|
-
subtitle: {
|
|
14
|
-
type: 'text',
|
|
15
|
-
label: 'Subtitle',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
5
|
class EventTitleToolViewController extends heartwood_view_controllers_1.AbstractViewController {
|
|
20
6
|
constructor(options) {
|
|
21
7
|
super(options);
|
|
@@ -37,7 +23,8 @@ class EventTitleToolViewController extends heartwood_view_controllers_1.Abstract
|
|
|
37
23
|
});
|
|
38
24
|
}
|
|
39
25
|
FormVc() {
|
|
40
|
-
var _a, _b
|
|
26
|
+
var _a, _b;
|
|
27
|
+
const timeBlock = (_b = (_a = this.getContext().event) === null || _a === void 0 ? void 0 : _a.timeBlocks) === null || _b === void 0 ? void 0 : _b[0];
|
|
41
28
|
return this.Controller('form', (0, heartwood_view_controllers_1.buildForm)({
|
|
42
29
|
schema: formSchema,
|
|
43
30
|
shouldShowSubmitControls: false,
|
|
@@ -48,16 +35,18 @@ class EventTitleToolViewController extends heartwood_view_controllers_1.Abstract
|
|
|
48
35
|
},
|
|
49
36
|
],
|
|
50
37
|
values: {
|
|
51
|
-
title:
|
|
52
|
-
subtitle:
|
|
38
|
+
title: timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.title,
|
|
39
|
+
subtitle: timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.subtitle,
|
|
53
40
|
},
|
|
54
41
|
}));
|
|
55
42
|
}
|
|
56
43
|
async handleChangeForm() {
|
|
57
|
-
const {
|
|
58
|
-
event.timeBlocks[0] = Object.assign(Object.assign({}, event.timeBlocks[0]), this.formVc.getValues());
|
|
44
|
+
const { title, subtitle } = this.formVc.getValues();
|
|
59
45
|
await this.updateContextHandler({
|
|
60
|
-
|
|
46
|
+
//@ts-ignore
|
|
47
|
+
'event.timeBlocks[0].title': title,
|
|
48
|
+
//@ts-ignore
|
|
49
|
+
'event.timeBlocks[0].subtitle': subtitle,
|
|
61
50
|
});
|
|
62
51
|
}
|
|
63
52
|
async handleUpdateContext(context) {
|
|
@@ -75,3 +64,17 @@ class EventTitleToolViewController extends heartwood_view_controllers_1.Abstract
|
|
|
75
64
|
}
|
|
76
65
|
exports.default = EventTitleToolViewController;
|
|
77
66
|
EventTitleToolViewController.id = 'event-title-card';
|
|
67
|
+
const formSchema = (0, schema_1.buildSchema)({
|
|
68
|
+
id: 'titleSubtitle',
|
|
69
|
+
fields: {
|
|
70
|
+
title: {
|
|
71
|
+
type: 'text',
|
|
72
|
+
isRequired: true,
|
|
73
|
+
label: 'Title',
|
|
74
|
+
},
|
|
75
|
+
subtitle: {
|
|
76
|
+
type: 'text',
|
|
77
|
+
label: 'Subtitle',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
@@ -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
|
+
}>;
|