@sumaris-net/ngx-components 1.5.9 → 1.5.10

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.
@@ -24895,6 +24895,7 @@
24895
24895
  var _a;
24896
24896
  return __awaiter(this, void 0, void 0, function () {
24897
24897
  var confirmed, canDelete, saved, rowsToDelete, deleteCount, err_2;
24898
+ var _this = this;
24898
24899
  return __generator(this, function (_d) {
24899
24900
  switch (_d.label) {
24900
24901
  case 0:
@@ -24920,9 +24921,17 @@
24920
24921
  if (!canDelete)
24921
24922
  return [2 /*return*/, 0]; // Cannot delete
24922
24923
  if (!this.saveBeforeDelete) return [3 /*break*/, 3];
24923
- // Cancel invalid rows (because of save() will failed if there is invalid rows)
24924
+ // Cancel invalid rows (because of save() will fail, if invalid rows exists)
24924
24925
  rows.filter(function (row) { var _a; return !((_a = row.validator) === null || _a === void 0 ? void 0 : _a.valid); })
24925
- .forEach(function (row) { return row.cancelOrDelete(); });
24926
+ .forEach(function (row) {
24927
+ var deleted = row.id === -1;
24928
+ row.cancelOrDelete();
24929
+ // When deleted (= newly created row) : decrement counter
24930
+ if (deleted) {
24931
+ _this.visibleRowCount--;
24932
+ _this.totalRowCount--;
24933
+ }
24934
+ });
24926
24935
  return [4 /*yield*/, this.saveBeforeAction('delete')];
24927
24936
  case 2:
24928
24937
  saved = _d.sent();
@@ -24946,10 +24955,9 @@
24946
24955
  return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
24947
24956
  case 5:
24948
24957
  _d.sent();
24949
- // Update manually, even if watchALl().subscribe() will update this count,
24950
- // because of memory data service (see issue #
24951
- this.totalRowCount -= deleteCount;
24952
- this.visibleRowCount -= deleteCount;
24958
+ // DO not update manually, because watchALl().subscribe() will update this count
24959
+ //this.totalRowCount -= deleteCount;
24960
+ //this.visibleRowCount -= deleteCount;
24953
24961
  this.selection.clear();
24954
24962
  this.editedRow = undefined;
24955
24963
  this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });