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