@sprucelabs/spruce-calendar-components 24.2.20 → 24.2.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.
@@ -25,6 +25,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
25
25
  protected preferences: RemotePreferencesStore;
26
26
  protected people: CalendarPeopleManager;
27
27
  protected remoteVc: RemoteViewControllerFactory;
28
+ protected draftEvent?: CalendarEvent;
28
29
  constructor(options: ViewControllerOptions);
29
30
  getScope: () => ScopeFlag[];
30
31
  private createToolBeltStates;
@@ -48,6 +49,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
48
49
  private handleDeselectEvent;
49
50
  protected resetToRootState(): Promise<void>;
50
51
  private ToolBeltVc;
52
+ private handleCloseToolBelt;
51
53
  private handleClickEvent;
52
54
  private handleDraftEventAdded;
53
55
  private handleEventSwapped;
@@ -228,24 +228,32 @@ class RootSkillViewController extends AbstractSkillViewController {
228
228
  yield this.events.reset();
229
229
  this.makeDateSelectMatchSelectedDateFromCalendar();
230
230
  this.syncPeopleOnCalendar();
231
+ yield this.calendarVc.deselectEvent();
231
232
  });
232
233
  }
233
234
  ToolBeltVc() {
234
235
  return this.Controller('toolBelt', {
235
- onCloseToolBelt: ({ isDrawer }) => __awaiter(this, void 0, void 0, function* () {
236
- if (!isDrawer) {
237
- yield this.events.deselectEvent();
238
- }
239
- }),
236
+ onCloseToolBelt: this.handleCloseToolBelt.bind(this),
240
237
  shouldRenderAllToolsAtOnce: true,
241
238
  });
242
239
  }
240
+ handleCloseToolBelt({ isDrawer }) {
241
+ return __awaiter(this, void 0, void 0, function* () {
242
+ if (!isDrawer) {
243
+ yield this.resetToRootState();
244
+ if (this.draftEvent) {
245
+ const event = this.draftEvent;
246
+ this.draftEvent = undefined;
247
+ yield this.events.cancelEvent(event.id);
248
+ }
249
+ }
250
+ });
251
+ }
243
252
  handleClickEvent(options) {
244
253
  var _a, _b;
245
254
  return __awaiter(this, void 0, void 0, function* () {
246
255
  const { event } = options;
247
256
  yield this.events.selectEvent(event.id);
248
- console.log('handleClickEvent', event);
249
257
  this.toolBeltVc.open({ shouldStayOpen: true });
250
258
  try {
251
259
  if (!event.eventTypeSlug) {
@@ -267,6 +275,7 @@ class RootSkillViewController extends AbstractSkillViewController {
267
275
  handleDraftEventAdded(event) {
268
276
  return __awaiter(this, void 0, void 0, function* () {
269
277
  yield this.events.addDraftEvent(event, !event.eventTypeSlug);
278
+ this.draftEvent = event;
270
279
  if (!event.eventTypeSlug) {
271
280
  this.toolBeltVc.open({ shouldStayOpen: true });
272
281
  yield this.sm.transitionTo(this.toolBeltStates.prerequisites);
@@ -25,6 +25,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
25
25
  protected preferences: RemotePreferencesStore;
26
26
  protected people: CalendarPeopleManager;
27
27
  protected remoteVc: RemoteViewControllerFactory;
28
+ protected draftEvent?: CalendarEvent;
28
29
  constructor(options: ViewControllerOptions);
29
30
  getScope: () => ScopeFlag[];
30
31
  private createToolBeltStates;
@@ -48,6 +49,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
48
49
  private handleDeselectEvent;
49
50
  protected resetToRootState(): Promise<void>;
50
51
  private ToolBeltVc;
52
+ private handleCloseToolBelt;
51
53
  private handleClickEvent;
52
54
  private handleDraftEventAdded;
53
55
  private handleEventSwapped;
@@ -201,22 +201,28 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
201
201
  await this.events.reset();
202
202
  this.makeDateSelectMatchSelectedDateFromCalendar();
203
203
  this.syncPeopleOnCalendar();
204
+ await this.calendarVc.deselectEvent();
204
205
  }
205
206
  ToolBeltVc() {
206
207
  return this.Controller('toolBelt', {
207
- onCloseToolBelt: async ({ isDrawer }) => {
208
- if (!isDrawer) {
209
- await this.events.deselectEvent();
210
- }
211
- },
208
+ onCloseToolBelt: this.handleCloseToolBelt.bind(this),
212
209
  shouldRenderAllToolsAtOnce: true,
213
210
  });
214
211
  }
212
+ async handleCloseToolBelt({ isDrawer }) {
213
+ if (!isDrawer) {
214
+ await this.resetToRootState();
215
+ if (this.draftEvent) {
216
+ const event = this.draftEvent;
217
+ this.draftEvent = undefined;
218
+ await this.events.cancelEvent(event.id);
219
+ }
220
+ }
221
+ }
215
222
  async handleClickEvent(options) {
216
223
  var _a, _b;
217
224
  const { event } = options;
218
225
  await this.events.selectEvent(event.id);
219
- console.log('handleClickEvent', event);
220
226
  this.toolBeltVc.open({ shouldStayOpen: true });
221
227
  try {
222
228
  if (!event.eventTypeSlug) {
@@ -236,6 +242,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
236
242
  }
237
243
  async handleDraftEventAdded(event) {
238
244
  await this.events.addDraftEvent(event, !event.eventTypeSlug);
245
+ this.draftEvent = event;
239
246
  if (!event.eventTypeSlug) {
240
247
  this.toolBeltVc.open({ shouldStayOpen: true });
241
248
  await this.sm.transitionTo(this.toolBeltStates.prerequisites);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-calendar-components",
3
3
  "description": "Calendar components for working with calendars and Sprucebot.",
4
- "version": "24.2.20",
4
+ "version": "24.2.22",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },