@sumaris-net/ngx-components 1.23.17 → 1.23.19
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/bundles/sumaris-net.ngx-components.umd.js +33 -30
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/services/base-entity-service.class.js +5 -6
- package/esm2015/src/app/core/services/network.service.js +1 -1
- package/esm2015/src/app/core/table/entities-table-datasource.class.js +25 -23
- package/esm2015/src/app/core/table/table.class.js +6 -4
- package/fesm2015/sumaris-net.ngx-components.js +33 -30
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -25928,15 +25928,15 @@
|
|
|
25928
25928
|
console.warn(this.constructor.name + ".listenChanges() not implemented yet. Will empty observable");
|
|
25929
25929
|
return rxjs.of();
|
|
25930
25930
|
}
|
|
25931
|
-
var variables = opts
|
|
25931
|
+
var variables = (opts === null || opts === void 0 ? void 0 : opts.variables) || {
|
|
25932
25932
|
id: id,
|
|
25933
25933
|
interval: toNumber(opts && opts.interval, 0) // no timer by default
|
|
25934
25934
|
};
|
|
25935
25935
|
if (this._debug)
|
|
25936
25936
|
console.debug(this._logPrefix + ("[WS] Listening for changes on " + this._logTypeName + " {" + id + "}..."));
|
|
25937
25937
|
return this.graphql.subscribe({
|
|
25938
|
-
query: opts
|
|
25939
|
-
fetchPolicy: opts
|
|
25938
|
+
query: (opts === null || opts === void 0 ? void 0 : opts.query) || this.subscriptions.listenChanges,
|
|
25939
|
+
fetchPolicy: (opts === null || opts === void 0 ? void 0 : opts.fetchPolicy) || 'no-cache',
|
|
25940
25940
|
variables: variables,
|
|
25941
25941
|
error: {
|
|
25942
25942
|
code: ErrorCodes.SUBSCRIBE_DATA_ERROR,
|
|
@@ -25946,8 +25946,7 @@
|
|
|
25946
25946
|
.pipe(operators.map(function (_b) {
|
|
25947
25947
|
var data = _b.data;
|
|
25948
25948
|
var entity = (!opts || opts.toEntity !== false) ? data && _this.fromObject(data) : data;
|
|
25949
|
-
if (entity &&
|
|
25950
|
-
console.debug(_this._logPrefix + ("[WS] Received changes on " + _this._logTypeName + " {" + id + "}"), entity);
|
|
25949
|
+
//if (entity && this._debug) console.debug(this._logPrefix + `[WS] Received changes on ${this._logTypeName} {${id}}`, entity);
|
|
25951
25950
|
// TODO: missing = deleted ?
|
|
25952
25951
|
if (!entity)
|
|
25953
25952
|
console.warn(_this._logPrefix + ("[WS] Received deletion on " + _this._logTypeName + " {" + id + "} - TODO check implementation"));
|
|
@@ -26121,7 +26120,8 @@
|
|
|
26121
26120
|
*/
|
|
26122
26121
|
EntitiesTableDataSource.prototype.close = function () {
|
|
26123
26122
|
if (!this._stopWatchSubject.closed) {
|
|
26124
|
-
|
|
26123
|
+
if (this._debug)
|
|
26124
|
+
console.debug('[entities-table-datasource] Closing...');
|
|
26125
26125
|
this._stopWatchSubject.next();
|
|
26126
26126
|
this._stopWatchSubject.complete();
|
|
26127
26127
|
this._stopWatchSubject.unsubscribe();
|
|
@@ -26137,10 +26137,10 @@
|
|
|
26137
26137
|
return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
|
|
26138
26138
|
.pipe(operators.catchError(function (err) { return _this.handleError(err, 'ERROR.LOAD_DATA_ERROR'); }), operators.map(function (res) {
|
|
26139
26139
|
if (_this._saving) {
|
|
26140
|
-
console.info("[table-datasource] Received " + _this._entityName + " data (from service), but still saving: skip");
|
|
26140
|
+
console.info("[entities-table-datasource] Received " + _this._entityName + " data (from service), but still saving: skip");
|
|
26141
26141
|
}
|
|
26142
26142
|
else if (_this.hasSomeEditingRow()) {
|
|
26143
|
-
console.warn("[table-datasource] Received " + _this._entityName + " data, while some row still editing: skip; Please check save() implementation in the table!");
|
|
26143
|
+
console.warn("[entities-table-datasource] Received " + _this._entityName + " data, while some row still editing: skip; Please check save() implementation in the table!");
|
|
26144
26144
|
}
|
|
26145
26145
|
else {
|
|
26146
26146
|
_this.updateDatasource((res.data || []));
|
|
@@ -26158,11 +26158,11 @@
|
|
|
26158
26158
|
// Avoid to update dataSourceSubject, when not need
|
|
26159
26159
|
if ((_a = this.datasourceSubject.observers) === null || _a === void 0 ? void 0 : _a.length) {
|
|
26160
26160
|
if (!this.config.suppressErrors)
|
|
26161
|
-
console.warn('[table-datasource] Update datasource subject. Please prefer using \'rowsSubject\' instead of \'datasourceSubject\'');
|
|
26161
|
+
console.warn('[entities-table-datasource] Update datasource subject. Please prefer using \'rowsSubject\' instead of \'datasourceSubject\'');
|
|
26162
26162
|
_super_1.prototype.updateDatasourceFromRows.call(this, rows);
|
|
26163
26163
|
}
|
|
26164
26164
|
else {
|
|
26165
|
-
console.debug('[table-datasource] Skipping datasourceSubject update (not used yet).');
|
|
26165
|
+
console.debug('[entities-table-datasource] Skipping datasourceSubject update (not used yet).');
|
|
26166
26166
|
}
|
|
26167
26167
|
};
|
|
26168
26168
|
EntitiesTableDataSource.prototype.save = function () {
|
|
@@ -26173,12 +26173,12 @@
|
|
|
26173
26173
|
switch (_b.label) {
|
|
26174
26174
|
case 0:
|
|
26175
26175
|
if (this.config.readOnly) {
|
|
26176
|
-
console.error('[table-datasource] Enable to save, because config.readOnly=true');
|
|
26176
|
+
console.error('[entities-table-datasource] Enable to save, because config.readOnly=true');
|
|
26177
26177
|
return [2 /*return*/, false];
|
|
26178
26178
|
}
|
|
26179
26179
|
// Saving twice (should never occur)
|
|
26180
26180
|
if (this._saving) {
|
|
26181
|
-
console.warn("[table-datasource] Trying to save " + this._entityName + " rows twice. Skip");
|
|
26181
|
+
console.warn("[entities-table-datasource] Trying to save " + this._entityName + " rows twice. Skip");
|
|
26182
26182
|
return [2 /*return*/, false];
|
|
26183
26183
|
}
|
|
26184
26184
|
this._saving = true;
|
|
@@ -26188,14 +26188,14 @@
|
|
|
26188
26188
|
case 1:
|
|
26189
26189
|
_b.trys.push([1, 3, 4, 5]);
|
|
26190
26190
|
if (this._debug)
|
|
26191
|
-
console.debug("[table-datasource] Saving " + this._entityName + " rows... {onlyDirtyRows: " + onlyDirtyRows + "}");
|
|
26191
|
+
console.debug("[entities-table-datasource] Saving " + this._entityName + " rows... {onlyDirtyRows: " + onlyDirtyRows + "}");
|
|
26192
26192
|
rows = this.getRows();
|
|
26193
26193
|
invalidRows = rows.filter(function (row) { return row.editing && !row.confirmEditCreate(); });
|
|
26194
26194
|
// Cannot finish some rows: error
|
|
26195
26195
|
if (invalidRows.length) {
|
|
26196
26196
|
// log errors
|
|
26197
26197
|
if (this._debug)
|
|
26198
|
-
invalidRows.forEach(function (row) { return AppTableUtils.logRowErrors(row, "[table-datasource] " + _this._entityName + " row #" + row.id); });
|
|
26198
|
+
invalidRows.forEach(function (row) { return AppTableUtils.logRowErrors(row, "[entities-table-datasource] " + _this._entityName + " row #" + row.id); });
|
|
26199
26199
|
// Stop with an error
|
|
26200
26200
|
throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
26201
26201
|
}
|
|
@@ -26222,23 +26222,23 @@
|
|
|
26222
26222
|
// If no data to save: exit
|
|
26223
26223
|
if (onlyDirtyRows && !dataToSave_1.length) {
|
|
26224
26224
|
if (this._debug)
|
|
26225
|
-
console.debug("[table-datasource] No " + this._entityName + " data to save. Skip");
|
|
26225
|
+
console.debug("[entities-table-datasource] No " + this._entityName + " data to save. Skip");
|
|
26226
26226
|
return [2 /*return*/, false];
|
|
26227
26227
|
}
|
|
26228
26228
|
if (this._debug)
|
|
26229
|
-
console.debug("[table-datasource] Asking service to save this " + this._entityName + " data:", dataToSave_1);
|
|
26229
|
+
console.debug("[entities-table-datasource] Asking service to save this " + this._entityName + " data:", dataToSave_1);
|
|
26230
26230
|
return [4 /*yield*/, this.dataService.saveAll(dataToSave_1, this.serviceOptions)];
|
|
26231
26231
|
case 2:
|
|
26232
26232
|
_b.sent();
|
|
26233
26233
|
if (this._debug)
|
|
26234
|
-
console.debug("[table-datasource] Saving " + this._entityName + " data [OK]");
|
|
26234
|
+
console.debug("[entities-table-datasource] Saving " + this._entityName + " data [OK]");
|
|
26235
26235
|
// LP 23/03/2021: update datasource is necessary but can be changed to a refetch() on QueryRef (must be created and registered in GraphqlService.watchQuery)
|
|
26236
26236
|
this.updateDatasource(data, { emitEvent: false });
|
|
26237
26237
|
return [2 /*return*/, true];
|
|
26238
26238
|
case 3:
|
|
26239
26239
|
error_1 = _b.sent();
|
|
26240
26240
|
if (this._debug)
|
|
26241
|
-
console.error('[table-datasource] Error while saving: ' + error_1 && error_1.message || error_1);
|
|
26241
|
+
console.error('[entities-table-datasource] Error while saving: ' + error_1 && error_1.message || error_1);
|
|
26242
26242
|
throw error_1;
|
|
26243
26243
|
case 4:
|
|
26244
26244
|
this._saving = false;
|
|
@@ -26251,7 +26251,7 @@
|
|
|
26251
26251
|
};
|
|
26252
26252
|
EntitiesTableDataSource.prototype.updateDatasource = function (data, opts) {
|
|
26253
26253
|
if (this._debug)
|
|
26254
|
-
console.debug("[table-datasource] Updating datasource with data:", data);
|
|
26254
|
+
console.debug("[entities-table-datasource] Updating datasource with data:", data);
|
|
26255
26255
|
_super_1.prototype.updateDatasource.call(this, data, opts);
|
|
26256
26256
|
if (!opts || opts.emitEvent !== false) {
|
|
26257
26257
|
this.markAsLoaded();
|
|
@@ -26263,7 +26263,8 @@
|
|
|
26263
26263
|
return _super_1.prototype.connect.call(this, collectionViewer);
|
|
26264
26264
|
};
|
|
26265
26265
|
EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
|
|
26266
|
-
|
|
26266
|
+
if (this._debug)
|
|
26267
|
+
console.debug('[entities-table-datasource] Disconnecting...');
|
|
26267
26268
|
_super_1.prototype.disconnect.call(this, collectionViewer);
|
|
26268
26269
|
this.close();
|
|
26269
26270
|
};
|
|
@@ -26277,7 +26278,7 @@
|
|
|
26277
26278
|
if (!_super_1.prototype.confirmCreate.call(this, row))
|
|
26278
26279
|
return false;
|
|
26279
26280
|
if (row.editing && row.validator) {
|
|
26280
|
-
console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
|
|
26281
|
+
console.warn('[entities-table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
|
|
26281
26282
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
26282
26283
|
}
|
|
26283
26284
|
return true;
|
|
@@ -26286,7 +26287,7 @@
|
|
|
26286
26287
|
if (!_super_1.prototype.confirmEdit.call(this, row))
|
|
26287
26288
|
return false;
|
|
26288
26289
|
if (row.editing && row.validator) {
|
|
26289
|
-
console.warn('[table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
|
|
26290
|
+
console.warn('[entities-table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
|
|
26290
26291
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
26291
26292
|
}
|
|
26292
26293
|
return true;
|
|
@@ -26295,19 +26296,19 @@
|
|
|
26295
26296
|
if (!_super_1.prototype.startEdit.call(this, row))
|
|
26296
26297
|
return false;
|
|
26297
26298
|
if (!row.editing && row.validator) {
|
|
26298
|
-
console.warn('[table-datasource] Row still has {editing: false} after startEdit()! Force editing');
|
|
26299
|
+
console.warn('[entities-table-datasource] Row still has {editing: false} after startEdit()! Force editing');
|
|
26299
26300
|
row.validator.enable({ onlySelf: true, emitEvent: false });
|
|
26300
26301
|
}
|
|
26301
26302
|
};
|
|
26302
26303
|
EntitiesTableDataSource.prototype.handleError = function (error, message) {
|
|
26303
26304
|
var errorMsg = error && error.message || error;
|
|
26304
|
-
console.error("[table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
|
|
26305
|
+
console.error("[entities-table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
|
|
26305
26306
|
this.markAsLoaded();
|
|
26306
26307
|
throw new Error(message || errorMsg);
|
|
26307
26308
|
};
|
|
26308
26309
|
EntitiesTableDataSource.prototype.handleServiceError = function (error) {
|
|
26309
26310
|
var errorMsg = error && error.message || error;
|
|
26310
|
-
console.error("[table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
|
|
26311
|
+
console.error("[entities-table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
|
|
26311
26312
|
this.markAsLoaded();
|
|
26312
26313
|
throw error;
|
|
26313
26314
|
};
|
|
@@ -26319,7 +26320,7 @@
|
|
|
26319
26320
|
}
|
|
26320
26321
|
var row = this.getRow(id);
|
|
26321
26322
|
if (!row) {
|
|
26322
|
-
console.error("[table-datasource] Row to delete with id=" + id + " not found");
|
|
26323
|
+
console.error("[entities-table-datasource] Row to delete with id=" + id + " not found");
|
|
26323
26324
|
return;
|
|
26324
26325
|
}
|
|
26325
26326
|
this.markAsLoading();
|
|
@@ -26357,7 +26358,7 @@
|
|
|
26357
26358
|
_b.sent();
|
|
26358
26359
|
rowNotDeleted = this.getRows().filter(function (row) { return rows.includes(row); });
|
|
26359
26360
|
if (isNotEmptyArray(rowNotDeleted)) {
|
|
26360
|
-
console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows! Please check that data service update the cache, after deletion");
|
|
26361
|
+
console.warn("[entities-table-datasource] Force deletion of " + rowNotDeleted.length + " rows! Please check that data service update the cache, after deletion");
|
|
26361
26362
|
rowNotDeleted
|
|
26362
26363
|
// Start at the end
|
|
26363
26364
|
.sort(function (a, b) { return a.id > b.id ? -1 : 1; })
|
|
@@ -27365,8 +27366,10 @@
|
|
|
27365
27366
|
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
27366
27367
|
// Exclude invalid rows (because of save() will fail, when exists some invalid rows)
|
|
27367
27368
|
tempRows = tempRows.filter(function (row) {
|
|
27368
|
-
// Delete the row
|
|
27369
|
-
if (
|
|
27369
|
+
// Delete the row :
|
|
27370
|
+
// - if newly created row (id = -1),
|
|
27371
|
+
// - or if invalid and not editing (= not cancellable)
|
|
27372
|
+
if (row.id === -1 || (!row.editing && row.invalid)) {
|
|
27370
27373
|
if (_this.debug)
|
|
27371
27374
|
console.debug("[table] Delete row #" + row.id);
|
|
27372
27375
|
row.delete();
|
|
@@ -27378,7 +27381,7 @@
|
|
|
27378
27381
|
return false; // Exclude from the list to delete using the service
|
|
27379
27382
|
}
|
|
27380
27383
|
// Cancel the row (and mark as pristine), when not valid but in edition
|
|
27381
|
-
else if (
|
|
27384
|
+
else if (row.editing && !row.valid) {
|
|
27382
27385
|
row.cancel();
|
|
27383
27386
|
// Mark row as pristine (if possible)
|
|
27384
27387
|
_this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|