@sumaris-net/ngx-components 1.9.2 → 1.9.3

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.
@@ -25059,7 +25059,7 @@
25059
25059
  rxjs.merge(
25060
25060
  // Listen sort events
25061
25061
  this.sort && this.sort.sortChange
25062
- .pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_d) {
25062
+ .pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
25063
25063
  return [2 /*return*/, this.saveBeforeAction('sort')];
25064
25064
  }); }); }), operators.filter(function (res) { return res === true; }),
25065
25065
  // Save sort in settings
@@ -25070,7 +25070,7 @@
25070
25070
  || rxjs.EMPTY,
25071
25071
  // Listen paginator events
25072
25072
  this.paginator && this.paginator.page
25073
- .pipe(operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_d) {
25073
+ .pipe(operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
25074
25074
  return [2 /*return*/, this.saveBeforeAction('sort')];
25075
25075
  }); }); }), operators.filter(function (res) { return res === true; }),
25076
25076
  // Save page size
@@ -25115,7 +25115,7 @@
25115
25115
  };
25116
25116
  AppTable.prototype.updateView = function (res, opts) {
25117
25117
  return __awaiter(this, void 0, void 0, function () {
25118
- return __generator(this, function (_d) {
25118
+ return __generator(this, function (_e) {
25119
25119
  if (!res)
25120
25120
  return [2 /*return*/]; // Skip (e.g error)
25121
25121
  if (res && res.data) {
@@ -25224,8 +25224,8 @@
25224
25224
  AppTable.prototype.editRowById = function (event, id, opts) {
25225
25225
  return __awaiter(this, void 0, void 0, function () {
25226
25226
  var row;
25227
- return __generator(this, function (_d) {
25228
- switch (_d.label) {
25227
+ return __generator(this, function (_e) {
25228
+ switch (_e.label) {
25229
25229
  case 0:
25230
25230
  if (id < 0)
25231
25231
  return [2 /*return*/];
@@ -25235,9 +25235,9 @@
25235
25235
  return [3 /*break*/, 3];
25236
25236
  case 1: return [4 /*yield*/, this.dataSource.getRow(id)];
25237
25237
  case 2:
25238
- row = _d.sent();
25238
+ row = _e.sent();
25239
25239
  this.editRow(event, row, opts);
25240
- _d.label = 3;
25240
+ _e.label = 3;
25241
25241
  case 3: return [2 /*return*/];
25242
25242
  }
25243
25243
  });
@@ -25322,11 +25322,11 @@
25322
25322
  return true;
25323
25323
  };
25324
25324
  AppTable.prototype.save = function (opts) {
25325
- var _a, _b;
25325
+ var _a, _b, _c, _d;
25326
25326
  return __awaiter(this, void 0, void 0, function () {
25327
25327
  var previouslyEditedData, isOK, err_1;
25328
- return __generator(this, function (_d) {
25329
- switch (_d.label) {
25328
+ return __generator(this, function (_e) {
25329
+ switch (_e.label) {
25330
25330
  case 0:
25331
25331
  opts = Object.assign({ keepEditing: this.keepEditedRowOnSave }, opts);
25332
25332
  if (this.readOnly) {
@@ -25334,27 +25334,27 @@
25334
25334
  }
25335
25335
  this.resetError();
25336
25336
  // Keep edited row id (should be done BEFORE confirmEditCreate() )
25337
- this.previouslyEditedRowId = opts.keepEditing && ((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined;
25338
- previouslyEditedData = isNotNil(this.previouslyEditedRowId) && this.editedRow.currentData || ((_b = this.singleSelectedRow) === null || _b === void 0 ? void 0 : _b.currentData);
25337
+ this.previouslyEditedRowId = opts.keepEditing && ((((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined) || ((_b = this.singleSelectedRow) === null || _b === void 0 ? void 0 : _b.id));
25338
+ previouslyEditedData = isNotNil(this.previouslyEditedRowId) && ((_c = this.editedRow) === null || _c === void 0 ? void 0 : _c.currentData) || ((_d = this.singleSelectedRow) === null || _d === void 0 ? void 0 : _d.currentData);
25339
25339
  if (!this.confirmEditCreate()) {
25340
25340
  throw { code: ErrorCodes$2.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
25341
25341
  }
25342
25342
  // Mark as saving
25343
25343
  this.markAsSaving();
25344
- _d.label = 1;
25344
+ _e.label = 1;
25345
25345
  case 1:
25346
- _d.trys.push([1, 3, 4, 7]);
25346
+ _e.trys.push([1, 3, 4, 7]);
25347
25347
  // Calling service save()
25348
25348
  if (this.debug)
25349
25349
  console.debug('[table] Calling dataSource.save()...');
25350
25350
  return [4 /*yield*/, this._dataSource.save()];
25351
25351
  case 2:
25352
- isOK = _d.sent();
25352
+ isOK = _e.sent();
25353
25353
  if (isOK)
25354
25354
  this.markAsPristine();
25355
25355
  return [2 /*return*/, isOK];
25356
25356
  case 3:
25357
- err_1 = _d.sent();
25357
+ err_1 = _e.sent();
25358
25358
  this.setError(err_1 && err_1.message || err_1);
25359
25359
  throw err_1;
25360
25360
  case 4:
@@ -25362,8 +25362,8 @@
25362
25362
  if (!isNotNil(this.previouslyEditedRowId)) return [3 /*break*/, 6];
25363
25363
  return [4 /*yield*/, this.selectRowByIdOrData(this.previouslyEditedRowId, previouslyEditedData)];
25364
25364
  case 5:
25365
- _d.sent();
25366
- _d.label = 6;
25365
+ _e.sent();
25366
+ _e.label = 6;
25367
25367
  case 6: return [7 /*endfinally*/];
25368
25368
  case 7: return [2 /*return*/];
25369
25369
  }
@@ -25388,8 +25388,8 @@
25388
25388
  var _a;
25389
25389
  return __awaiter(this, void 0, void 0, function () {
25390
25390
  var newRow, json, newData_1;
25391
- return __generator(this, function (_d) {
25392
- switch (_d.label) {
25391
+ return __generator(this, function (_e) {
25392
+ switch (_e.label) {
25393
25393
  case 0:
25394
25394
  event === null || event === void 0 ? void 0 : event.stopPropagation();
25395
25395
  row = row || this.singleSelectedRow;
@@ -25398,7 +25398,7 @@
25398
25398
  }
25399
25399
  return [4 /*yield*/, this.addRowToTable(row.id + 1)];
25400
25400
  case 1:
25401
- newRow = _d.sent();
25401
+ newRow = _e.sent();
25402
25402
  json = Object.assign(Object.assign({}, row.currentData), { id: null });
25403
25403
  // Reset some properties (e.g. rankOrder, etc)
25404
25404
  if (opts && opts.skipProperties) {
@@ -25437,8 +25437,8 @@
25437
25437
  return __awaiter(this, void 0, void 0, function () {
25438
25438
  var rows;
25439
25439
  var _this = this;
25440
- return __generator(this, function (_d) {
25441
- switch (_d.label) {
25440
+ return __generator(this, function (_e) {
25441
+ switch (_e.label) {
25442
25442
  case 0:
25443
25443
  if (this.loading)
25444
25444
  return [2 /*return*/];
@@ -25447,9 +25447,9 @@
25447
25447
  return [3 /*break*/, 3];
25448
25448
  case 1: return [4 /*yield*/, this._dataSource.getRows()];
25449
25449
  case 2:
25450
- rows = _d.sent();
25450
+ rows = _e.sent();
25451
25451
  rows.forEach(function (row) { return _this.selection.select(row); });
25452
- _d.label = 3;
25452
+ _e.label = 3;
25453
25453
  case 3: return [2 /*return*/];
25454
25454
  }
25455
25455
  });
@@ -25467,11 +25467,11 @@
25467
25467
  AppTable.prototype.deleteRow = function (event, row, opts) {
25468
25468
  return __awaiter(this, void 0, void 0, function () {
25469
25469
  var deleteCount;
25470
- return __generator(this, function (_d) {
25471
- switch (_d.label) {
25470
+ return __generator(this, function (_e) {
25471
+ switch (_e.label) {
25472
25472
  case 0: return [4 /*yield*/, this.deleteRows(event, [row], opts)];
25473
25473
  case 1:
25474
- deleteCount = _d.sent();
25474
+ deleteCount = _e.sent();
25475
25475
  return [2 /*return*/, deleteCount === 1];
25476
25476
  }
25477
25477
  });
@@ -25488,8 +25488,8 @@
25488
25488
  return __awaiter(this, void 0, void 0, function () {
25489
25489
  var confirmed, canDelete, saved, rowsToDelete, deleteCount, err_2;
25490
25490
  var _this = this;
25491
- return __generator(this, function (_d) {
25492
- switch (_d.label) {
25491
+ return __generator(this, function (_e) {
25492
+ switch (_e.label) {
25493
25493
  case 0:
25494
25494
  if (this.readOnly) {
25495
25495
  throw { code: ErrorCodes$2.TABLE_READ_ONLY, message: 'ERROR.TABLE_READ_ONLY' };
@@ -25509,7 +25509,7 @@
25509
25509
  }
25510
25510
  return [4 /*yield*/, this.canDeleteRows(rows, opts)];
25511
25511
  case 1:
25512
- canDelete = _d.sent();
25512
+ canDelete = _e.sent();
25513
25513
  if (!canDelete)
25514
25514
  return [2 /*return*/, 0]; // Cannot delete
25515
25515
  if (!this.saveBeforeDelete) return [3 /*break*/, 3];
@@ -25531,12 +25531,12 @@
25531
25531
  return [2 /*return*/, 0];
25532
25532
  return [4 /*yield*/, this.saveBeforeAction('delete')];
25533
25533
  case 2:
25534
- saved = _d.sent();
25534
+ saved = _e.sent();
25535
25535
  if (!saved) {
25536
25536
  // Stop if save cancelled or save failed
25537
25537
  return [2 /*return*/];
25538
25538
  }
25539
- _d.label = 3;
25539
+ _e.label = 3;
25540
25540
  case 3:
25541
25541
  if (this.debug)
25542
25542
  console.debug('[table] Delete selection...');
@@ -25545,13 +25545,13 @@
25545
25545
  // This is a workaround, need because row.delete() has async execution
25546
25546
  // and index cache is updated with a delay)
25547
25547
  .sort(function (a, b) { return a.id > b.id ? -1 : 1; });
25548
- _d.label = 4;
25548
+ _e.label = 4;
25549
25549
  case 4:
25550
- _d.trys.push([4, 6, , 7]);
25550
+ _e.trys.push([4, 6, , 7]);
25551
25551
  deleteCount = rowsToDelete.length;
25552
25552
  return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
25553
25553
  case 5:
25554
- _d.sent();
25554
+ _e.sent();
25555
25555
  // DO not update manually, because watchALl().subscribe() will update this count
25556
25556
  //this.totalRowCount -= deleteCount;
25557
25557
  //this.visibleRowCount -= deleteCount;
@@ -25562,7 +25562,7 @@
25562
25562
  this.onAfterDeletedRows.next(rowsToDelete);
25563
25563
  return [2 /*return*/, deleteCount];
25564
25564
  case 6:
25565
- err_2 = _d.sent();
25565
+ err_2 = _e.sent();
25566
25566
  this.setError(err_2 && err_2.message || err_2);
25567
25567
  throw err_2;
25568
25568
  case 7: return [2 /*return*/];
@@ -25573,14 +25573,14 @@
25573
25573
  AppTable.prototype.selectRowById = function (id) {
25574
25574
  return __awaiter(this, void 0, void 0, function () {
25575
25575
  var row;
25576
- return __generator(this, function (_d) {
25577
- switch (_d.label) {
25576
+ return __generator(this, function (_e) {
25577
+ switch (_e.label) {
25578
25578
  case 0:
25579
25579
  if (id === undefined)
25580
25580
  return [2 /*return*/, false];
25581
25581
  return [4 /*yield*/, this.waitIdle()];
25582
25582
  case 1:
25583
- _d.sent();
25583
+ _e.sent();
25584
25584
  row = this.dataSource.getRow(id);
25585
25585
  return [2 /*return*/, this.clickRow(null, row)];
25586
25586
  }
@@ -25595,17 +25595,17 @@
25595
25595
  return __awaiter(this, void 0, void 0, function () {
25596
25596
  var row;
25597
25597
  var _this = this;
25598
- return __generator(this, function (_d) {
25599
- switch (_d.label) {
25598
+ return __generator(this, function (_e) {
25599
+ switch (_e.label) {
25600
25600
  case 0:
25601
25601
  if (data === undefined)
25602
25602
  return [2 /*return*/, Promise.resolve(false)];
25603
25603
  return [4 /*yield*/, this.waitIdle()];
25604
25604
  case 1:
25605
- _d.sent();
25605
+ _e.sent();
25606
25606
  return [4 /*yield*/, this.dataSource.getRows()];
25607
25607
  case 2:
25608
- row = ((_d.sent()) || [])
25608
+ row = ((_e.sent()) || [])
25609
25609
  .find(function (row) { return _this.equals(row.currentData, data); });
25610
25610
  return [2 /*return*/, row && this.clickRow(null, row)];
25611
25611
  }
@@ -25647,11 +25647,11 @@
25647
25647
  };
25648
25648
  AppTable.prototype.ready = function () {
25649
25649
  return __awaiter(this, void 0, void 0, function () {
25650
- return __generator(this, function (_d) {
25651
- switch (_d.label) {
25650
+ return __generator(this, function (_e) {
25651
+ switch (_e.label) {
25652
25652
  case 0: return [4 /*yield*/, firstTruePromise(this.readySubject)];
25653
25653
  case 1:
25654
- _d.sent();
25654
+ _e.sent();
25655
25655
  return [2 /*return*/];
25656
25656
  }
25657
25657
  });
@@ -25659,11 +25659,11 @@
25659
25659
  };
25660
25660
  AppTable.prototype.waitIdle = function (opts) {
25661
25661
  return __awaiter(this, void 0, void 0, function () {
25662
- return __generator(this, function (_d) {
25663
- switch (_d.label) {
25662
+ return __generator(this, function (_e) {
25663
+ switch (_e.label) {
25664
25664
  case 0: return [4 /*yield*/, firstFalsePromise(this.loadingSubject)];
25665
25665
  case 1:
25666
- _d.sent();
25666
+ _e.sent();
25667
25667
  return [2 /*return*/];
25668
25668
  }
25669
25669
  });
@@ -25672,28 +25672,28 @@
25672
25672
  AppTable.prototype.openSelectColumnsModal = function (event) {
25673
25673
  return __awaiter(this, void 0, void 0, function () {
25674
25674
  var columns, hasTopModal, modal, data, userColumns;
25675
- return __generator(this, function (_d) {
25676
- switch (_d.label) {
25675
+ return __generator(this, function (_e) {
25676
+ switch (_e.label) {
25677
25677
  case 0:
25678
25678
  columns = this.getCurrentColumns();
25679
25679
  return [4 /*yield*/, this.modalCtrl.getTop()];
25680
25680
  case 1:
25681
- hasTopModal = !!(_d.sent());
25681
+ hasTopModal = !!(_e.sent());
25682
25682
  return [4 /*yield*/, this.modalCtrl.create({
25683
25683
  component: TableSelectColumnsComponent,
25684
25684
  componentProps: { columns: columns },
25685
25685
  cssClass: hasTopModal && 'stack-modal'
25686
25686
  })];
25687
25687
  case 2:
25688
- modal = _d.sent();
25688
+ modal = _e.sent();
25689
25689
  // Open the modal
25690
25690
  return [4 /*yield*/, modal.present()];
25691
25691
  case 3:
25692
25692
  // Open the modal
25693
- _d.sent();
25693
+ _e.sent();
25694
25694
  return [4 /*yield*/, modal.onDidDismiss()];
25695
25695
  case 4:
25696
- data = (_d.sent()).data;
25696
+ data = (_e.sent()).data;
25697
25697
  if (!data)
25698
25698
  return [2 /*return*/]; // CANCELLED
25699
25699
  userColumns = (data || []).filter(function (c) { return c.canHide === false || c.visible; }).map(function (c) { return c.name; }) || [];
@@ -25703,7 +25703,7 @@
25703
25703
  return [4 /*yield*/, this.settings.savePageSetting(this.settingsId, userColumns, SETTINGS_DISPLAY_COLUMNS)];
25704
25704
  case 5:
25705
25705
  // Update user settings
25706
- _d.sent();
25706
+ _e.sent();
25707
25707
  return [2 /*return*/];
25708
25708
  }
25709
25709
  });
@@ -25718,11 +25718,11 @@
25718
25718
  // When target wait for a complete (e.g. IonRefresher)
25719
25719
  if ((event === null || event === void 0 ? void 0 : event.target) && event.target.complete) {
25720
25720
  setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
25721
- return __generator(this, function (_d) {
25722
- switch (_d.label) {
25721
+ return __generator(this, function (_e) {
25722
+ switch (_e.label) {
25723
25723
  case 0: return [4 /*yield*/, this.waitIdle()];
25724
25724
  case 1:
25725
- _d.sent();
25725
+ _e.sent();
25726
25726
  event.target.complete();
25727
25727
  return [2 /*return*/];
25728
25728
  }
@@ -25807,33 +25807,33 @@
25807
25807
  AppTable.prototype.selectRowByIdOrData = function (id, data) {
25808
25808
  return __awaiter(this, void 0, void 0, function () {
25809
25809
  var done, err_3;
25810
- return __generator(this, function (_d) {
25811
- switch (_d.label) {
25810
+ return __generator(this, function (_e) {
25811
+ switch (_e.label) {
25812
25812
  case 0:
25813
25813
  done = false;
25814
- _d.label = 1;
25814
+ _e.label = 1;
25815
25815
  case 1:
25816
- _d.trys.push([1, 6, , 7]);
25816
+ _e.trys.push([1, 6, , 7]);
25817
25817
  if (!(isNotNil(id) || id !== -1)) return [3 /*break*/, 3];
25818
25818
  return [4 /*yield*/, this.selectRowById(id)];
25819
25819
  case 2:
25820
- done = _d.sent();
25820
+ done = _e.sent();
25821
25821
  if (done)
25822
25822
  return [2 /*return*/, true];
25823
25823
  console.warn('[app-table] Save: Cannot reselect row by row.id: ', id);
25824
- _d.label = 3;
25824
+ _e.label = 3;
25825
25825
  case 3:
25826
25826
  if (!data) return [3 /*break*/, 5];
25827
25827
  return [4 /*yield*/, this.selectRowByData(data)];
25828
25828
  case 4:
25829
- done = _d.sent();
25829
+ done = _e.sent();
25830
25830
  if (done)
25831
25831
  return [2 /*return*/, true];
25832
25832
  console.warn('[app-table] Save: Cannot reselect row by data: ', data);
25833
- _d.label = 5;
25833
+ _e.label = 5;
25834
25834
  case 5: return [2 /*return*/, false];
25835
25835
  case 6:
25836
- err_3 = _d.sent();
25836
+ err_3 = _e.sent();
25837
25837
  // Log, but continue
25838
25838
  console.error(err_3 && err_3.message || err_3);
25839
25839
  return [2 /*return*/, false];
@@ -25856,23 +25856,23 @@
25856
25856
  AppTable.prototype.canDeleteRows = function (rows, opts) {
25857
25857
  return __awaiter(this, void 0, void 0, function () {
25858
25858
  var canDelete, err_4;
25859
- return __generator(this, function (_d) {
25860
- switch (_d.label) {
25859
+ return __generator(this, function (_e) {
25860
+ switch (_e.label) {
25861
25861
  case 0:
25862
25862
  if (!(this.onBeforeDeleteRows.observers.length > 0)) return [3 /*break*/, 4];
25863
- _d.label = 1;
25863
+ _e.label = 1;
25864
25864
  case 1:
25865
- _d.trys.push([1, 3, , 4]);
25865
+ _e.trys.push([1, 3, , 4]);
25866
25866
  return [4 /*yield*/, emitPromiseEvent(this.onBeforeDeleteRows, 'canDelete', {
25867
25867
  detail: { rows: rows }
25868
25868
  })];
25869
25869
  case 2:
25870
- canDelete = _d.sent();
25870
+ canDelete = _e.sent();
25871
25871
  if (!canDelete)
25872
25872
  return [2 /*return*/, false];
25873
25873
  return [3 /*break*/, 4];
25874
25874
  case 3:
25875
- err_4 = _d.sent();
25875
+ err_4 = _e.sent();
25876
25876
  if (err_4 === 'CANCELLED')
25877
25877
  return [2 /*return*/, false]; // User cancel
25878
25878
  console.error('Error while checking if can delete rows', err_4);
@@ -25889,35 +25889,35 @@
25889
25889
  };
25890
25890
  AppTable.prototype.canCancelRows = function (rows, opts) {
25891
25891
  return __awaiter(this, void 0, void 0, function () {
25892
- var _d, isCancel, err_5;
25893
- return __generator(this, function (_e) {
25894
- switch (_e.label) {
25892
+ var _e, isCancel, err_5;
25893
+ return __generator(this, function (_f) {
25894
+ switch (_f.label) {
25895
25895
  case 0:
25896
- _d = rows;
25897
- if (_d) return [3 /*break*/, 2];
25896
+ _e = rows;
25897
+ if (_e) return [3 /*break*/, 2];
25898
25898
  return [4 /*yield*/, this.dataSource.getRows()];
25899
25899
  case 1:
25900
- _d = (_e.sent()).filter(function (row) { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; });
25901
- _e.label = 2;
25900
+ _e = (_f.sent()).filter(function (row) { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; });
25901
+ _f.label = 2;
25902
25902
  case 2:
25903
25903
  // Get dirty rows
25904
- rows = _d;
25904
+ rows = _e;
25905
25905
  if (isEmptyArray(rows))
25906
25906
  return [2 /*return*/, true]; // No dirty: OK
25907
25907
  if (!(this.onBeforeCancelRows.observers.length > 0)) return [3 /*break*/, 6];
25908
- _e.label = 3;
25908
+ _f.label = 3;
25909
25909
  case 3:
25910
- _e.trys.push([3, 5, , 6]);
25910
+ _f.trys.push([3, 5, , 6]);
25911
25911
  return [4 /*yield*/, emitPromiseEvent(this.onBeforeCancelRows, 'canCancel', {
25912
25912
  detail: { rows: rows }
25913
25913
  })];
25914
25914
  case 4:
25915
- isCancel = _e.sent();
25915
+ isCancel = _f.sent();
25916
25916
  if (!isCancel)
25917
25917
  return [2 /*return*/, false];
25918
25918
  return [3 /*break*/, 6];
25919
25919
  case 5:
25920
- err_5 = _e.sent();
25920
+ err_5 = _f.sent();
25921
25921
  if (err_5 === 'CANCELLED')
25922
25922
  return [2 /*return*/, false]; // User cancel
25923
25923
  console.error('Error while checking if can cancel rows', err_5);
@@ -25935,8 +25935,8 @@
25935
25935
  AppTable.prototype.saveBeforeAction = function (saveAction) {
25936
25936
  return __awaiter(this, void 0, void 0, function () {
25937
25937
  var save, confirmed, res, err_6, saved;
25938
- return __generator(this, function (_d) {
25939
- switch (_d.label) {
25938
+ return __generator(this, function (_e) {
25939
+ switch (_e.label) {
25940
25940
  case 0:
25941
25941
  if (!this.dirty) {
25942
25942
  // Continue without save
@@ -25958,19 +25958,19 @@
25958
25958
  confirmed = true;
25959
25959
  if (!save) return [3 /*break*/, 4];
25960
25960
  if (!(this.onBeforeSave.observers.length > 0)) return [3 /*break*/, 4];
25961
- _d.label = 1;
25961
+ _e.label = 1;
25962
25962
  case 1:
25963
- _d.trys.push([1, 3, , 4]);
25963
+ _e.trys.push([1, 3, , 4]);
25964
25964
  return [4 /*yield*/, emitPromiseEvent(this.onBeforeSave, 'beforeSave', {
25965
25965
  detail: { action: saveAction, valid: this.valid }
25966
25966
  })];
25967
25967
  case 2:
25968
- res = _d.sent();
25968
+ res = _e.sent();
25969
25969
  confirmed = res.confirmed;
25970
25970
  save = res.save;
25971
25971
  return [3 /*break*/, 4];
25972
25972
  case 3:
25973
- err_6 = _d.sent();
25973
+ err_6 = _e.sent();
25974
25974
  if (err_6 === 'CANCELLED')
25975
25975
  return [2 /*return*/, false]; // User cancel
25976
25976
  console.error('Error while checking if can delete rows', err_6);
@@ -25980,7 +25980,7 @@
25980
25980
  if (!save) return [3 /*break*/, 6];
25981
25981
  return [4 /*yield*/, this.save()];
25982
25982
  case 5:
25983
- saved = _d.sent();
25983
+ saved = _e.sent();
25984
25984
  this.markAsDirty(); // Restore dirty flag
25985
25985
  return [2 /*return*/, saved];
25986
25986
  case 6: return [2 /*return*/, true]; // No save but continue action
@@ -25998,8 +25998,8 @@
25998
25998
  */
25999
25999
  AppTable.prototype.openRow = function (id, row) {
26000
26000
  return __awaiter(this, void 0, void 0, function () {
26001
- return __generator(this, function (_d) {
26002
- switch (_d.label) {
26001
+ return __generator(this, function (_e) {
26002
+ switch (_e.label) {
26003
26003
  case 0:
26004
26004
  if (!this.allowRowDetail) return [3 /*break*/, 2];
26005
26005
  if (this.debug && this.dirty) {
@@ -26018,7 +26018,7 @@
26018
26018
  relativeTo: this.route,
26019
26019
  queryParams: {}
26020
26020
  })];
26021
- case 1: return [2 /*return*/, _d.sent()];
26021
+ case 1: return [2 /*return*/, _e.sent()];
26022
26022
  case 2: return [2 /*return*/, false];
26023
26023
  }
26024
26024
  });
@@ -26026,8 +26026,8 @@
26026
26026
  };
26027
26027
  AppTable.prototype.openNewRowDetail = function (event) {
26028
26028
  return __awaiter(this, void 0, void 0, function () {
26029
- return __generator(this, function (_d) {
26030
- switch (_d.label) {
26029
+ return __generator(this, function (_e) {
26030
+ switch (_e.label) {
26031
26031
  case 0:
26032
26032
  if (!this.allowRowDetail)
26033
26033
  return [2 /*return*/, false];
@@ -26038,7 +26038,7 @@
26038
26038
  return [4 /*yield*/, this.router.navigate(['new'], {
26039
26039
  relativeTo: this.route
26040
26040
  })];
26041
- case 1: return [2 /*return*/, _d.sent()];
26041
+ case 1: return [2 /*return*/, _e.sent()];
26042
26042
  }
26043
26043
  });
26044
26044
  });
@@ -26119,13 +26119,13 @@
26119
26119
  };
26120
26120
  AppTable.prototype.addRowToTable = function (insertAt) {
26121
26121
  return __awaiter(this, void 0, void 0, function () {
26122
- return __generator(this, function (_d) {
26123
- switch (_d.label) {
26122
+ return __generator(this, function (_e) {
26123
+ switch (_e.label) {
26124
26124
  case 0:
26125
26125
  this.focusFirstColumn = true;
26126
26126
  return [4 /*yield*/, this._dataSource.asyncCreateNew(insertAt)];
26127
26127
  case 1:
26128
- _d.sent();
26128
+ _e.sent();
26129
26129
  this.editedRow = this._dataSource.getRow(-1);
26130
26130
  // Emit start editing event
26131
26131
  this.onStartEditingRow.emit(this.editedRow);
@@ -26189,7 +26189,7 @@
26189
26189
  };
26190
26190
  AppTable.prototype.askDeleteConfirmation = function (event, rows) {
26191
26191
  return __awaiter(this, void 0, void 0, function () {
26192
- return __generator(this, function (_d) {
26192
+ return __generator(this, function (_e) {
26193
26193
  if (this.undoableDeletion) {
26194
26194
  // Special message, for undoable deletion
26195
26195
  return [2 /*return*/, Alerts.askConfirmation((rows === null || rows === void 0 ? void 0 : rows.length) === 1 ? 'CONFIRM.DELETE_ROW' : 'CONFIRM.DELETE_ROWS', this.alertCtrl, this.translate, event)];
@@ -26201,21 +26201,21 @@
26201
26201
  };
26202
26202
  AppTable.prototype.askCancelConfirmation = function (event, rows) {
26203
26203
  return __awaiter(this, void 0, void 0, function () {
26204
- return __generator(this, function (_d) {
26204
+ return __generator(this, function (_e) {
26205
26205
  return [2 /*return*/, Alerts.askConfirmation((rows === null || rows === void 0 ? void 0 : rows.length) === 1 ? 'CONFIRM.CANCEL_ROW' : 'CONFIRM.CANCEL_ROWS', this.alertCtrl, this.translate, event)];
26206
26206
  });
26207
26207
  });
26208
26208
  };
26209
26209
  AppTable.prototype.askRestoreConfirmation = function (event) {
26210
26210
  return __awaiter(this, void 0, void 0, function () {
26211
- return __generator(this, function (_d) {
26211
+ return __generator(this, function (_e) {
26212
26212
  return [2 /*return*/, Alerts.askActionConfirmation(this.alertCtrl, this.translate, false, event)];
26213
26213
  });
26214
26214
  });
26215
26215
  };
26216
26216
  AppTable.prototype.showToast = function (opts) {
26217
26217
  return __awaiter(this, void 0, void 0, function () {
26218
- return __generator(this, function (_d) {
26218
+ return __generator(this, function (_e) {
26219
26219
  if (!this.toastController)
26220
26220
  throw new Error('Missing toastController in component\'s constructor');
26221
26221
  return [2 /*return*/, Toasts.show(this.toastController, this.translate, opts)];
@@ -26310,14 +26310,14 @@
26310
26310
  AppTable.prototype.checkIfPristine = function (opts) {
26311
26311
  return __awaiter(this, void 0, void 0, function () {
26312
26312
  var rows, pristine;
26313
- return __generator(this, function (_d) {
26314
- switch (_d.label) {
26313
+ return __generator(this, function (_e) {
26314
+ switch (_e.label) {
26315
26315
  case 0:
26316
26316
  if (!this.dirty)
26317
26317
  return [2 /*return*/]; // Already pristine
26318
26318
  return [4 /*yield*/, this._dataSource.getRows()];
26319
26319
  case 1:
26320
- rows = _d.sent();
26320
+ rows = _e.sent();
26321
26321
  pristine = (rows || []).findIndex(function (row) { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; }) === -1;
26322
26322
  if (pristine)
26323
26323
  this.markAsPristine(opts);
@@ -27162,7 +27162,6 @@
27162
27162
  _this.dataType = dataType;
27163
27163
  _this.dataService = dataService;
27164
27164
  _this.saving = false;
27165
- _this.hasRemoteListener = false;
27166
27165
  _this.$title = new rxjs.Subject();
27167
27166
  _this.onUpdateView = new i0.EventEmitter();
27168
27167
  options = Object.assign({
@@ -27264,6 +27263,7 @@
27264
27263
  };
27265
27264
  AppEntityEditor.prototype.ngOnDestroy = function () {
27266
27265
  _super.prototype.ngOnDestroy.call(this);
27266
+ this.listenRemoteSubscription = null; // already unsubscribe in the super function
27267
27267
  this.$title.complete();
27268
27268
  this.$title.unsubscribe();
27269
27269
  this.onUpdateView.complete();
@@ -27360,11 +27360,10 @@
27360
27360
  AppEntityEditor.prototype.startListenRemoteChanges = function () {
27361
27361
  var _this = this;
27362
27362
  // Skip if disable, or already listening
27363
- if (this.hasRemoteListener || !this._enableListenChanges || this.isNewData)
27363
+ if (this.listenRemoteSubscription || !this._enableListenChanges || this.isNewData)
27364
27364
  return;
27365
27365
  // Listen for changes on server
27366
- this.hasRemoteListener = true;
27367
- this.registerSubscription(this.dataService.listenChanges(this.data.id)
27366
+ this.listenRemoteSubscription = this.dataService.listenChanges(this.data.id)
27368
27367
  .pipe(operators.filter(isNotNil))
27369
27368
  .subscribe(function (data) {
27370
27369
  if (data.updateDate && data.updateDate.isAfter(_this.data.updateDate)) {
@@ -27378,8 +27377,16 @@
27378
27377
  console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}, but page is dirty: skip reloading.");
27379
27378
  }
27380
27379
  }
27381
- })
27382
- .add(function () { return _this.hasRemoteListener = false; }));
27380
+ });
27381
+ this.listenRemoteSubscription.add(function () { return _this.listenRemoteSubscription = null; });
27382
+ this.registerSubscription(this.listenRemoteSubscription);
27383
+ };
27384
+ AppEntityEditor.prototype.stopListenRemoteChanges = function () {
27385
+ if (this.listenRemoteSubscription) {
27386
+ this.unregisterSubscription(this.listenRemoteSubscription);
27387
+ this.listenRemoteSubscription.unsubscribe();
27388
+ this.listenRemoteSubscription = null;
27389
+ }
27383
27390
  };
27384
27391
  AppEntityEditor.prototype.updateView = function (data, opts) {
27385
27392
  return __awaiter(this, void 0, void 0, function () {
@@ -27575,7 +27582,7 @@
27575
27582
  // Update the view (e.g metadata)
27576
27583
  _b.sent();
27577
27584
  // Subscribe to remote changes
27578
- if (!this.hasRemoteListener)
27585
+ if (!this.listenRemoteSubscription)
27579
27586
  this.startListenRemoteChanges();
27580
27587
  this.submitted = false;
27581
27588
  return [2 /*return*/, true];
@@ -27773,6 +27780,7 @@
27773
27780
  AppEntityEditor.prototype.unload = function () {
27774
27781
  return __awaiter(this, void 0, void 0, function () {
27775
27782
  return __generator(this, function (_b) {
27783
+ this.stopListenRemoteChanges();
27776
27784
  this.form.reset();
27777
27785
  this.registerForms();
27778
27786
  this._dirty = false;