@sprucelabs/spruce-calendar-components 22.10.12 → 22.10.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.
@@ -74,11 +74,14 @@ export default class RootSkillViewController extends AbstractSkillViewController
74
74
  return sm;
75
75
  }
76
76
  handleCancelEvent(eventId) {
77
+ var _a;
77
78
  return __awaiter(this, void 0, void 0, function* () {
78
- const confirm = yield this.confirm({
79
- title: 'Cancel?',
80
- message: `You wanna cancel this?`,
81
- });
79
+ const event = this.events.getEvent(eventId);
80
+ const confirm = ((_a = event.totalInRepeating) !== null && _a !== void 0 ? _a : 0) > 0 ||
81
+ (yield this.confirm({
82
+ title: 'Cancel?',
83
+ message: `You wanna cancel this?`,
84
+ }));
82
85
  if (confirm) {
83
86
  yield this.resetToRootState();
84
87
  yield this.events.cancelEvent(eventId);
@@ -99,10 +99,11 @@ export default class CalendarEventManager {
99
99
  private clearPersistRepeatingOptions;
100
100
  getIsLoaded(): boolean;
101
101
  hasEvent(id: string): boolean;
102
- optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent): Promise<boolean>;
102
+ optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent, action?: RepeatingUpdateAction): Promise<boolean>;
103
103
  }
104
104
  export declare type EventManagerCalendarVc = Pick<CalendarViewController, 'replaceEventsInRange' | 'mixinEvents' | 'removeEvent' | 'addEvent' | 'hasEvent' | 'updateEvent' | 'setShifts' | 'getShifts' | 'getEvent' | 'getPeople' | 'setControllerForEventType' | 'setRemoteStore' | 'getSelectedEvent' | 'selectEvent' | 'deselectEvent' | 'removeEvents'>;
105
105
  declare type EventManagerRemoteViewControllerFactory = Pick<RemoteViewControllerFactory, 'fetchRemoteController'>;
106
+ export declare type RepeatingUpdateAction = 'update' | 'cancel';
106
107
  export interface CalendarEventManagerOptions {
107
108
  calendarVc: EventManagerCalendarVc;
108
109
  events: RemoteEventStore;
@@ -110,8 +111,9 @@ export interface CalendarEventManagerOptions {
110
111
  sm: CalendarToolBeltStateMachine;
111
112
  dates: DateUtil;
112
113
  preferences: RemotePreferencesStore;
113
- askForUpdateStrategy: (event: UpdateEvent) => Promise<UpdateRepeatingStrategyWithCancel>;
114
+ askForUpdateStrategy: AskForUpdateStrategyHandler;
114
115
  }
116
+ declare type AskForUpdateStrategyHandler = (event: UpdateEvent, action: RepeatingUpdateAction) => Promise<UpdateRepeatingStrategyWithCancel>;
115
117
  export declare type SavedEvent = Partial<CalendarEvent> & {
116
118
  id: string;
117
119
  };
@@ -150,7 +150,7 @@ export default class CalendarEventManager {
150
150
  const { shouldPersist = true } = options !== null && options !== void 0 ? options : {};
151
151
  const event = this.calendarVc.getEvent(id);
152
152
  if (shouldPersist) {
153
- const accepted = yield this.optionallyAskForUpdateRepeatingStrategy(event);
153
+ const accepted = yield this.optionallyAskForUpdateRepeatingStrategy(event, 'cancel');
154
154
  if (!accepted) {
155
155
  return;
156
156
  }
@@ -372,7 +372,7 @@ export default class CalendarEventManager {
372
372
  hasEvent(id) {
373
373
  return !!this.allEvents.find((e) => e.id === id);
374
374
  }
375
- optionallyAskForUpdateRepeatingStrategy(event) {
375
+ optionallyAskForUpdateRepeatingStrategy(event, action = 'update') {
376
376
  var _a;
377
377
  return __awaiter(this, void 0, void 0, function* () {
378
378
  if (!event.id) {
@@ -380,7 +380,7 @@ export default class CalendarEventManager {
380
380
  }
381
381
  const cleaned = normalizeSchemaValues(calendarEventSchema, event, {});
382
382
  if (((_a = cleaned.totalInRepeating) !== null && _a !== void 0 ? _a : 0) > 1) {
383
- let strategy = yield this.askForUpdateStrategy(cleaned);
383
+ let strategy = yield this.askForUpdateStrategy(cleaned, action);
384
384
  if (strategy === 'cancel') {
385
385
  return false;
386
386
  }
@@ -70,10 +70,13 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
70
70
  return sm;
71
71
  }
72
72
  async handleCancelEvent(eventId) {
73
- const confirm = await this.confirm({
74
- title: 'Cancel?',
75
- message: `You wanna cancel this?`,
76
- });
73
+ var _a;
74
+ const event = this.events.getEvent(eventId);
75
+ const confirm = ((_a = event.totalInRepeating) !== null && _a !== void 0 ? _a : 0) > 0 ||
76
+ (await this.confirm({
77
+ title: 'Cancel?',
78
+ message: `You wanna cancel this?`,
79
+ }));
77
80
  if (confirm) {
78
81
  await this.resetToRootState();
79
82
  await this.events.cancelEvent(eventId);
@@ -99,10 +99,11 @@ export default class CalendarEventManager {
99
99
  private clearPersistRepeatingOptions;
100
100
  getIsLoaded(): boolean;
101
101
  hasEvent(id: string): boolean;
102
- optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent): Promise<boolean>;
102
+ optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent, action?: RepeatingUpdateAction): Promise<boolean>;
103
103
  }
104
104
  export declare type EventManagerCalendarVc = Pick<CalendarViewController, 'replaceEventsInRange' | 'mixinEvents' | 'removeEvent' | 'addEvent' | 'hasEvent' | 'updateEvent' | 'setShifts' | 'getShifts' | 'getEvent' | 'getPeople' | 'setControllerForEventType' | 'setRemoteStore' | 'getSelectedEvent' | 'selectEvent' | 'deselectEvent' | 'removeEvents'>;
105
105
  declare type EventManagerRemoteViewControllerFactory = Pick<RemoteViewControllerFactory, 'fetchRemoteController'>;
106
+ export declare type RepeatingUpdateAction = 'update' | 'cancel';
106
107
  export interface CalendarEventManagerOptions {
107
108
  calendarVc: EventManagerCalendarVc;
108
109
  events: RemoteEventStore;
@@ -110,8 +111,9 @@ export interface CalendarEventManagerOptions {
110
111
  sm: CalendarToolBeltStateMachine;
111
112
  dates: DateUtil;
112
113
  preferences: RemotePreferencesStore;
113
- askForUpdateStrategy: (event: UpdateEvent) => Promise<UpdateRepeatingStrategyWithCancel>;
114
+ askForUpdateStrategy: AskForUpdateStrategyHandler;
114
115
  }
116
+ declare type AskForUpdateStrategyHandler = (event: UpdateEvent, action: RepeatingUpdateAction) => Promise<UpdateRepeatingStrategyWithCancel>;
115
117
  export declare type SavedEvent = Partial<CalendarEvent> & {
116
118
  id: string;
117
119
  };
@@ -135,7 +135,7 @@ class CalendarEventManager {
135
135
  const { shouldPersist = true } = options !== null && options !== void 0 ? options : {};
136
136
  const event = this.calendarVc.getEvent(id);
137
137
  if (shouldPersist) {
138
- const accepted = await this.optionallyAskForUpdateRepeatingStrategy(event);
138
+ const accepted = await this.optionallyAskForUpdateRepeatingStrategy(event, 'cancel');
139
139
  if (!accepted) {
140
140
  return;
141
141
  }
@@ -328,14 +328,14 @@ class CalendarEventManager {
328
328
  hasEvent(id) {
329
329
  return !!this.allEvents.find((e) => e.id === id);
330
330
  }
331
- async optionallyAskForUpdateRepeatingStrategy(event) {
331
+ async optionallyAskForUpdateRepeatingStrategy(event, action = 'update') {
332
332
  var _a;
333
333
  if (!event.id) {
334
334
  return true;
335
335
  }
336
336
  const cleaned = (0, schema_1.normalizeSchemaValues)(heartwood_view_controllers_1.calendarEventSchema, event, {});
337
337
  if (((_a = cleaned.totalInRepeating) !== null && _a !== void 0 ? _a : 0) > 1) {
338
- let strategy = await this.askForUpdateStrategy(cleaned);
338
+ let strategy = await this.askForUpdateStrategy(cleaned, action);
339
339
  if (strategy === 'cancel') {
340
340
  return false;
341
341
  }
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.10.12",
4
+ "version": "22.10.13",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },