@sumaris-net/ngx-components 1.12.3 → 1.12.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.
@@ -25581,18 +25581,28 @@
25581
25581
  canDelete = _e.sent();
25582
25582
  if (!canDelete)
25583
25583
  return [2 /*return*/, 0]; // Cannot delete
25584
+ // Reverse row order (on a copy)
25585
+ // This is a workaround, need because row.delete() has async execution
25586
+ // and index cache is updated with a delay
25587
+ rows = rows.slice()
25588
+ .sort(function (a, b) { return a.id > b.id ? -1 : 1; });
25584
25589
  if (!this.saveBeforeDelete) return [3 /*break*/, 3];
25585
25590
  // Cancel invalid rows (because of save() will fail, if invalid rows exists)
25586
25591
  rows = rows.reduce(function (res, row) {
25587
25592
  if (row.validator && !row.validator.valid) {
25588
- var deleted = row.id === -1;
25589
- row.cancelOrDelete();
25590
25593
  // When deleted (= newly created row) : decrement counter
25591
- if (deleted) {
25594
+ if (row.id === -1 || !row.editing) {
25595
+ row.delete();
25592
25596
  _this.visibleRowCount--;
25593
25597
  _this.totalRowCount--;
25594
25598
  return res;
25595
25599
  }
25600
+ // Mark row as pristine, to avoid row to be saved
25601
+ else {
25602
+ row.cancelOrDelete(); // Will cancel only (delete will always go into the previous 'if')
25603
+ row.validator.markAsPristine();
25604
+ // Continue: the row will be deleted after the save
25605
+ }
25596
25606
  }
25597
25607
  return res.concat(row);
25598
25608
  }, []);
@@ -25611,11 +25621,6 @@
25611
25621
  if (!deleteCount) return [3 /*break*/, 5];
25612
25622
  if (this.debug)
25613
25623
  console.debug('[table] Delete selected rows...');
25614
- // Reverse row order (on a copy)
25615
- // This is a workaround, need because row.delete() has async execution
25616
- // and index cache is updated with a delay
25617
- rows = rows.slice()
25618
- .sort(function (a, b) { return a.id > b.id ? -1 : 1; });
25619
25624
  return [4 /*yield*/, this._dataSource.deleteAll(rows)];
25620
25625
  case 4:
25621
25626
  _e.sent();