@sprucelabs/spruce-calendar-components 24.2.26 → 24.2.28

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.
@@ -222,13 +222,17 @@ class RootSkillViewController extends AbstractSkillViewController {
222
222
  }
223
223
  resetToRootState() {
224
224
  return __awaiter(this, void 0, void 0, function* () {
225
+ if (this.transitionPromise) {
226
+ return;
227
+ }
225
228
  this.toolBeltVc.close();
226
- this.transitionPromise = this.sm.transitionTo(this.toolBeltStates.root);
227
- yield this.transitionPromise;
228
- yield this.events.reset();
229
+ this.transitionPromise = this.transitionToRoot();
229
230
  this.makeDateSelectMatchSelectedDateFromCalendar();
230
231
  this.syncPeopleOnCalendar();
232
+ yield this.transitionPromise;
233
+ yield this.events.reset();
231
234
  yield this.calendarVc.deselectEvent();
235
+ delete this.transitionPromise;
232
236
  });
233
237
  }
234
238
  ToolBeltVc() {
@@ -290,6 +294,11 @@ class RootSkillViewController extends AbstractSkillViewController {
290
294
  handleDropEvent(id, updates) {
291
295
  return __awaiter(this, void 0, void 0, function* () {
292
296
  if (RootSkillViewController.shouldConfirmDrops) {
297
+ const event = this.events.getEvent(id);
298
+ if (!updates.startDateTimeMs ||
299
+ event.startDateTimeMs === updates.startDateTimeMs) {
300
+ return true;
301
+ }
293
302
  const pass = yield this.confirm({
294
303
  title: 'Did you mean to drag and drop this?',
295
304
  });
@@ -10,6 +10,7 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
10
10
  private calendarVc;
11
11
  constructor(options: ViewControllerOptions & CalendarToolOptions);
12
12
  private handleSelectDateFromCalendar;
13
+ private get event();
13
14
  private promptForNavigationPreference;
14
15
  private getSelectedDate;
15
16
  private CardVc;
@@ -25,16 +25,23 @@ class EventDateTimeToolViewController extends AbstractViewController {
25
25
  }
26
26
  handleSelectDateFromCalendar({ dateTimeMs, }) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
+ const { hour, minute, day, month } = this.dates.splitDate(this.event.startDateTimeMs);
29
+ const { day: newDay, month: newMonth } = this.dates.splitDate(dateTimeMs);
30
+ if (day === newDay && month === newMonth) {
31
+ return;
32
+ }
28
33
  const shouldBail = yield this.promptForNavigationPreference(dateTimeMs);
29
34
  if (shouldBail) {
30
35
  return;
31
36
  }
32
- const { hour, minute } = this.dates.splitDate(this.getContext().event.startDateTimeMs);
33
37
  const startDateTime = this.dates.setTimeOfDay(dateTimeMs, hour, minute, 0, 0);
34
38
  yield this.formVc.setValue('startDateTime', startDateTime);
35
39
  this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
36
40
  });
37
41
  }
42
+ get event() {
43
+ return this.getContext().event;
44
+ }
38
45
  promptForNavigationPreference(dateTimeMs) {
39
46
  return __awaiter(this, void 0, void 0, function* () {
40
47
  let shouldBail = false;
@@ -84,7 +91,7 @@ class EventDateTimeToolViewController extends AbstractViewController {
84
91
  });
85
92
  }
86
93
  getSelectedDate(dateTimeMs) {
87
- const { year, month, day } = this.dates.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
94
+ const { year, month, day } = this.dates.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.event.startDateTimeMs);
88
95
  return { year, month, day };
89
96
  }
90
97
  CardVc() {
@@ -118,7 +125,7 @@ class EventDateTimeToolViewController extends AbstractViewController {
118
125
  },
119
126
  ],
120
127
  values: {
121
- startDateTime: this.getContext().event.startDateTimeMs,
128
+ startDateTime: this.event.startDateTimeMs,
122
129
  },
123
130
  }));
124
131
  }
@@ -195,13 +195,17 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
195
195
  await this.resetToRootState();
196
196
  }
197
197
  async resetToRootState() {
198
+ if (this.transitionPromise) {
199
+ return;
200
+ }
198
201
  this.toolBeltVc.close();
199
- this.transitionPromise = this.sm.transitionTo(this.toolBeltStates.root);
200
- await this.transitionPromise;
201
- await this.events.reset();
202
+ this.transitionPromise = this.transitionToRoot();
202
203
  this.makeDateSelectMatchSelectedDateFromCalendar();
203
204
  this.syncPeopleOnCalendar();
205
+ await this.transitionPromise;
206
+ await this.events.reset();
204
207
  await this.calendarVc.deselectEvent();
208
+ delete this.transitionPromise;
205
209
  }
206
210
  ToolBeltVc() {
207
211
  return this.Controller('toolBelt', {
@@ -253,6 +257,11 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
253
257
  }
254
258
  async handleDropEvent(id, updates) {
255
259
  if (RootSkillViewController.shouldConfirmDrops) {
260
+ const event = this.events.getEvent(id);
261
+ if (!updates.startDateTimeMs ||
262
+ event.startDateTimeMs === updates.startDateTimeMs) {
263
+ return true;
264
+ }
256
265
  const pass = await this.confirm({
257
266
  title: 'Did you mean to drag and drop this?',
258
267
  });
@@ -10,6 +10,7 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
10
10
  private calendarVc;
11
11
  constructor(options: ViewControllerOptions & CalendarToolOptions);
12
12
  private handleSelectDateFromCalendar;
13
+ private get event();
13
14
  private promptForNavigationPreference;
14
15
  private getSelectedDate;
15
16
  private CardVc;
@@ -17,15 +17,22 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
17
17
  this.cardVc = this.CardVc();
18
18
  }
19
19
  async handleSelectDateFromCalendar({ dateTimeMs, }) {
20
+ const { hour, minute, day, month } = this.dates.splitDate(this.event.startDateTimeMs);
21
+ const { day: newDay, month: newMonth } = this.dates.splitDate(dateTimeMs);
22
+ if (day === newDay && month === newMonth) {
23
+ return;
24
+ }
20
25
  const shouldBail = await this.promptForNavigationPreference(dateTimeMs);
21
26
  if (shouldBail) {
22
27
  return;
23
28
  }
24
- const { hour, minute } = this.dates.splitDate(this.getContext().event.startDateTimeMs);
25
29
  const startDateTime = this.dates.setTimeOfDay(dateTimeMs, hour, minute, 0, 0);
26
30
  await this.formVc.setValue('startDateTime', startDateTime);
27
31
  this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
28
32
  }
33
+ get event() {
34
+ return this.getContext().event;
35
+ }
29
36
  async promptForNavigationPreference(dateTimeMs) {
30
37
  let shouldBail = false;
31
38
  const formattedDestination = this.dates.format(dateTimeMs, 'MMM do');
@@ -73,7 +80,7 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
73
80
  return shouldBail;
74
81
  }
75
82
  getSelectedDate(dateTimeMs) {
76
- const { year, month, day } = this.dates.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
83
+ const { year, month, day } = this.dates.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.event.startDateTimeMs);
77
84
  return { year, month, day };
78
85
  }
79
86
  CardVc() {
@@ -107,7 +114,7 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
107
114
  },
108
115
  ],
109
116
  values: {
110
- startDateTime: this.getContext().event.startDateTimeMs,
117
+ startDateTime: this.event.startDateTimeMs,
111
118
  },
112
119
  }));
113
120
  }
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.26",
4
+ "version": "24.2.28",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },