@sprucelabs/spruce-calendar-components 25.6.0 → 25.6.1
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/calendar/CalendarEventManager.d.ts +6 -5
- package/build/calendar/CalendarEventManager.js +7 -0
- package/build/esm/calendar/CalendarEventManager.d.ts +6 -5
- package/build/esm/calendar/CalendarEventManager.js +7 -0
- package/build/esm/stores/RemoteEventStore.js +2 -20
- package/build/stores/RemoteEventStore.js +2 -20
- package/package.json +1 -1
|
@@ -48,11 +48,7 @@ export default class CalendarEventManager {
|
|
|
48
48
|
cancelEvent(id: string, options?: CancelOptions): Promise<void>;
|
|
49
49
|
makeCalendarVisible(calendarId: string): Promise<void>;
|
|
50
50
|
makeCalendarHidden(calendarId: string): Promise<void>;
|
|
51
|
-
updateEvent(id: string, updates:
|
|
52
|
-
dateToUpdate?: number;
|
|
53
|
-
shouldUpdateAllEventsGoingForward?: boolean;
|
|
54
|
-
shouldPersist?: boolean;
|
|
55
|
-
}): void;
|
|
51
|
+
updateEvent(id: string, updates: UpdateEventOptions): void;
|
|
56
52
|
loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent[]>;
|
|
57
53
|
setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
|
|
58
54
|
setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
|
|
@@ -122,4 +118,9 @@ export type SavedEvent = Partial<CalendarEvent> & {
|
|
|
122
118
|
export interface CancelOptions {
|
|
123
119
|
shouldPersist?: boolean;
|
|
124
120
|
}
|
|
121
|
+
export type UpdateEventOptions = Partial<CalendarEvent> & {
|
|
122
|
+
dateToUpdate?: number;
|
|
123
|
+
shouldUpdateAllEventsGoingForward?: boolean;
|
|
124
|
+
shouldPersist?: boolean;
|
|
125
|
+
};
|
|
125
126
|
export {};
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
18
18
|
const schema_1 = require("@sprucelabs/schema");
|
|
19
19
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
20
|
+
const isEqual_1 = __importDefault(require("../stores/isEqual"));
|
|
20
21
|
const calendarShiftGenerator_1 = __importDefault(require("../utilities/calendarShiftGenerator"));
|
|
21
22
|
const draftGenerator_1 = __importDefault(require("../utilities/draftGenerator"));
|
|
22
23
|
class CalendarEventManager {
|
|
@@ -177,6 +178,12 @@ class CalendarEventManager {
|
|
|
177
178
|
updateEvent(id, updates) {
|
|
178
179
|
var _a;
|
|
179
180
|
const { shouldPersist } = updates, rest = __rest(updates, ["shouldPersist"]);
|
|
181
|
+
const match = this.allEvents.find((e) => e.id === id);
|
|
182
|
+
const updated = Object.assign(Object.assign({}, match), updates);
|
|
183
|
+
const isTheSame = (0, isEqual_1.default)(match, updated);
|
|
184
|
+
if (isTheSame) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
180
187
|
this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist }));
|
|
181
188
|
const idx = this.allEvents.findIndex((e) => e.id === id);
|
|
182
189
|
this.allEvents[idx] = Object.assign(Object.assign({}, this.allEvents[idx]), rest);
|
|
@@ -48,11 +48,7 @@ export default class CalendarEventManager {
|
|
|
48
48
|
cancelEvent(id: string, options?: CancelOptions): Promise<void>;
|
|
49
49
|
makeCalendarVisible(calendarId: string): Promise<void>;
|
|
50
50
|
makeCalendarHidden(calendarId: string): Promise<void>;
|
|
51
|
-
updateEvent(id: string, updates:
|
|
52
|
-
dateToUpdate?: number;
|
|
53
|
-
shouldUpdateAllEventsGoingForward?: boolean;
|
|
54
|
-
shouldPersist?: boolean;
|
|
55
|
-
}): void;
|
|
51
|
+
updateEvent(id: string, updates: UpdateEventOptions): void;
|
|
56
52
|
loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent[]>;
|
|
57
53
|
setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
|
|
58
54
|
setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
|
|
@@ -122,4 +118,9 @@ export type SavedEvent = Partial<CalendarEvent> & {
|
|
|
122
118
|
export interface CancelOptions {
|
|
123
119
|
shouldPersist?: boolean;
|
|
124
120
|
}
|
|
121
|
+
export type UpdateEventOptions = Partial<CalendarEvent> & {
|
|
122
|
+
dateToUpdate?: number;
|
|
123
|
+
shouldUpdateAllEventsGoingForward?: boolean;
|
|
124
|
+
shouldPersist?: boolean;
|
|
125
|
+
};
|
|
125
126
|
export {};
|
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
import { calendarEventSchema, } from '@sprucelabs/heartwood-view-controllers';
|
|
22
22
|
import { assertOptions, normalizeSchemaValues } from '@sprucelabs/schema';
|
|
23
23
|
import SpruceError from '../errors/SpruceError.js';
|
|
24
|
+
import isEqual from '../stores/isEqual.js';
|
|
24
25
|
import calendarShiftGenerator from '../utilities/calendarShiftGenerator.js';
|
|
25
26
|
import draftEventGenerator from '../utilities/draftGenerator.js';
|
|
26
27
|
export default class CalendarEventManager {
|
|
@@ -197,6 +198,12 @@ export default class CalendarEventManager {
|
|
|
197
198
|
updateEvent(id, updates) {
|
|
198
199
|
var _a;
|
|
199
200
|
const { shouldPersist } = updates, rest = __rest(updates, ["shouldPersist"]);
|
|
201
|
+
const match = this.allEvents.find((e) => e.id === id);
|
|
202
|
+
const updated = Object.assign(Object.assign({}, match), updates);
|
|
203
|
+
const isTheSame = isEqual(match, updated);
|
|
204
|
+
if (isTheSame) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
200
207
|
this.calendarVc.updateEvent(id, Object.assign(Object.assign({}, rest), { shouldPersist }));
|
|
201
208
|
const idx = this.allEvents.findIndex((e) => e.id === id);
|
|
202
209
|
this.allEvents[idx] = Object.assign(Object.assign({}, this.allEvents[idx]), rest);
|
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
import { calendarEventSchema } from '@sprucelabs/calendar-utils';
|
|
22
22
|
import { assertOptions, normalizeSchemaValues } from '@sprucelabs/schema';
|
|
23
23
|
import draftEventGenerator from '../utilities/draftGenerator.js';
|
|
24
|
+
import isEqual from './isEqual.js';
|
|
24
25
|
export default class RemoteEventStoreImpl {
|
|
25
26
|
constructor(options) {
|
|
26
27
|
this.pendingEvents = {};
|
|
@@ -81,7 +82,7 @@ export default class RemoteEventStoreImpl {
|
|
|
81
82
|
}
|
|
82
83
|
delete event.isBusy;
|
|
83
84
|
const lastSaved = (_b = this.lastSavedById[this.getId(id)]) !== null && _b !== void 0 ? _b : {};
|
|
84
|
-
if (
|
|
85
|
+
if (isEqual(lastSaved.before, event) || isEqual(lastSaved.after, event)) {
|
|
85
86
|
resolve(lastSaved.after);
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
@@ -273,22 +274,3 @@ export default class RemoteEventStoreImpl {
|
|
|
273
274
|
});
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
|
-
const equals = (a, b) => {
|
|
277
|
-
if (a === b) {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
if (a instanceof Date && b instanceof Date) {
|
|
281
|
-
return a.getTime() === b.getTime();
|
|
282
|
-
}
|
|
283
|
-
if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) {
|
|
284
|
-
return a === b;
|
|
285
|
-
}
|
|
286
|
-
if (a.prototype !== b.prototype) {
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
const keys = Object.keys(a);
|
|
290
|
-
if (keys.length !== Object.keys(b).length) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
return keys.every((k) => equals(a[k], b[k]));
|
|
294
|
-
};
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
18
18
|
const schema_1 = require("@sprucelabs/schema");
|
|
19
19
|
const draftGenerator_1 = __importDefault(require("../utilities/draftGenerator"));
|
|
20
|
+
const isEqual_1 = __importDefault(require("./isEqual"));
|
|
20
21
|
class RemoteEventStoreImpl {
|
|
21
22
|
constructor(options) {
|
|
22
23
|
this.pendingEvents = {};
|
|
@@ -72,7 +73,7 @@ class RemoteEventStoreImpl {
|
|
|
72
73
|
}
|
|
73
74
|
delete event.isBusy;
|
|
74
75
|
const lastSaved = (_b = this.lastSavedById[this.getId(id)]) !== null && _b !== void 0 ? _b : {};
|
|
75
|
-
if (
|
|
76
|
+
if ((0, isEqual_1.default)(lastSaved.before, event) || (0, isEqual_1.default)(lastSaved.after, event)) {
|
|
76
77
|
resolve(lastSaved.after);
|
|
77
78
|
}
|
|
78
79
|
else {
|
|
@@ -248,22 +249,3 @@ class RemoteEventStoreImpl {
|
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
exports.default = RemoteEventStoreImpl;
|
|
251
|
-
const equals = (a, b) => {
|
|
252
|
-
if (a === b) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
if (a instanceof Date && b instanceof Date) {
|
|
256
|
-
return a.getTime() === b.getTime();
|
|
257
|
-
}
|
|
258
|
-
if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) {
|
|
259
|
-
return a === b;
|
|
260
|
-
}
|
|
261
|
-
if (a.prototype !== b.prototype) {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
const keys = Object.keys(a);
|
|
265
|
-
if (keys.length !== Object.keys(b).length) {
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
return keys.every((k) => equals(a[k], b[k]));
|
|
269
|
-
};
|