remult 0.26.21 → 0.26.22
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.
|
@@ -1287,7 +1287,13 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1287
1287
|
try {
|
|
1288
1288
|
this._subscribers?.reportChanged();
|
|
1289
1289
|
if (this.isNew()) {
|
|
1290
|
-
|
|
1290
|
+
if (doNotSave) {
|
|
1291
|
+
updatedRow = (updatedRow = await this.edp.find({
|
|
1292
|
+
where: await this.getIdFilter(),
|
|
1293
|
+
}))[0];
|
|
1294
|
+
}
|
|
1295
|
+
else
|
|
1296
|
+
updatedRow = await this.edp.insert(d);
|
|
1291
1297
|
}
|
|
1292
1298
|
else {
|
|
1293
1299
|
let changesOnly = {};
|
|
@@ -1311,7 +1317,8 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1311
1317
|
updatedRow = await this.edp.update(this.id, changesOnly);
|
|
1312
1318
|
}
|
|
1313
1319
|
}
|
|
1314
|
-
|
|
1320
|
+
if (updatedRow)
|
|
1321
|
+
await this.loadDataFrom(updatedRow);
|
|
1315
1322
|
e.id = this.getId();
|
|
1316
1323
|
if (!this.repository._dataProvider.isProxy) {
|
|
1317
1324
|
if (this.info.entityInfo.saved)
|
package/package.json
CHANGED
|
@@ -2062,12 +2062,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2062
2062
|
rowHelperImplementation.prototype.save = function (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2063
2063
|
var _a;
|
|
2064
2064
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2065
|
-
var doNotSave_1, e, _b, _c, col, e_32_1, d, ignoreKeys, _d, _e, field, f, updatedRow, isNew, changesOnly, wasChanged, key, element,
|
|
2066
|
-
var e_32,
|
|
2067
|
-
return tslib_1.__generator(this, function (
|
|
2068
|
-
switch (
|
|
2065
|
+
var doNotSave_1, e, _b, _c, col, e_32_1, d, ignoreKeys, _d, _e, field, f, updatedRow, isNew, _f, _g, changesOnly, wasChanged, key, element, _h, _j, _k, _l, listener, e_33_1, err_1;
|
|
2066
|
+
var e_32, _m, e_34, _o, _p, _q, e_33, _r;
|
|
2067
|
+
return tslib_1.__generator(this, function (_s) {
|
|
2068
|
+
switch (_s.label) {
|
|
2069
2069
|
case 0:
|
|
2070
|
-
|
|
2070
|
+
_s.trys.push([0, , 41, 42]);
|
|
2071
2071
|
if (this._saving)
|
|
2072
2072
|
throw new Error('cannot save while entity is already saving');
|
|
2073
2073
|
this._saving = true;
|
|
@@ -2080,36 +2080,36 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2080
2080
|
return [4 /*yield*/, this.__validateEntity()];
|
|
2081
2081
|
case 1:
|
|
2082
2082
|
// no need
|
|
2083
|
-
|
|
2084
|
-
|
|
2083
|
+
_s.sent();
|
|
2084
|
+
_s.label = 2;
|
|
2085
2085
|
case 2:
|
|
2086
2086
|
doNotSave_1 = false;
|
|
2087
2087
|
e = this.buildLifeCycleEvent(function () { return (doNotSave_1 = true); });
|
|
2088
2088
|
if (!!this.repository._dataProvider.isProxy) return [3 /*break*/, 12];
|
|
2089
|
-
|
|
2089
|
+
_s.label = 3;
|
|
2090
2090
|
case 3:
|
|
2091
|
-
|
|
2091
|
+
_s.trys.push([3, 8, 9, 10]);
|
|
2092
2092
|
_b = tslib_1.__values(this.fields), _c = _b.next();
|
|
2093
|
-
|
|
2093
|
+
_s.label = 4;
|
|
2094
2094
|
case 4:
|
|
2095
2095
|
if (!!_c.done) return [3 /*break*/, 7];
|
|
2096
2096
|
col = _c.value;
|
|
2097
2097
|
if (!col.metadata.options.saving) return [3 /*break*/, 6];
|
|
2098
2098
|
return [4 /*yield*/, col.metadata.options.saving(this.instance, col, e)];
|
|
2099
2099
|
case 5:
|
|
2100
|
-
|
|
2101
|
-
|
|
2100
|
+
_s.sent();
|
|
2101
|
+
_s.label = 6;
|
|
2102
2102
|
case 6:
|
|
2103
2103
|
_c = _b.next();
|
|
2104
2104
|
return [3 /*break*/, 4];
|
|
2105
2105
|
case 7: return [3 /*break*/, 10];
|
|
2106
2106
|
case 8:
|
|
2107
|
-
e_32_1 =
|
|
2107
|
+
e_32_1 = _s.sent();
|
|
2108
2108
|
e_32 = { error: e_32_1 };
|
|
2109
2109
|
return [3 /*break*/, 10];
|
|
2110
2110
|
case 9:
|
|
2111
2111
|
try {
|
|
2112
|
-
if (_c && !_c.done && (
|
|
2112
|
+
if (_c && !_c.done && (_m = _b.return)) _m.call(_b);
|
|
2113
2113
|
}
|
|
2114
2114
|
finally { if (e_32) throw e_32.error; }
|
|
2115
2115
|
return [7 /*endfinally*/];
|
|
@@ -2117,8 +2117,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2117
2117
|
if (!this.info.entityInfo.saving) return [3 /*break*/, 12];
|
|
2118
2118
|
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, e)];
|
|
2119
2119
|
case 11:
|
|
2120
|
-
|
|
2121
|
-
|
|
2120
|
+
_s.sent();
|
|
2121
|
+
_s.label = 12;
|
|
2122
2122
|
case 12:
|
|
2123
2123
|
this.__assertValidity();
|
|
2124
2124
|
d = this.copyDataToObject(this.isNew());
|
|
@@ -2140,22 +2140,32 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2140
2140
|
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
2141
2141
|
finally {
|
|
2142
2142
|
try {
|
|
2143
|
-
if (_e && !_e.done && (
|
|
2143
|
+
if (_e && !_e.done && (_o = _d.return)) _o.call(_d);
|
|
2144
2144
|
}
|
|
2145
2145
|
finally { if (e_34) throw e_34.error; }
|
|
2146
2146
|
}
|
|
2147
2147
|
updatedRow = void 0;
|
|
2148
2148
|
isNew = this.isNew();
|
|
2149
|
-
|
|
2149
|
+
_s.label = 13;
|
|
2150
2150
|
case 13:
|
|
2151
|
-
|
|
2151
|
+
_s.trys.push([13, 38, , 40]);
|
|
2152
2152
|
(_a = this._subscribers) === null || _a === void 0 ? void 0 : _a.reportChanged();
|
|
2153
|
-
if (!this.isNew()) return [3 /*break*/,
|
|
2154
|
-
return [
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
return [
|
|
2153
|
+
if (!this.isNew()) return [3 /*break*/, 19];
|
|
2154
|
+
if (!doNotSave_1) return [3 /*break*/, 16];
|
|
2155
|
+
_g = (_f = this.edp).find;
|
|
2156
|
+
_p = {};
|
|
2157
|
+
return [4 /*yield*/, this.getIdFilter()];
|
|
2158
|
+
case 14: return [4 /*yield*/, _g.apply(_f, [(_p.where = _s.sent(),
|
|
2159
|
+
_p)])];
|
|
2158
2160
|
case 15:
|
|
2161
|
+
updatedRow = (updatedRow = _s.sent())[0];
|
|
2162
|
+
return [3 /*break*/, 18];
|
|
2163
|
+
case 16: return [4 /*yield*/, this.edp.insert(d)];
|
|
2164
|
+
case 17:
|
|
2165
|
+
updatedRow = _s.sent();
|
|
2166
|
+
_s.label = 18;
|
|
2167
|
+
case 18: return [3 /*break*/, 24];
|
|
2168
|
+
case 19:
|
|
2159
2169
|
changesOnly = {};
|
|
2160
2170
|
wasChanged = false;
|
|
2161
2171
|
for (key in d) {
|
|
@@ -2170,75 +2180,79 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2170
2180
|
}
|
|
2171
2181
|
if (!wasChanged)
|
|
2172
2182
|
return [2 /*return*/, this.instance];
|
|
2173
|
-
if (!doNotSave_1) return [3 /*break*/,
|
|
2174
|
-
|
|
2175
|
-
|
|
2183
|
+
if (!doNotSave_1) return [3 /*break*/, 22];
|
|
2184
|
+
_j = (_h = this.edp).find;
|
|
2185
|
+
_q = {};
|
|
2176
2186
|
return [4 /*yield*/, this.getIdFilter()];
|
|
2177
|
-
case
|
|
2178
|
-
case 17:
|
|
2179
|
-
updatedRow = (_p.sent())[0];
|
|
2180
|
-
return [3 /*break*/, 20];
|
|
2181
|
-
case 18: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
2182
|
-
case 19:
|
|
2183
|
-
updatedRow = _p.sent();
|
|
2184
|
-
_p.label = 20;
|
|
2185
|
-
case 20: return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2187
|
+
case 20: return [4 /*yield*/, _j.apply(_h, [(_q.where = _s.sent(), _q)])];
|
|
2186
2188
|
case 21:
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
if (!this.info.entityInfo.saved) return [3 /*break*/, 23];
|
|
2191
|
-
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2192
|
-
case 22:
|
|
2193
|
-
_p.sent();
|
|
2194
|
-
_p.label = 23;
|
|
2189
|
+
updatedRow = (_s.sent())[0];
|
|
2190
|
+
return [3 /*break*/, 24];
|
|
2191
|
+
case 22: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
2195
2192
|
case 23:
|
|
2196
|
-
|
|
2197
|
-
|
|
2193
|
+
updatedRow = _s.sent();
|
|
2194
|
+
_s.label = 24;
|
|
2198
2195
|
case 24:
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
_p.label = 25;
|
|
2196
|
+
if (!updatedRow) return [3 /*break*/, 26];
|
|
2197
|
+
return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2202
2198
|
case 25:
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
return [4 /*yield*/, listener.saved(this.instance, isNew)];
|
|
2199
|
+
_s.sent();
|
|
2200
|
+
_s.label = 26;
|
|
2206
2201
|
case 26:
|
|
2207
|
-
|
|
2208
|
-
|
|
2202
|
+
e.id = this.getId();
|
|
2203
|
+
if (!!this.repository._dataProvider.isProxy) return [3 /*break*/, 36];
|
|
2204
|
+
if (!this.info.entityInfo.saved) return [3 /*break*/, 28];
|
|
2205
|
+
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2209
2206
|
case 27:
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
case 28:
|
|
2207
|
+
_s.sent();
|
|
2208
|
+
_s.label = 28;
|
|
2209
|
+
case 28:
|
|
2210
|
+
if (!this.repository.listeners) return [3 /*break*/, 36];
|
|
2211
|
+
_s.label = 29;
|
|
2213
2212
|
case 29:
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2213
|
+
_s.trys.push([29, 34, 35, 36]);
|
|
2214
|
+
_k = tslib_1.__values(this.repository.listeners.filter(function (x) { return x.saved; })), _l = _k.next();
|
|
2215
|
+
_s.label = 30;
|
|
2217
2216
|
case 30:
|
|
2217
|
+
if (!!_l.done) return [3 /*break*/, 33];
|
|
2218
|
+
listener = _l.value;
|
|
2219
|
+
return [4 /*yield*/, listener.saved(this.instance, isNew)];
|
|
2220
|
+
case 31:
|
|
2221
|
+
_s.sent();
|
|
2222
|
+
_s.label = 32;
|
|
2223
|
+
case 32:
|
|
2224
|
+
_l = _k.next();
|
|
2225
|
+
return [3 /*break*/, 30];
|
|
2226
|
+
case 33: return [3 /*break*/, 36];
|
|
2227
|
+
case 34:
|
|
2228
|
+
e_33_1 = _s.sent();
|
|
2229
|
+
e_33 = { error: e_33_1 };
|
|
2230
|
+
return [3 /*break*/, 36];
|
|
2231
|
+
case 35:
|
|
2218
2232
|
try {
|
|
2219
|
-
if (
|
|
2233
|
+
if (_l && !_l.done && (_r = _k.return)) _r.call(_k);
|
|
2220
2234
|
}
|
|
2221
2235
|
finally { if (e_33) throw e_33.error; }
|
|
2222
2236
|
return [7 /*endfinally*/];
|
|
2223
|
-
case
|
|
2224
|
-
case
|
|
2225
|
-
|
|
2237
|
+
case 36: return [4 /*yield*/, this.repository._remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }])];
|
|
2238
|
+
case 37:
|
|
2239
|
+
_s.sent();
|
|
2226
2240
|
this.saveOriginalData();
|
|
2227
2241
|
this._isNew = false;
|
|
2228
2242
|
return [2 /*return*/, this.instance];
|
|
2229
|
-
case
|
|
2230
|
-
err_1 =
|
|
2243
|
+
case 38:
|
|
2244
|
+
err_1 = _s.sent();
|
|
2231
2245
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
2232
|
-
case
|
|
2233
|
-
|
|
2234
|
-
return [3 /*break*/,
|
|
2235
|
-
case
|
|
2236
|
-
case
|
|
2246
|
+
case 39:
|
|
2247
|
+
_s.sent();
|
|
2248
|
+
return [3 /*break*/, 40];
|
|
2249
|
+
case 40: return [3 /*break*/, 42];
|
|
2250
|
+
case 41:
|
|
2237
2251
|
this.isLoading = false;
|
|
2238
2252
|
this._reportChangedToEntityAndFields();
|
|
2239
2253
|
this._saving = false;
|
|
2240
2254
|
return [7 /*endfinally*/];
|
|
2241
|
-
case
|
|
2255
|
+
case 42: return [2 /*return*/];
|
|
2242
2256
|
}
|
|
2243
2257
|
});
|
|
2244
2258
|
});
|