@sumaris-net/ngx-components 1.23.1 → 1.23.2

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.
@@ -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._editingRowCount > 0) {
25894
- console.warn("[table-datasource] Received " + _this._entityName + " data, while " + _this._editingRowCount + " rows still editing: skip; Please check save() implementation in the table!");
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
- if (row.editing)
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.loadingSubject.next(false);
26081
+ _this.markAsLoaded();
26090
26082
  }, 300);
26091
26083
  });
26092
26084
  };
@@ -26129,7 +26121,7 @@
26129
26121
  return [3 /*break*/, 5];
26130
26122
  case 3:
26131
26123
  err_1 = _b.sent();
26132
- // Handle sservice error
26124
+ // Handle service error
26133
26125
  this.handleServiceError(err_1);
26134
26126
  return [3 /*break*/, 5];
26135
26127
  case 4:
@@ -26146,6 +26138,9 @@
26146
26138
  EntitiesTableDataSource.prototype.getRows = function () {
26147
26139
  return this.rowsSubject.getValue();
26148
26140
  };
26141
+ EntitiesTableDataSource.prototype.hasSomeEditingRow = function () {
26142
+ return (this.rowsSubject.value || []).some(function (row) { return row.editing; });
26143
+ };
26149
26144
  EntitiesTableDataSource.prototype.createNew = function (insertAt, options) {
26150
26145
  if (options === void 0) { options = { editing: true }; }
26151
26146
  var _super = Object.create(null, {
@@ -26181,10 +26176,7 @@
26181
26176
  // Log, then continue
26182
26177
  console.error(err_2 && err_2.message || err_2, err_2);
26183
26178
  return [3 /*break*/, 6];
26184
- case 6:
26185
- if (row.editing)
26186
- this._editingRowCount++;
26187
- return [2 /*return*/, row];
26179
+ case 6: return [2 /*return*/, row];
26188
26180
  case 7:
26189
26181
  this._creating = false;
26190
26182
  return [7 /*endfinally*/];
@@ -26209,8 +26201,8 @@
26209
26201
  case 0:
26210
26202
  if (!this._fetchMoreFn)
26211
26203
  return [2 /*return*/, false]; // Avoid multiple call
26212
- if (this._editingRowCount > 0) {
26213
- console.warn("Cannot fetch more " + this._entityName + " because " + this._editingRowCount + " row(s) still editing");
26204
+ if (this.hasSomeEditingRow()) {
26205
+ console.warn("Cannot fetch more " + this._entityName + " because some row) still editing");
26214
26206
  return [2 /*return*/];
26215
26207
  }
26216
26208
  console.debug("Will fetching more row(s) still...");
@@ -26289,7 +26281,6 @@
26289
26281
  this.savingSubject = new rxjs.BehaviorSubject(false);
26290
26282
  this.dirtySubject = new rxjs.BehaviorSubject(false);
26291
26283
  this.errorSubject = new rxjs.BehaviorSubject(undefined);
26292
- this.isRateLimitReached = false;
26293
26284
  this.selection = new collections.SelectionModel(true, []);
26294
26285
  this.editedRow = undefined;
26295
26286
  this.i18nColumnPrefix = 'COMMON.';
@@ -26779,7 +26770,6 @@
26779
26770
  if (!res)
26780
26771
  return [2 /*return*/]; // Skip (e.g error)
26781
26772
  if (res && res.data) {
26782
- this.isRateLimitReached = !this.paginator || (res.data.length < this.paginator.pageSize);
26783
26773
  this.visibleRowCount = res.data.length;
26784
26774
  this.totalRowCount = isNotNil(res.total) ? res.total : ((this.paginator && this.paginator.pageIndex * (this.paginator.pageSize || DEFAULT_PAGE_SIZE) || 0) + this.visibleRowCount);
26785
26775
  if (this.debug)
@@ -26787,7 +26777,6 @@
26787
26777
  }
26788
26778
  else {
26789
26779
  //if (this.debug) console.debug('[table] NO rows loaded');
26790
- this.isRateLimitReached = true;
26791
26780
  this.totalRowCount = 0;
26792
26781
  this.visibleRowCount = 0;
26793
26782
  }
@@ -27196,22 +27185,19 @@
27196
27185
  if (!this.saveBeforeDelete) return [3 /*break*/, 3];
27197
27186
  // Exclude invalid rows (because of save() will fail, when exists some invalid rows)
27198
27187
  rows = rows.filter(function (row) {
27199
- if (row.validator && !row.validator.valid) {
27200
- // When deleted (= newly created row) : decrement counter
27201
- if (row.id === -1 || !row.editing) {
27202
- row.delete();
27203
- _this.visibleRowCount--;
27204
- _this.totalRowCount--;
27205
- return false; // Remove this row to the list, because already deleted
27206
- }
27207
- // Mark row as pristine, to avoid row to be saved even if still invalid
27208
- else {
27209
- // Will cancel only (delete will always go into the previous 'if')
27210
- row.cancelOrDelete();
27211
- // Mark row as pristine (if possible)
27212
- _this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
27213
- // Continue: the row will be deleted after the save
27214
- }
27188
+ // Delete the row, if newly created row (id = -1), or if invalid and not editing (= not cancellable)
27189
+ if (row.id === -1 || (!row.valid && !row.editing)) {
27190
+ row.delete();
27191
+ _this.visibleRowCount--;
27192
+ _this.totalRowCount--;
27193
+ return false;
27194
+ }
27195
+ // Cancel the row (and mark as pristine), when not valid but in edition
27196
+ else if (!row.valid && row.editing) {
27197
+ row.cancel();
27198
+ // Mark row as pristine (if possible)
27199
+ _this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
27200
+ return true; // Keep the row. the row will be deleted after the save
27215
27201
  }
27216
27202
  return true;
27217
27203
  });