@sprucelabs/spruce-calendar-components 19.0.2 → 19.0.3
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.
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { assertOptions } from '@sprucelabs/schema';
|
|
11
|
+
import equalDeep from 'lodash/isEqual.js';
|
|
11
12
|
import CalendarToolRegistrar from '../CalendarToolRegistrar.js';
|
|
12
13
|
export default class AbstractCalendarEventToolBeltState {
|
|
13
14
|
constructor() {
|
|
@@ -122,7 +123,11 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
122
123
|
}
|
|
123
124
|
handleUpdateContextFromTool(updates, fromToolId) {
|
|
124
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
|
|
126
|
+
const pendingUpdates = Object.assign(Object.assign({}, this.pendingContextUpdates), updates);
|
|
127
|
+
if (equalDeep(this.pendingContextUpdates, pendingUpdates)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.pendingContextUpdates = pendingUpdates;
|
|
126
131
|
yield this.handleDidUpdateContext(fromToolId);
|
|
127
132
|
const vc = this.getVcForTool(fromToolId);
|
|
128
133
|
if (vc === null || vc === void 0 ? void 0 : vc.shouldPersistContextChangesImmediately) {
|
|
@@ -134,7 +139,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
134
139
|
assertOptions({ id }, ['id']);
|
|
135
140
|
const tool = this.toolBeltVc.getTool(id);
|
|
136
141
|
if (!tool) {
|
|
137
|
-
throw new Error(`
|
|
142
|
+
throw new Error(`Can't remove tool '${id}' because it does not exist.`);
|
|
138
143
|
}
|
|
139
144
|
this.vcs = this.vcs.filter(({ toolId }) => id !== toolId);
|
|
140
145
|
this.toolBeltVc.removeTool(id);
|
|
@@ -64,7 +64,6 @@ export default class EventTitleToolViewController extends AbstractViewController
|
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
const { event } = this.getContext();
|
|
66
66
|
event.timeBlocks[0] = Object.assign(Object.assign({}, event.timeBlocks[0]), this.formVc.getValues());
|
|
67
|
-
console.log('handling-form-change');
|
|
68
67
|
return this.updateContextHandler({
|
|
69
68
|
event: Object.assign({}, event),
|
|
70
69
|
});
|
|
@@ -72,7 +71,6 @@ export default class EventTitleToolViewController extends AbstractViewController
|
|
|
72
71
|
}
|
|
73
72
|
handleUpdateContext(context) {
|
|
74
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
console.log('handling-update-context');
|
|
76
74
|
yield this.formVc.setValues({
|
|
77
75
|
title: context.event.timeBlocks[0].title,
|
|
78
76
|
subtitle: context.event.timeBlocks[0].subtitle,
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const schema_1 = require("@sprucelabs/schema");
|
|
7
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
7
8
|
const CalendarToolRegistrar_1 = __importDefault(require("../CalendarToolRegistrar"));
|
|
8
9
|
class AbstractCalendarEventToolBeltState {
|
|
9
10
|
constructor() {
|
|
@@ -101,7 +102,11 @@ class AbstractCalendarEventToolBeltState {
|
|
|
101
102
|
return null;
|
|
102
103
|
}
|
|
103
104
|
async handleUpdateContextFromTool(updates, fromToolId) {
|
|
104
|
-
|
|
105
|
+
const pendingUpdates = Object.assign(Object.assign({}, this.pendingContextUpdates), updates);
|
|
106
|
+
if ((0, isEqual_1.default)(this.pendingContextUpdates, pendingUpdates)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.pendingContextUpdates = pendingUpdates;
|
|
105
110
|
await this.handleDidUpdateContext(fromToolId);
|
|
106
111
|
const vc = this.getVcForTool(fromToolId);
|
|
107
112
|
if (vc === null || vc === void 0 ? void 0 : vc.shouldPersistContextChangesImmediately) {
|
|
@@ -112,7 +117,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
112
117
|
(0, schema_1.assertOptions)({ id }, ['id']);
|
|
113
118
|
const tool = this.toolBeltVc.getTool(id);
|
|
114
119
|
if (!tool) {
|
|
115
|
-
throw new Error(`
|
|
120
|
+
throw new Error(`Can't remove tool '${id}' because it does not exist.`);
|
|
116
121
|
}
|
|
117
122
|
this.vcs = this.vcs.filter(({ toolId }) => id !== toolId);
|
|
118
123
|
this.toolBeltVc.removeTool(id);
|
|
@@ -56,13 +56,11 @@ class EventTitleToolViewController extends heartwood_view_controllers_1.Abstract
|
|
|
56
56
|
async handleChangeForm() {
|
|
57
57
|
const { event } = this.getContext();
|
|
58
58
|
event.timeBlocks[0] = Object.assign(Object.assign({}, event.timeBlocks[0]), this.formVc.getValues());
|
|
59
|
-
console.log('handling-form-change');
|
|
60
59
|
return this.updateContextHandler({
|
|
61
60
|
event: Object.assign({}, event),
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
63
|
async handleUpdateContext(context) {
|
|
65
|
-
console.log('handling-update-context');
|
|
66
64
|
await this.formVc.setValues({
|
|
67
65
|
title: context.event.timeBlocks[0].title,
|
|
68
66
|
subtitle: context.event.timeBlocks[0].subtitle,
|