@sprucelabs/spruce-calendar-components 22.9.11 → 22.9.13

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.
@@ -59,7 +59,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
59
59
  load(options: SkillViewControllerLoadOptions<RootArgs>): Promise<void>;
60
60
  private setupCalendarEventListeners;
61
61
  private handleDidCancelEvent;
62
- private handleDidCreateOrUpdate;
62
+ private handleDidCreateOrUpdateRemoteEvent;
63
63
  private loadEventStore;
64
64
  private loadPeople;
65
65
  private loadScope;
@@ -327,8 +327,8 @@ export default class RootSkillViewController extends AbstractSkillViewController
327
327
  setupCalendarEventListeners() {
328
328
  return __awaiter(this, void 0, void 0, function* () {
329
329
  yield Promise.all([
330
- this.client.on('calendar.did-create-calendar-event::v2021_05_19', this.handleDidCreateOrUpdate.bind(this)),
331
- this.client.on('calendar.did-update-calendar-event::v2021_05_19', this.handleDidCreateOrUpdate.bind(this)),
330
+ this.client.on('calendar.did-create-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent.bind(this)),
331
+ this.client.on('calendar.did-update-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent.bind(this)),
332
332
  this.client.on('calendar.did-cancel-calendar-event::v2021_05_19', this.handleDidCancelEvent.bind(this)),
333
333
  ]);
334
334
  });
@@ -341,7 +341,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
341
341
  }
342
342
  });
343
343
  }
344
- handleDidCreateOrUpdate({ payload, target, }) {
344
+ handleDidCreateOrUpdateRemoteEvent({ payload, target, }) {
345
345
  return __awaiter(this, void 0, void 0, function* () {
346
346
  const { calendarEvent } = payload;
347
347
  const { locationId } = target;
@@ -1,6 +1,5 @@
1
1
  import { AbstractViewController, CalendarViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { CalendarTool, CalendarToolBeltContext, CalendarToolOptions } from '../types/calendar.types';
3
- declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
4
3
  export default class EventDateTimeToolViewController extends AbstractViewController<Card> implements CalendarTool {
5
4
  static id: string;
6
5
  shouldPersistContextChangesImmediately: boolean;
@@ -11,6 +10,7 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
11
10
  private calendarVc;
12
11
  constructor(options: ViewControllerOptions & CalendarToolOptions);
13
12
  private handleSelectDateFromCalendar;
13
+ private promptForNavigationPreference;
14
14
  private getSelectedDate;
15
15
  private CardVc;
16
16
  getCalendarVc(): CalendarViewController;
@@ -38,4 +38,5 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
38
38
  }, false>;
39
39
  render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
40
40
  }
41
+ declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
41
42
  export {};
@@ -10,15 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { dateUtil } from '@sprucelabs/calendar-utils';
11
11
  import { AbstractViewController, buildForm, } from '@sprucelabs/heartwood-view-controllers';
12
12
  import { buildSchema } from '@sprucelabs/schema';
13
- const schema = buildSchema({
14
- id: ' startDateTime',
15
- fields: {
16
- startDateTime: {
17
- type: 'dateTime',
18
- isRequired: true,
19
- },
20
- },
21
- });
22
13
  export default class EventDateTimeToolViewController extends AbstractViewController {
23
14
  constructor(options) {
24
15
  super(options);
@@ -34,6 +25,17 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
34
25
  this.cardVc = this.CardVc();
35
26
  }
36
27
  handleSelectDateFromCalendar({ dateTimeMs, }) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ let shouldBail = yield this.promptForNavigationPreference(dateTimeMs);
30
+ if (shouldBail) {
31
+ return;
32
+ }
33
+ const { hour, minute } = dateUtil.splitDate(this.getContext().event.startDateTimeMs);
34
+ yield this.formVc.setValue('startDateTime', dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
35
+ this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
36
+ });
37
+ }
38
+ promptForNavigationPreference(dateTimeMs) {
37
39
  return __awaiter(this, void 0, void 0, function* () {
38
40
  let shouldBail = false;
39
41
  const formattedDestination = dateUtil.format(dateTimeMs, 'MMM do');
@@ -78,16 +80,11 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
78
80
  },
79
81
  });
80
82
  yield dlg.wait();
81
- if (shouldBail) {
82
- return;
83
- }
84
- const { hour, minute } = dateUtil.splitDate(this.getContext().event.startDateTimeMs);
85
- yield this.formVc.setValue('startDateTime', dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
86
- this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
83
+ return shouldBail;
87
84
  });
88
85
  }
89
86
  getSelectedDate(dateTimeMs) {
90
- const { year, month, day } = dateUtil.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
87
+ const { year, month, day } = this.dates.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
91
88
  return { year, month, day };
92
89
  }
93
90
  CardVc() {
@@ -155,3 +152,12 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
155
152
  }
156
153
  }
157
154
  EventDateTimeToolViewController.id = 'event-date-time-tool';
155
+ const schema = buildSchema({
156
+ id: ' startDateTime',
157
+ fields: {
158
+ startDateTime: {
159
+ type: 'dateTime',
160
+ isRequired: true,
161
+ },
162
+ },
163
+ });
@@ -59,7 +59,7 @@ export default class RootSkillViewController extends AbstractSkillViewController
59
59
  load(options: SkillViewControllerLoadOptions<RootArgs>): Promise<void>;
60
60
  private setupCalendarEventListeners;
61
61
  private handleDidCancelEvent;
62
- private handleDidCreateOrUpdate;
62
+ private handleDidCreateOrUpdateRemoteEvent;
63
63
  private loadEventStore;
64
64
  private loadPeople;
65
65
  private loadScope;
@@ -286,8 +286,8 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
286
286
  }
287
287
  async setupCalendarEventListeners() {
288
288
  await Promise.all([
289
- this.client.on('calendar.did-create-calendar-event::v2021_05_19', this.handleDidCreateOrUpdate.bind(this)),
290
- this.client.on('calendar.did-update-calendar-event::v2021_05_19', this.handleDidCreateOrUpdate.bind(this)),
289
+ this.client.on('calendar.did-create-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent.bind(this)),
290
+ this.client.on('calendar.did-update-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent.bind(this)),
291
291
  this.client.on('calendar.did-cancel-calendar-event::v2021_05_19', this.handleDidCancelEvent.bind(this)),
292
292
  ]);
293
293
  }
@@ -297,7 +297,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
297
297
  await this.events.removeEvent(calendarEventId, { shouldPersist: false });
298
298
  }
299
299
  }
300
- async handleDidCreateOrUpdate({ payload, target, }) {
300
+ async handleDidCreateOrUpdateRemoteEvent({ payload, target, }) {
301
301
  const { calendarEvent } = payload;
302
302
  const { locationId } = target;
303
303
  if (calendarEvent.style !== 'draft' && locationId === this.locationId) {
@@ -1,6 +1,5 @@
1
1
  import { AbstractViewController, CalendarViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { CalendarTool, CalendarToolBeltContext, CalendarToolOptions } from '../types/calendar.types';
3
- declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
4
3
  export default class EventDateTimeToolViewController extends AbstractViewController<Card> implements CalendarTool {
5
4
  static id: string;
6
5
  shouldPersistContextChangesImmediately: boolean;
@@ -11,6 +10,7 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
11
10
  private calendarVc;
12
11
  constructor(options: ViewControllerOptions & CalendarToolOptions);
13
12
  private handleSelectDateFromCalendar;
13
+ private promptForNavigationPreference;
14
14
  private getSelectedDate;
15
15
  private CardVc;
16
16
  getCalendarVc(): CalendarViewController;
@@ -38,4 +38,5 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
38
38
  }, false>;
39
39
  render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
40
40
  }
41
+ declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
41
42
  export {};
@@ -3,15 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const calendar_utils_1 = require("@sprucelabs/calendar-utils");
4
4
  const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
5
5
  const schema_1 = require("@sprucelabs/schema");
6
- const schema = (0, schema_1.buildSchema)({
7
- id: ' startDateTime',
8
- fields: {
9
- startDateTime: {
10
- type: 'dateTime',
11
- isRequired: true,
12
- },
13
- },
14
- });
15
6
  class EventDateTimeToolViewController extends heartwood_view_controllers_1.AbstractViewController {
16
7
  constructor(options) {
17
8
  super(options);
@@ -27,6 +18,15 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
27
18
  this.cardVc = this.CardVc();
28
19
  }
29
20
  async handleSelectDateFromCalendar({ dateTimeMs, }) {
21
+ let shouldBail = await this.promptForNavigationPreference(dateTimeMs);
22
+ if (shouldBail) {
23
+ return;
24
+ }
25
+ const { hour, minute } = calendar_utils_1.dateUtil.splitDate(this.getContext().event.startDateTimeMs);
26
+ await this.formVc.setValue('startDateTime', calendar_utils_1.dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
27
+ this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
28
+ }
29
+ async promptForNavigationPreference(dateTimeMs) {
30
30
  let shouldBail = false;
31
31
  const formattedDestination = calendar_utils_1.dateUtil.format(dateTimeMs, 'MMM do');
32
32
  const dlg = this.renderInDialog({
@@ -70,15 +70,10 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
70
70
  },
71
71
  });
72
72
  await dlg.wait();
73
- if (shouldBail) {
74
- return;
75
- }
76
- const { hour, minute } = calendar_utils_1.dateUtil.splitDate(this.getContext().event.startDateTimeMs);
77
- await this.formVc.setValue('startDateTime', calendar_utils_1.dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
78
- this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
73
+ return shouldBail;
79
74
  }
80
75
  getSelectedDate(dateTimeMs) {
81
- const { year, month, day } = calendar_utils_1.dateUtil.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
76
+ const { year, month, day } = this.dates.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
82
77
  return { year, month, day };
83
78
  }
84
79
  CardVc() {
@@ -143,3 +138,12 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
143
138
  }
144
139
  exports.default = EventDateTimeToolViewController;
145
140
  EventDateTimeToolViewController.id = 'event-date-time-tool';
141
+ const schema = (0, schema_1.buildSchema)({
142
+ id: ' startDateTime',
143
+ fields: {
144
+ startDateTime: {
145
+ type: 'dateTime',
146
+ isRequired: true,
147
+ },
148
+ },
149
+ });
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": "22.9.11",
4
+ "version": "22.9.13",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },