@sumaris-net/ngx-components 1.23.4 → 1.23.7

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.
@@ -17509,6 +17509,7 @@ class AppForm {
17509
17509
  this._subscription = new Subscription();
17510
17510
  this._enable = false;
17511
17511
  this.i18nFieldPrefix = null;
17512
+ this.destroySubject = new Subject();
17512
17513
  this.readySubject = new BehaviorSubject(false);
17513
17514
  this.loadingSubject = new BehaviorSubject(true);
17514
17515
  this.errorSubject = new BehaviorSubject(undefined);
@@ -17630,6 +17631,8 @@ class AppForm {
17630
17631
  this.errorSubject.unsubscribe();
17631
17632
  this.onCancel.unsubscribe();
17632
17633
  this.onSubmit.unsubscribe();
17634
+ this.destroySubject.next();
17635
+ this.destroySubject.unsubscribe();
17633
17636
  }
17634
17637
  cancel() {
17635
17638
  return __awaiter(this, void 0, void 0, function* () {
@@ -22596,13 +22599,13 @@ class EntitiesTableDataSource extends TableDataSource {
22596
22599
  // Call service deletion
22597
22600
  yield this.dataService.deleteAll(data, this.serviceOptions);
22598
22601
  // Workaround, to be sure all rows have been deleted
22599
- // Sometimes, the service miss deletion, or GrapQHl cache remove failed.
22602
+ // Sometime, the service miss deletion, or GraphQl cache remove failed.
22600
22603
  // In this case, apply missing deletion using the super.delete() function
22601
- const rowNotDeleted = this.getRows().filter(rows.includes);
22604
+ const rowNotDeleted = this.getRows().filter(row => rows.includes(row));
22602
22605
  if (isNotEmptyArray(rowNotDeleted)) {
22603
- console.warn(`[table-datasource] Force deletion of ${rowNotDeleted.length} rows (Is service update the cache ?)`);
22606
+ console.warn(`[table-datasource] Force deletion of ${rowNotDeleted.length} rows! Please check that data service update the cache, after deletion`);
22604
22607
  rowNotDeleted
22605
- // Start from the end
22608
+ // Start at the end
22606
22609
  .sort((a, b) => a.id > b.id ? -1 : 1)
22607
22610
  .forEach(r => _super.delete.call(this, r.id));
22608
22611
  }
@@ -22729,8 +22732,8 @@ class AppTable {
22729
22732
  this._subscription = new Subscription();
22730
22733
  this._cellValueChangesDefs = {};
22731
22734
  this._enabled = true;
22732
- this._destroy$ = new Subject();
22733
22735
  this.allowRowDetail = true;
22736
+ this.destroySubject = new Subject();
22734
22737
  this.excludesColumns = [];
22735
22738
  this.totalRowCount = null;
22736
22739
  this.readySubject = new BehaviorSubject(false);
@@ -23025,7 +23028,7 @@ class AppTable {
23025
23028
  // Stop if next another row, or destroying
23026
23029
  combineLatest([
23027
23030
  this.onStartEditingRow,
23028
- this._destroy$
23031
+ this.destroySubject
23029
23032
  ])
23030
23033
  // DEBUG
23031
23034
  //.pipe(
@@ -23122,8 +23125,8 @@ class AppTable {
23122
23125
  this.onSort.unsubscribe();
23123
23126
  this.onDirty.unsubscribe();
23124
23127
  this.onError.unsubscribe();
23125
- this._destroy$.next();
23126
- this._destroy$.unsubscribe();
23128
+ this.destroySubject.next();
23129
+ this.destroySubject.unsubscribe();
23127
23130
  (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
23128
23131
  }
23129
23132
  updateView(res, opts) {
@@ -23259,7 +23262,6 @@ class AppTable {
23259
23262
  // Stop event
23260
23263
  event === null || event === void 0 ? void 0 : event.stopPropagation();
23261
23264
  // Confirmation edition or creation
23262
- //const confirmed = this.dataSource.confirmEditCreate(row);
23263
23265
  const confirmed = row.confirmEditCreate();
23264
23266
  if (confirmed) {
23265
23267
  // If edit finished, forget edited row
@@ -23484,18 +23486,22 @@ class AppTable {
23484
23486
  // Reverse row order (on a copy)
23485
23487
  // This is a workaround, need because row.delete() has async execution
23486
23488
  // and index cache is updated with a delay
23487
- rows = rows.slice()
23489
+ let tempRows = rows.slice()
23488
23490
  .sort((a, b) => a.id > b.id ? -1 : 1);
23491
+ let deletedRows = [];
23489
23492
  // If data need to be saved first
23490
23493
  if (this.saveBeforeDelete) {
23491
23494
  // Exclude invalid rows (because of save() will fail, when exists some invalid rows)
23492
- rows = rows.filter(row => {
23495
+ tempRows = tempRows.filter(row => {
23493
23496
  // Delete the row, if newly created row (id = -1), or if invalid and not editing (= not cancellable)
23494
23497
  if (row.id === -1 || (!row.valid && !row.editing)) {
23498
+ if (this.debug)
23499
+ console.debug(`[table] Delete row #${row.id}`);
23495
23500
  row.delete();
23496
23501
  this.visibleRowCount--;
23497
23502
  this.totalRowCount--;
23498
- return false;
23503
+ deletedRows.push(row);
23504
+ return false; // Exclude from the list to delete using the service
23499
23505
  }
23500
23506
  // Cancel the row (and mark as pristine), when not valid but in edition
23501
23507
  else if (!row.valid && row.editing) {
@@ -23508,7 +23514,7 @@ class AppTable {
23508
23514
  });
23509
23515
  // Apply save, only if there is still some rows to delete
23510
23516
  // WARN: If no more rows (e.g. because all has been cancelled) then continue anyway to clear editedRow and selection (issue IMAGINE-669)
23511
- if (isNotEmptyArray(rows)) {
23517
+ if (deletedRows.length || tempRows.length) {
23512
23518
  // Save data (e.g. when using memory service)
23513
23519
  const saved = yield this.saveBeforeAction('delete');
23514
23520
  if (!saved) {
@@ -23518,13 +23524,12 @@ class AppTable {
23518
23524
  }
23519
23525
  }
23520
23526
  try {
23521
- const deleteCount = rows.length;
23522
23527
  // Apply deletion on datasource
23523
23528
  // If no more rows to delete, continue anyway to clear editedRow and selection (issue IMAGINE-669)
23524
- if (deleteCount) {
23529
+ if (tempRows.length) {
23525
23530
  if (this.debug)
23526
- console.debug('[table] Delete selected rows...');
23527
- yield this._dataSource.deleteAll(rows);
23531
+ console.debug(`[table] Delete ${tempRows.length} rows...`);
23532
+ yield this._dataSource.deleteAll(tempRows);
23528
23533
  }
23529
23534
  // DO not update manually, because watchALl().subscribe() will update this count
23530
23535
  //this.totalRowCount -= deleteCount;
@@ -23533,9 +23538,8 @@ class AppTable {
23533
23538
  this.editedRow = undefined;
23534
23539
  this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
23535
23540
  this.markForCheck();
23536
- if (deleteCount)
23537
- this.onAfterDeletedRows.next(rows);
23538
- return deleteCount;
23541
+ this.onAfterDeletedRows.next(rows);
23542
+ return rows.length;
23539
23543
  }
23540
23544
  catch (err) {
23541
23545
  this.setError(err && err.message || err);
@@ -24342,6 +24346,7 @@ class AppEditor {
24342
24346
  this._subscription = new Subscription();
24343
24347
  this._enabled = false;
24344
24348
  this._dirty = false;
24349
+ this.destroySubject = new Subject();
24345
24350
  this.readySubject = new BehaviorSubject(false);
24346
24351
  this.loadingSubject = new BehaviorSubject(true);
24347
24352
  this.errorSubject = new BehaviorSubject(undefined);
@@ -24426,13 +24431,15 @@ class AppEditor {
24426
24431
  }
24427
24432
  }
24428
24433
  ngAfterViewInit() {
24429
- // Can be override by subclasses
24434
+ // Can be overridden by subclasses
24430
24435
  }
24431
24436
  ngOnDestroy() {
24432
24437
  this._subscription.unsubscribe();
24433
24438
  this.readySubject.unsubscribe();
24434
24439
  this.loadingSubject.unsubscribe();
24435
24440
  this.errorSubject.unsubscribe();
24441
+ this.destroySubject.next();
24442
+ this.destroySubject.unsubscribe();
24436
24443
  }
24437
24444
  addChildForm(form) {
24438
24445
  if (!form)