@sprucelabs/spruce-calendar-components 26.0.21 → 26.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.d.ts +4 -2
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +15 -1
- package/build/esm/tools/EventDateTimeTool.vc.js +1 -0
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.d.ts +4 -2
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +13 -1
- package/build/tools/EventDateTimeTool.vc.js +1 -0
- package/package.json +1 -1
|
@@ -7,12 +7,13 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
7
7
|
protected sm: CalendarToolBeltStateMachine;
|
|
8
8
|
private toolBeltVc;
|
|
9
9
|
private vcs;
|
|
10
|
-
|
|
10
|
+
protected pendingContextUpdates: Partial<CalendarToolBeltContext>;
|
|
11
11
|
protected controlsVc: EventControlsCardViewController;
|
|
12
12
|
private isLoaded;
|
|
13
13
|
protected events: CalendarEventManager;
|
|
14
14
|
protected shouldLoadToolsRightAway: boolean;
|
|
15
15
|
private getPersonPromise?;
|
|
16
|
+
private lastEventId?;
|
|
16
17
|
constructor();
|
|
17
18
|
load(sm: CalendarToolBeltStateMachine): Promise<void>;
|
|
18
19
|
getIsLoaded(): boolean;
|
|
@@ -22,6 +23,7 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
22
23
|
protected get context(): CalendarToolBeltContext;
|
|
23
24
|
protected get event(): import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|
|
24
25
|
private deselectEvent;
|
|
26
|
+
private handleWillUpdateContext;
|
|
25
27
|
private handleDidUpdateContext;
|
|
26
28
|
protected getContextWithPendingChanges(): CalendarToolBeltContext;
|
|
27
29
|
clearPendingContextChanges(shouldEmitDidUpdate?: boolean): Promise<void>;
|
|
@@ -34,7 +36,7 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
34
36
|
private _getPersonFromEvent;
|
|
35
37
|
protected handleUpdateContextFromTool(updates: Partial<CalendarToolBeltContext>, fromToolId: string, options?: UpdateCalendarContextOptions): Promise<boolean>;
|
|
36
38
|
removeTool(id: string): void;
|
|
37
|
-
|
|
39
|
+
getPendingContextUpdates(): Partial<CalendarToolBeltContext>;
|
|
38
40
|
getVcForTool(toolId: string): CalendarTool | undefined;
|
|
39
41
|
getControlsVc(): EventControlsCardViewController;
|
|
40
42
|
destroy(): Promise<void>;
|
|
@@ -17,8 +17,10 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
17
17
|
this.isLoaded = false;
|
|
18
18
|
this.shouldLoadToolsRightAway = true;
|
|
19
19
|
this.handleDidUpdateContext = this.handleDidUpdateContext.bind(this);
|
|
20
|
+
this.handleWillUpdateContext = this.handleWillUpdateContext.bind(this);
|
|
20
21
|
}
|
|
21
22
|
load(sm) {
|
|
23
|
+
var _a;
|
|
22
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
25
|
this.sm = sm;
|
|
24
26
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
@@ -37,6 +39,8 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
37
39
|
position: 'bottom',
|
|
38
40
|
});
|
|
39
41
|
void this.sm.on('did-update-context', this.handleDidUpdateContext);
|
|
42
|
+
void this.sm.on('will-update-context', this.handleWillUpdateContext);
|
|
43
|
+
this.lastEventId = (_a = this.event) === null || _a === void 0 ? void 0 : _a.id;
|
|
40
44
|
});
|
|
41
45
|
}
|
|
42
46
|
getIsLoaded() {
|
|
@@ -75,9 +79,18 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
75
79
|
yield this.context.events.deselectEvent();
|
|
76
80
|
});
|
|
77
81
|
}
|
|
82
|
+
handleWillUpdateContext({ updates, }) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const { event } = updates;
|
|
85
|
+
if (event && this.lastEventId !== event.id) {
|
|
86
|
+
this.pendingContextUpdates = {};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
78
90
|
handleDidUpdateContext(skipToolWithId) {
|
|
79
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
92
|
const context = this.getContextWithPendingChanges();
|
|
93
|
+
const { event } = context;
|
|
81
94
|
if (!context.event) {
|
|
82
95
|
return;
|
|
83
96
|
}
|
|
@@ -87,6 +100,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
87
100
|
}
|
|
88
101
|
})));
|
|
89
102
|
this.controlsVc.handleUpdateContext();
|
|
103
|
+
this.lastEventId = event === null || event === void 0 ? void 0 : event.id;
|
|
90
104
|
});
|
|
91
105
|
}
|
|
92
106
|
getContextWithPendingChanges() {
|
|
@@ -204,7 +218,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
204
218
|
this.vcs = this.vcs.filter(({ toolId }) => id !== toolId);
|
|
205
219
|
this.toolBeltVc.removeTool(id);
|
|
206
220
|
}
|
|
207
|
-
|
|
221
|
+
getPendingContextUpdates() {
|
|
208
222
|
return this.pendingContextUpdates;
|
|
209
223
|
}
|
|
210
224
|
getVcForTool(toolId) {
|
|
@@ -131,6 +131,7 @@ class EventDateTimeToolViewController extends AbstractViewController {
|
|
|
131
131
|
}
|
|
132
132
|
handleUpdateContext(context) {
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
console.log('eventDateTime.handleUpdateContext', context.event.timeBlocks[0].title, context.event.startDateTimeMs, this.getContext().event.startDateTimeMs);
|
|
134
135
|
yield this.formVc.setValue('startDateTime', context.event.startDateTimeMs);
|
|
135
136
|
this.calendarVc.setSelectedDates([this.getSelectedDate()]);
|
|
136
137
|
});
|
|
@@ -7,12 +7,13 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
7
7
|
protected sm: CalendarToolBeltStateMachine;
|
|
8
8
|
private toolBeltVc;
|
|
9
9
|
private vcs;
|
|
10
|
-
|
|
10
|
+
protected pendingContextUpdates: Partial<CalendarToolBeltContext>;
|
|
11
11
|
protected controlsVc: EventControlsCardViewController;
|
|
12
12
|
private isLoaded;
|
|
13
13
|
protected events: CalendarEventManager;
|
|
14
14
|
protected shouldLoadToolsRightAway: boolean;
|
|
15
15
|
private getPersonPromise?;
|
|
16
|
+
private lastEventId?;
|
|
16
17
|
constructor();
|
|
17
18
|
load(sm: CalendarToolBeltStateMachine): Promise<void>;
|
|
18
19
|
getIsLoaded(): boolean;
|
|
@@ -22,6 +23,7 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
22
23
|
protected get context(): CalendarToolBeltContext;
|
|
23
24
|
protected get event(): import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|
|
24
25
|
private deselectEvent;
|
|
26
|
+
private handleWillUpdateContext;
|
|
25
27
|
private handleDidUpdateContext;
|
|
26
28
|
protected getContextWithPendingChanges(): CalendarToolBeltContext;
|
|
27
29
|
clearPendingContextChanges(shouldEmitDidUpdate?: boolean): Promise<void>;
|
|
@@ -34,7 +36,7 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
34
36
|
private _getPersonFromEvent;
|
|
35
37
|
protected handleUpdateContextFromTool(updates: Partial<CalendarToolBeltContext>, fromToolId: string, options?: UpdateCalendarContextOptions): Promise<boolean>;
|
|
36
38
|
removeTool(id: string): void;
|
|
37
|
-
|
|
39
|
+
getPendingContextUpdates(): Partial<CalendarToolBeltContext>;
|
|
38
40
|
getVcForTool(toolId: string): CalendarTool | undefined;
|
|
39
41
|
getControlsVc(): EventControlsCardViewController;
|
|
40
42
|
destroy(): Promise<void>;
|
|
@@ -13,8 +13,10 @@ class AbstractCalendarEventToolBeltState {
|
|
|
13
13
|
this.isLoaded = false;
|
|
14
14
|
this.shouldLoadToolsRightAway = true;
|
|
15
15
|
this.handleDidUpdateContext = this.handleDidUpdateContext.bind(this);
|
|
16
|
+
this.handleWillUpdateContext = this.handleWillUpdateContext.bind(this);
|
|
16
17
|
}
|
|
17
18
|
async load(sm) {
|
|
19
|
+
var _a;
|
|
18
20
|
this.sm = sm;
|
|
19
21
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
20
22
|
this.isLoaded = true;
|
|
@@ -32,6 +34,8 @@ class AbstractCalendarEventToolBeltState {
|
|
|
32
34
|
position: 'bottom',
|
|
33
35
|
});
|
|
34
36
|
void this.sm.on('did-update-context', this.handleDidUpdateContext);
|
|
37
|
+
void this.sm.on('will-update-context', this.handleWillUpdateContext);
|
|
38
|
+
this.lastEventId = (_a = this.event) === null || _a === void 0 ? void 0 : _a.id;
|
|
35
39
|
}
|
|
36
40
|
getIsLoaded() {
|
|
37
41
|
return this.isLoaded;
|
|
@@ -61,8 +65,15 @@ class AbstractCalendarEventToolBeltState {
|
|
|
61
65
|
async deselectEvent() {
|
|
62
66
|
await this.context.events.deselectEvent();
|
|
63
67
|
}
|
|
68
|
+
async handleWillUpdateContext({ updates, }) {
|
|
69
|
+
const { event } = updates;
|
|
70
|
+
if (event && this.lastEventId !== event.id) {
|
|
71
|
+
this.pendingContextUpdates = {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
64
74
|
async handleDidUpdateContext(skipToolWithId) {
|
|
65
75
|
const context = this.getContextWithPendingChanges();
|
|
76
|
+
const { event } = context;
|
|
66
77
|
if (!context.event) {
|
|
67
78
|
return;
|
|
68
79
|
}
|
|
@@ -72,6 +83,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
72
83
|
}
|
|
73
84
|
}));
|
|
74
85
|
this.controlsVc.handleUpdateContext();
|
|
86
|
+
this.lastEventId = event === null || event === void 0 ? void 0 : event.id;
|
|
75
87
|
}
|
|
76
88
|
getContextWithPendingChanges() {
|
|
77
89
|
return Object.assign({}, this.sm.getContext(this.pendingContextUpdates));
|
|
@@ -172,7 +184,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
172
184
|
this.vcs = this.vcs.filter(({ toolId }) => id !== toolId);
|
|
173
185
|
this.toolBeltVc.removeTool(id);
|
|
174
186
|
}
|
|
175
|
-
|
|
187
|
+
getPendingContextUpdates() {
|
|
176
188
|
return this.pendingContextUpdates;
|
|
177
189
|
}
|
|
178
190
|
getVcForTool(toolId) {
|
|
@@ -119,6 +119,7 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
|
|
|
119
119
|
}));
|
|
120
120
|
}
|
|
121
121
|
async handleUpdateContext(context) {
|
|
122
|
+
console.log('eventDateTime.handleUpdateContext', context.event.timeBlocks[0].title, context.event.startDateTimeMs, this.getContext().event.startDateTimeMs);
|
|
122
123
|
await this.formVc.setValue('startDateTime', context.event.startDateTimeMs);
|
|
123
124
|
this.calendarVc.setSelectedDates([this.getSelectedDate()]);
|
|
124
125
|
}
|