@sumaris-net/ngx-components 1.23.1 → 1.23.4
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 +30 -51
- 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/table/entities-table-datasource.class.js +15 -29
- package/esm2015/src/app/core/table/table.class.js +18 -23
- package/fesm2015/sumaris-net.ngx-components.js +30 -49
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/table/entities-table-datasource.class.d.ts +1 -1
- package/src/app/core/table/table.class.d.ts +1 -4
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -25813,7 +25813,6 @@
|
|
|
25813
25813
|
_this._creating = false;
|
|
25814
25814
|
_this._saving = false;
|
|
25815
25815
|
_this._stopWatching$ = new rxjs.Subject();
|
|
25816
|
-
_this._editingRowCount = 0;
|
|
25817
25816
|
_this._fetchMoreFn = null;
|
|
25818
25817
|
_this.loadingSubject = new rxjs.BehaviorSubject(undefined);
|
|
25819
25818
|
_this._entityName = removeEnd((new dataType()).__typename || 'UnknownVO', 'VO');
|
|
@@ -25882,7 +25881,6 @@
|
|
|
25882
25881
|
EntitiesTableDataSource.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter) {
|
|
25883
25882
|
var _this = this;
|
|
25884
25883
|
this._stopWatching$.next();
|
|
25885
|
-
this._editingRowCount = 0;
|
|
25886
25884
|
this._fetchMoreFn = null;
|
|
25887
25885
|
this.markAsLoading();
|
|
25888
25886
|
return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
|
|
@@ -25890,8 +25888,8 @@
|
|
|
25890
25888
|
if (_this._saving) {
|
|
25891
25889
|
console.info("[table-datasource] Received " + _this._entityName + " data (from service), but still saving: skip");
|
|
25892
25890
|
}
|
|
25893
|
-
else if (_this.
|
|
25894
|
-
console.warn("[table-datasource] Received " + _this._entityName + " data, while
|
|
25891
|
+
else if (_this.hasSomeEditingRow()) {
|
|
25892
|
+
console.warn("[table-datasource] Received " + _this._entityName + " data, while some row still editing: skip; Please check save() implementation in the table!");
|
|
25895
25893
|
}
|
|
25896
25894
|
else {
|
|
25897
25895
|
_this.updateDatasource((res.data || []));
|
|
@@ -25950,7 +25948,6 @@
|
|
|
25950
25948
|
// Stop with an error
|
|
25951
25949
|
throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
25952
25950
|
}
|
|
25953
|
-
this._editingRowCount = 0;
|
|
25954
25951
|
data = void 0;
|
|
25955
25952
|
if (this.validatorService) {
|
|
25956
25953
|
dataToSave_1 = [];
|
|
@@ -26030,7 +26027,6 @@
|
|
|
26030
26027
|
console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
|
|
26031
26028
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
26032
26029
|
}
|
|
26033
|
-
this._editingRowCount--;
|
|
26034
26030
|
return true;
|
|
26035
26031
|
};
|
|
26036
26032
|
EntitiesTableDataSource.prototype.confirmEdit = function (row) {
|
|
@@ -26040,7 +26036,6 @@
|
|
|
26040
26036
|
console.warn('[table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
|
|
26041
26037
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
26042
26038
|
}
|
|
26043
|
-
this._editingRowCount--;
|
|
26044
26039
|
return true;
|
|
26045
26040
|
};
|
|
26046
26041
|
EntitiesTableDataSource.prototype.startEdit = function (row) {
|
|
@@ -26050,7 +26045,6 @@
|
|
|
26050
26045
|
console.warn('[table-datasource] Row still has {editing: false} after startEdit()! Force editing');
|
|
26051
26046
|
row.validator.enable({ onlySelf: true, emitEvent: false });
|
|
26052
26047
|
}
|
|
26053
|
-
this._editingRowCount++;
|
|
26054
26048
|
};
|
|
26055
26049
|
EntitiesTableDataSource.prototype.handleError = function (error, message) {
|
|
26056
26050
|
var errorMsg = error && error.message || error;
|
|
@@ -26075,9 +26069,7 @@
|
|
|
26075
26069
|
console.error("[table-datasource] Row to delete with id=" + id + " not found");
|
|
26076
26070
|
return;
|
|
26077
26071
|
}
|
|
26078
|
-
|
|
26079
|
-
this._editingRowCount--;
|
|
26080
|
-
this.loadingSubject.next(true);
|
|
26072
|
+
this.markAsLoading();
|
|
26081
26073
|
this.dataService.deleteAll([row.currentData], this.serviceOptions)
|
|
26082
26074
|
.catch(function (err) { return _this.handleServiceError(err); })
|
|
26083
26075
|
.then(function () {
|
|
@@ -26086,7 +26078,7 @@
|
|
|
26086
26078
|
var present = _this.getRow(id) === row;
|
|
26087
26079
|
if (present)
|
|
26088
26080
|
_super_1.prototype.delete.call(_this, id);
|
|
26089
|
-
_this.
|
|
26081
|
+
_this.markAsLoaded();
|
|
26090
26082
|
}, 300);
|
|
26091
26083
|
});
|
|
26092
26084
|
};
|
|
@@ -26095,14 +26087,13 @@
|
|
|
26095
26087
|
delete: { get: function () { return _super_1.prototype.delete; } }
|
|
26096
26088
|
});
|
|
26097
26089
|
return __awaiter(this, void 0, void 0, function () {
|
|
26098
|
-
var data,
|
|
26090
|
+
var data, rowNotDeleted, err_1;
|
|
26099
26091
|
var _this = this;
|
|
26100
26092
|
return __generator(this, function (_b) {
|
|
26101
26093
|
switch (_b.label) {
|
|
26102
26094
|
case 0:
|
|
26103
26095
|
this.markAsLoading();
|
|
26104
26096
|
data = this.getDataFromRows(rows);
|
|
26105
|
-
rowsById = Beans.collectById(rows);
|
|
26106
26097
|
_b.label = 1;
|
|
26107
26098
|
case 1:
|
|
26108
26099
|
_b.trys.push([1, 3, 4, 5]);
|
|
@@ -26111,14 +26102,7 @@
|
|
|
26111
26102
|
case 2:
|
|
26112
26103
|
// Call service deletion
|
|
26113
26104
|
_b.sent();
|
|
26114
|
-
rowNotDeleted =
|
|
26115
|
-
.reduce(function (res, id) {
|
|
26116
|
-
var row = rowsById[id];
|
|
26117
|
-
var present = _this.getRow(+id) === row;
|
|
26118
|
-
return present ? res.concat(row) : res;
|
|
26119
|
-
}, []);
|
|
26120
|
-
//this.getRows().filter(row => rows.includes(row));
|
|
26121
|
-
// Apply missing deletion
|
|
26105
|
+
rowNotDeleted = this.getRows().filter(rows.includes);
|
|
26122
26106
|
if (isNotEmptyArray(rowNotDeleted)) {
|
|
26123
26107
|
console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows (Is service update the cache ?)");
|
|
26124
26108
|
rowNotDeleted
|
|
@@ -26129,7 +26113,7 @@
|
|
|
26129
26113
|
return [3 /*break*/, 5];
|
|
26130
26114
|
case 3:
|
|
26131
26115
|
err_1 = _b.sent();
|
|
26132
|
-
// Handle
|
|
26116
|
+
// Handle service error
|
|
26133
26117
|
this.handleServiceError(err_1);
|
|
26134
26118
|
return [3 /*break*/, 5];
|
|
26135
26119
|
case 4:
|
|
@@ -26146,6 +26130,9 @@
|
|
|
26146
26130
|
EntitiesTableDataSource.prototype.getRows = function () {
|
|
26147
26131
|
return this.rowsSubject.getValue();
|
|
26148
26132
|
};
|
|
26133
|
+
EntitiesTableDataSource.prototype.hasSomeEditingRow = function () {
|
|
26134
|
+
return (this.rowsSubject.value || []).some(function (row) { return row.editing; });
|
|
26135
|
+
};
|
|
26149
26136
|
EntitiesTableDataSource.prototype.createNew = function (insertAt, options) {
|
|
26150
26137
|
if (options === void 0) { options = { editing: true }; }
|
|
26151
26138
|
var _super = Object.create(null, {
|
|
@@ -26181,10 +26168,7 @@
|
|
|
26181
26168
|
// Log, then continue
|
|
26182
26169
|
console.error(err_2 && err_2.message || err_2, err_2);
|
|
26183
26170
|
return [3 /*break*/, 6];
|
|
26184
|
-
case 6:
|
|
26185
|
-
if (row.editing)
|
|
26186
|
-
this._editingRowCount++;
|
|
26187
|
-
return [2 /*return*/, row];
|
|
26171
|
+
case 6: return [2 /*return*/, row];
|
|
26188
26172
|
case 7:
|
|
26189
26173
|
this._creating = false;
|
|
26190
26174
|
return [7 /*endfinally*/];
|
|
@@ -26209,8 +26193,8 @@
|
|
|
26209
26193
|
case 0:
|
|
26210
26194
|
if (!this._fetchMoreFn)
|
|
26211
26195
|
return [2 /*return*/, false]; // Avoid multiple call
|
|
26212
|
-
if (this.
|
|
26213
|
-
console.warn("Cannot fetch more " + this._entityName + " because
|
|
26196
|
+
if (this.hasSomeEditingRow()) {
|
|
26197
|
+
console.warn("Cannot fetch more " + this._entityName + " because some row) still editing");
|
|
26214
26198
|
return [2 /*return*/];
|
|
26215
26199
|
}
|
|
26216
26200
|
console.debug("Will fetching more row(s) still...");
|
|
@@ -26289,7 +26273,6 @@
|
|
|
26289
26273
|
this.savingSubject = new rxjs.BehaviorSubject(false);
|
|
26290
26274
|
this.dirtySubject = new rxjs.BehaviorSubject(false);
|
|
26291
26275
|
this.errorSubject = new rxjs.BehaviorSubject(undefined);
|
|
26292
|
-
this.isRateLimitReached = false;
|
|
26293
26276
|
this.selection = new collections.SelectionModel(true, []);
|
|
26294
26277
|
this.editedRow = undefined;
|
|
26295
26278
|
this.i18nColumnPrefix = 'COMMON.';
|
|
@@ -26697,7 +26680,7 @@
|
|
|
26697
26680
|
return rxjs.of(undefined); // Continue
|
|
26698
26681
|
}))
|
|
26699
26682
|
.subscribe(function (res) { return _this.updateView(res); }));
|
|
26700
|
-
// Listen dataSource events
|
|
26683
|
+
// Listen dataSource loading events
|
|
26701
26684
|
if (this._dataSource)
|
|
26702
26685
|
this.listenDatasourceLoading(this._dataSource);
|
|
26703
26686
|
};
|
|
@@ -26779,7 +26762,6 @@
|
|
|
26779
26762
|
if (!res)
|
|
26780
26763
|
return [2 /*return*/]; // Skip (e.g error)
|
|
26781
26764
|
if (res && res.data) {
|
|
26782
|
-
this.isRateLimitReached = !this.paginator || (res.data.length < this.paginator.pageSize);
|
|
26783
26765
|
this.visibleRowCount = res.data.length;
|
|
26784
26766
|
this.totalRowCount = isNotNil(res.total) ? res.total : ((this.paginator && this.paginator.pageIndex * (this.paginator.pageSize || DEFAULT_PAGE_SIZE) || 0) + this.visibleRowCount);
|
|
26785
26767
|
if (this.debug)
|
|
@@ -26787,7 +26769,6 @@
|
|
|
26787
26769
|
}
|
|
26788
26770
|
else {
|
|
26789
26771
|
//if (this.debug) console.debug('[table] NO rows loaded');
|
|
26790
|
-
this.isRateLimitReached = true;
|
|
26791
26772
|
this.totalRowCount = 0;
|
|
26792
26773
|
this.visibleRowCount = 0;
|
|
26793
26774
|
}
|
|
@@ -27196,22 +27177,19 @@
|
|
|
27196
27177
|
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
27197
27178
|
// Exclude invalid rows (because of save() will fail, when exists some invalid rows)
|
|
27198
27179
|
rows = rows.filter(function (row) {
|
|
27199
|
-
if
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27204
|
-
|
|
27205
|
-
|
|
27206
|
-
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
|
|
27211
|
-
|
|
27212
|
-
_this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|
|
27213
|
-
// Continue: the row will be deleted after the save
|
|
27214
|
-
}
|
|
27180
|
+
// Delete the row, if newly created row (id = -1), or if invalid and not editing (= not cancellable)
|
|
27181
|
+
if (row.id === -1 || (!row.valid && !row.editing)) {
|
|
27182
|
+
row.delete();
|
|
27183
|
+
_this.visibleRowCount--;
|
|
27184
|
+
_this.totalRowCount--;
|
|
27185
|
+
return false;
|
|
27186
|
+
}
|
|
27187
|
+
// Cancel the row (and mark as pristine), when not valid but in edition
|
|
27188
|
+
else if (!row.valid && row.editing) {
|
|
27189
|
+
row.cancel();
|
|
27190
|
+
// Mark row as pristine (if possible)
|
|
27191
|
+
_this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|
|
27192
|
+
return true; // Keep the row. the row will be deleted after the save
|
|
27215
27193
|
}
|
|
27216
27194
|
return true;
|
|
27217
27195
|
});
|
|
@@ -28056,8 +28034,9 @@
|
|
|
28056
28034
|
if (this.debug)
|
|
28057
28035
|
console.debug('[table] Many call to listenDatasource(): Cleaning previous subscriptions...');
|
|
28058
28036
|
this._dataSourceLoadingSubscription.unsubscribe();
|
|
28059
|
-
this.
|
|
28037
|
+
this.unregisterSubscription(this._dataSourceLoadingSubscription);
|
|
28060
28038
|
}
|
|
28039
|
+
// Propage loading to table
|
|
28061
28040
|
this._dataSourceLoadingSubscription = this._dataSource.loadingSubject
|
|
28062
28041
|
.pipe(operators.distinctUntilChanged(),
|
|
28063
28042
|
// If changed to True: propagate as soon as possible
|
|
@@ -28065,7 +28044,7 @@
|
|
|
28065
28044
|
// If changed to False: wait 250ms before propagate (to make sure the spinner has been displayed)
|
|
28066
28045
|
operators.debounceTime(250), operators.tap(function (loading) { return !loading && _this.setLoading(false); }))
|
|
28067
28046
|
.subscribe();
|
|
28068
|
-
this.
|
|
28047
|
+
this.registerSubscription(this._dataSourceLoadingSubscription);
|
|
28069
28048
|
};
|
|
28070
28049
|
AppTable.prototype.startCellValueChanges = function (name, row) {
|
|
28071
28050
|
var def = this._cellValueChangesDefs[name];
|