@sprucelabs/spruce-calendar-components 25.2.9 → 25.2.10
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 +14 -10
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.d.ts +4 -2
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +14 -10
- package/package.json +1 -1
|
@@ -14,10 +14,12 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
14
14
|
getIsLoaded(): boolean;
|
|
15
15
|
protected loadRemoteCards(): Promise<void>;
|
|
16
16
|
protected handleClickSave(): Promise<void>;
|
|
17
|
-
protected handleClickCancel(
|
|
17
|
+
protected handleClickCancel(): Promise<boolean | void>;
|
|
18
|
+
protected get context(): CalendarToolBeltContext;
|
|
19
|
+
protected get event(): import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|
|
18
20
|
private deselectEvent;
|
|
19
21
|
private handleDidUpdateContext;
|
|
20
|
-
protected
|
|
22
|
+
protected getContextWithPendingChanges(): CalendarToolBeltContext;
|
|
21
23
|
clearPendingContextChanges(shouldEmitDidUpdate?: boolean): Promise<void>;
|
|
22
24
|
addTool(options: AddToolOptions): Promise<CalendarTool>;
|
|
23
25
|
protected buildVcConstructorOptions(id: string): CalendarToolOptions;
|
|
@@ -22,7 +22,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
22
22
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
23
23
|
this.isLoaded = true;
|
|
24
24
|
this.controlsVc = sm.Controller('calendar.event-controls-card', Object.assign(Object.assign({ onCancel: this.clearPendingContextChanges.bind(this), onSave: this.handleClickSave.bind(this) }, this.buildVcConstructorOptions('controls')), { onCancelEvent: this.handleClickCancel.bind(this) }));
|
|
25
|
-
this.events =
|
|
25
|
+
this.events = this.context.events;
|
|
26
26
|
this.events.setUpdateContextHandler((updates) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
return this.handleUpdateContextFromTool(updates, 'eventManager', {
|
|
28
28
|
shouldPersistContextChangesImmediately: true,
|
|
@@ -58,28 +58,33 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
58
58
|
yield this.deselectEvent();
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
handleClickCancel(
|
|
61
|
+
handleClickCancel() {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return this.
|
|
63
|
+
return this.context.cancelEvent(this.event.id);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
get context() {
|
|
67
|
+
return this.sm.getContext();
|
|
68
|
+
}
|
|
69
|
+
get event() {
|
|
70
|
+
return this.context.event;
|
|
71
|
+
}
|
|
66
72
|
deselectEvent() {
|
|
67
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
|
|
69
|
-
yield events.deselectEvent();
|
|
74
|
+
yield this.context.events.deselectEvent();
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
77
|
handleDidUpdateContext(skipToolWithId) {
|
|
73
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
79
|
yield Promise.all(this.vcs.map(({ vc, toolId }) => __awaiter(this, void 0, void 0, function* () {
|
|
75
80
|
if (toolId !== skipToolWithId) {
|
|
76
|
-
yield vc.handleUpdateContext(this.
|
|
81
|
+
yield vc.handleUpdateContext(this.getContextWithPendingChanges());
|
|
77
82
|
}
|
|
78
83
|
})));
|
|
79
84
|
this.controlsVc.handleUpdateContext();
|
|
80
85
|
});
|
|
81
86
|
}
|
|
82
|
-
|
|
87
|
+
getContextWithPendingChanges() {
|
|
83
88
|
return Object.assign({}, this.sm.getContext(this.pendingContextUpdates));
|
|
84
89
|
}
|
|
85
90
|
clearPendingContextChanges(shouldEmitDidUpdate = true) {
|
|
@@ -105,7 +110,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
105
110
|
buildVcConstructorOptions(id) {
|
|
106
111
|
return {
|
|
107
112
|
updateContext: (updates, options) => this.handleUpdateContextFromTool(updates, id, options),
|
|
108
|
-
getContext: () => this.
|
|
113
|
+
getContext: () => this.getContextWithPendingChanges(),
|
|
109
114
|
getPersonFromEvent: () => this.getPersonFromEvent(),
|
|
110
115
|
getHasPendingContextChanges: () => Object.keys(this.pendingContextUpdates).length > 0,
|
|
111
116
|
};
|
|
@@ -128,8 +133,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
128
133
|
getPersonFromEvent() {
|
|
129
134
|
var _a;
|
|
130
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
const
|
|
132
|
-
const id = event.target.personId;
|
|
136
|
+
const id = this.event.target.personId;
|
|
133
137
|
try {
|
|
134
138
|
const client = yield this.sm.connectToApi();
|
|
135
139
|
const [{ person }] = yield client.emitAndFlattenResponses('get-person::v2020_12_25', {
|
|
@@ -14,10 +14,12 @@ export default abstract class AbstractCalendarEventToolBeltState implements Tool
|
|
|
14
14
|
getIsLoaded(): boolean;
|
|
15
15
|
protected loadRemoteCards(): Promise<void>;
|
|
16
16
|
protected handleClickSave(): Promise<void>;
|
|
17
|
-
protected handleClickCancel(
|
|
17
|
+
protected handleClickCancel(): Promise<boolean | void>;
|
|
18
|
+
protected get context(): CalendarToolBeltContext;
|
|
19
|
+
protected get event(): import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|
|
18
20
|
private deselectEvent;
|
|
19
21
|
private handleDidUpdateContext;
|
|
20
|
-
protected
|
|
22
|
+
protected getContextWithPendingChanges(): CalendarToolBeltContext;
|
|
21
23
|
clearPendingContextChanges(shouldEmitDidUpdate?: boolean): Promise<void>;
|
|
22
24
|
addTool(options: AddToolOptions): Promise<CalendarTool>;
|
|
23
25
|
protected buildVcConstructorOptions(id: string): CalendarToolOptions;
|
|
@@ -17,7 +17,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
17
17
|
this.toolBeltVc = sm.getToolBeltVc();
|
|
18
18
|
this.isLoaded = true;
|
|
19
19
|
this.controlsVc = sm.Controller('calendar.event-controls-card', Object.assign(Object.assign({ onCancel: this.clearPendingContextChanges.bind(this), onSave: this.handleClickSave.bind(this) }, this.buildVcConstructorOptions('controls')), { onCancelEvent: this.handleClickCancel.bind(this) }));
|
|
20
|
-
this.events =
|
|
20
|
+
this.events = this.context.events;
|
|
21
21
|
this.events.setUpdateContextHandler(async (updates) => {
|
|
22
22
|
return this.handleUpdateContextFromTool(updates, 'eventManager', {
|
|
23
23
|
shouldPersistContextChangesImmediately: true,
|
|
@@ -48,22 +48,27 @@ class AbstractCalendarEventToolBeltState {
|
|
|
48
48
|
await this.sm.updateContext(Object.assign({}, updates));
|
|
49
49
|
await this.deselectEvent();
|
|
50
50
|
}
|
|
51
|
-
async handleClickCancel(
|
|
52
|
-
return this.
|
|
51
|
+
async handleClickCancel() {
|
|
52
|
+
return this.context.cancelEvent(this.event.id);
|
|
53
|
+
}
|
|
54
|
+
get context() {
|
|
55
|
+
return this.sm.getContext();
|
|
56
|
+
}
|
|
57
|
+
get event() {
|
|
58
|
+
return this.context.event;
|
|
53
59
|
}
|
|
54
60
|
async deselectEvent() {
|
|
55
|
-
|
|
56
|
-
await events.deselectEvent();
|
|
61
|
+
await this.context.events.deselectEvent();
|
|
57
62
|
}
|
|
58
63
|
async handleDidUpdateContext(skipToolWithId) {
|
|
59
64
|
await Promise.all(this.vcs.map(async ({ vc, toolId }) => {
|
|
60
65
|
if (toolId !== skipToolWithId) {
|
|
61
|
-
await vc.handleUpdateContext(this.
|
|
66
|
+
await vc.handleUpdateContext(this.getContextWithPendingChanges());
|
|
62
67
|
}
|
|
63
68
|
}));
|
|
64
69
|
this.controlsVc.handleUpdateContext();
|
|
65
70
|
}
|
|
66
|
-
|
|
71
|
+
getContextWithPendingChanges() {
|
|
67
72
|
return Object.assign({}, this.sm.getContext(this.pendingContextUpdates));
|
|
68
73
|
}
|
|
69
74
|
async clearPendingContextChanges(shouldEmitDidUpdate = true) {
|
|
@@ -85,7 +90,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
85
90
|
buildVcConstructorOptions(id) {
|
|
86
91
|
return {
|
|
87
92
|
updateContext: (updates, options) => this.handleUpdateContextFromTool(updates, id, options),
|
|
88
|
-
getContext: () => this.
|
|
93
|
+
getContext: () => this.getContextWithPendingChanges(),
|
|
89
94
|
getPersonFromEvent: () => this.getPersonFromEvent(),
|
|
90
95
|
getHasPendingContextChanges: () => Object.keys(this.pendingContextUpdates).length > 0,
|
|
91
96
|
};
|
|
@@ -105,8 +110,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
105
110
|
}
|
|
106
111
|
async getPersonFromEvent() {
|
|
107
112
|
var _a;
|
|
108
|
-
const
|
|
109
|
-
const id = event.target.personId;
|
|
113
|
+
const id = this.event.target.personId;
|
|
110
114
|
try {
|
|
111
115
|
const client = await this.sm.connectToApi();
|
|
112
116
|
const [{ person }] = await client.emitAndFlattenResponses('get-person::v2020_12_25', {
|