@sumaris-net/ngx-components 1.23.5 → 1.23.8

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.
@@ -20036,6 +20036,7 @@
20036
20036
  this._subscription = new rxjs.Subscription();
20037
20037
  this._enable = false;
20038
20038
  this.i18nFieldPrefix = null;
20039
+ this.destroySubject = new rxjs.Subject();
20039
20040
  this.readySubject = new rxjs.BehaviorSubject(false);
20040
20041
  this.loadingSubject = new rxjs.BehaviorSubject(true);
20041
20042
  this.errorSubject = new rxjs.BehaviorSubject(undefined);
@@ -20221,6 +20222,8 @@
20221
20222
  this.errorSubject.unsubscribe();
20222
20223
  this.onCancel.unsubscribe();
20223
20224
  this.onSubmit.unsubscribe();
20225
+ this.destroySubject.next();
20226
+ this.destroySubject.unsubscribe();
20224
20227
  };
20225
20228
  AppForm.prototype.cancel = function () {
20226
20229
  return __awaiter(this, void 0, void 0, function () {
@@ -26102,7 +26105,7 @@
26102
26105
  case 2:
26103
26106
  // Call service deletion
26104
26107
  _b.sent();
26105
- rowNotDeleted = this.getRows().filter(rows.includes);
26108
+ rowNotDeleted = this.getRows().filter(function (row) { return rows.includes(row); });
26106
26109
  if (isNotEmptyArray(rowNotDeleted)) {
26107
26110
  console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows! Please check that data service update the cache, after deletion");
26108
26111
  rowNotDeleted
@@ -26264,8 +26267,8 @@
26264
26267
  this._subscription = new rxjs.Subscription();
26265
26268
  this._cellValueChangesDefs = {};
26266
26269
  this._enabled = true;
26267
- this._destroy$ = new rxjs.Subject();
26268
26270
  this.allowRowDetail = true;
26271
+ this.destroySubject = new rxjs.Subject();
26269
26272
  this.excludesColumns = [];
26270
26273
  this.totalRowCount = null;
26271
26274
  this.readySubject = new rxjs.BehaviorSubject(false);
@@ -26649,7 +26652,7 @@
26649
26652
  // Stop if next another row, or destroying
26650
26653
  rxjs.combineLatest([
26651
26654
  _this.onStartEditingRow,
26652
- _this._destroy$
26655
+ _this.destroySubject
26653
26656
  ])
26654
26657
  // DEBUG
26655
26658
  //.pipe(
@@ -26752,8 +26755,8 @@
26752
26755
  this.onSort.unsubscribe();
26753
26756
  this.onDirty.unsubscribe();
26754
26757
  this.onError.unsubscribe();
26755
- this._destroy$.next();
26756
- this._destroy$.unsubscribe();
26758
+ this.destroySubject.next();
26759
+ this.destroySubject.unsubscribe();
26757
26760
  (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
26758
26761
  };
26759
26762
  AppTable.prototype.updateView = function (res, opts) {
@@ -26904,7 +26907,6 @@
26904
26907
  // Stop event
26905
26908
  event === null || event === void 0 ? void 0 : event.stopPropagation();
26906
26909
  // Confirmation edition or creation
26907
- //const confirmed = this.dataSource.confirmEditCreate(row);
26908
26910
  var confirmed = row.confirmEditCreate();
26909
26911
  if (confirmed) {
26910
26912
  // If edit finished, forget edited row
@@ -27141,7 +27143,7 @@
27141
27143
  AppTable.prototype.deleteRows = function (event, rows, opts) {
27142
27144
  var _a;
27143
27145
  return __awaiter(this, void 0, void 0, function () {
27144
- var confirmed, canDelete, saved, deleteCount, err_2;
27146
+ var confirmed, canDelete, tempRows, deletedRows, saved, err_2;
27145
27147
  var _this = this;
27146
27148
  return __generator(this, function (_e) {
27147
27149
  switch (_e.label) {
@@ -27169,20 +27171,23 @@
27169
27171
  canDelete = _e.sent();
27170
27172
  if (!canDelete)
27171
27173
  return [2 /*return*/, 0]; // Cannot delete
27172
- // Reverse row order (on a copy)
27173
- // This is a workaround, need because row.delete() has async execution
27174
- // and index cache is updated with a delay
27175
- rows = rows.slice()
27174
+ tempRows = rows.slice()
27176
27175
  .sort(function (a, b) { return a.id > b.id ? -1 : 1; });
27176
+ deletedRows = [];
27177
27177
  if (!this.saveBeforeDelete) return [3 /*break*/, 3];
27178
27178
  // Exclude invalid rows (because of save() will fail, when exists some invalid rows)
27179
- rows = rows.filter(function (row) {
27179
+ tempRows = tempRows.filter(function (row) {
27180
27180
  // Delete the row, if newly created row (id = -1), or if invalid and not editing (= not cancellable)
27181
27181
  if (row.id === -1 || (!row.valid && !row.editing)) {
27182
+ if (_this.debug)
27183
+ console.debug("[table] Delete row #" + row.id);
27182
27184
  row.delete();
27183
27185
  _this.visibleRowCount--;
27184
27186
  _this.totalRowCount--;
27185
- return false;
27187
+ deletedRows.push(row);
27188
+ if (_this.editedRow === row)
27189
+ _this.editedRow = undefined;
27190
+ return false; // Exclude from the list to delete using the service
27186
27191
  }
27187
27192
  // Cancel the row (and mark as pristine), when not valid but in edition
27188
27193
  else if (!row.valid && row.editing) {
@@ -27193,7 +27198,7 @@
27193
27198
  }
27194
27199
  return true;
27195
27200
  });
27196
- if (!isNotEmptyArray(rows)) return [3 /*break*/, 3];
27201
+ if (!(deletedRows.length || tempRows.length)) return [3 /*break*/, 3];
27197
27202
  return [4 /*yield*/, this.saveBeforeAction('delete')];
27198
27203
  case 2:
27199
27204
  saved = _e.sent();
@@ -27204,11 +27209,10 @@
27204
27209
  _e.label = 3;
27205
27210
  case 3:
27206
27211
  _e.trys.push([3, 6, , 7]);
27207
- deleteCount = rows.length;
27208
- if (!deleteCount) return [3 /*break*/, 5];
27212
+ if (!tempRows.length) return [3 /*break*/, 5];
27209
27213
  if (this.debug)
27210
- console.debug('[table] Delete selected rows...');
27211
- return [4 /*yield*/, this._dataSource.deleteAll(rows)];
27214
+ console.debug("[table] Delete " + tempRows.length + " rows...");
27215
+ return [4 /*yield*/, this._dataSource.deleteAll(tempRows)];
27212
27216
  case 4:
27213
27217
  _e.sent();
27214
27218
  _e.label = 5;
@@ -27220,9 +27224,8 @@
27220
27224
  this.editedRow = undefined;
27221
27225
  this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
27222
27226
  this.markForCheck();
27223
- if (deleteCount)
27224
- this.onAfterDeletedRows.next(rows);
27225
- return [2 /*return*/, deleteCount];
27227
+ this.onAfterDeletedRows.next(rows);
27228
+ return [2 /*return*/, rows.length];
27226
27229
  case 6:
27227
27230
  err_2 = _e.sent();
27228
27231
  this.setError(err_2 && err_2.message || err_2);
@@ -28163,6 +28166,7 @@
28163
28166
  this._subscription = new rxjs.Subscription();
28164
28167
  this._enabled = false;
28165
28168
  this._dirty = false;
28169
+ this.destroySubject = new rxjs.Subject();
28166
28170
  this.readySubject = new rxjs.BehaviorSubject(false);
28167
28171
  this.loadingSubject = new rxjs.BehaviorSubject(true);
28168
28172
  this.errorSubject = new rxjs.BehaviorSubject(undefined);
@@ -28312,13 +28316,15 @@
28312
28316
  }
28313
28317
  };
28314
28318
  AppEditor.prototype.ngAfterViewInit = function () {
28315
- // Can be override by subclasses
28319
+ // Can be overridden by subclasses
28316
28320
  };
28317
28321
  AppEditor.prototype.ngOnDestroy = function () {
28318
28322
  this._subscription.unsubscribe();
28319
28323
  this.readySubject.unsubscribe();
28320
28324
  this.loadingSubject.unsubscribe();
28321
28325
  this.errorSubject.unsubscribe();
28326
+ this.destroySubject.next();
28327
+ this.destroySubject.unsubscribe();
28322
28328
  };
28323
28329
  AppEditor.prototype.addChildForm = function (form) {
28324
28330
  if (!form)