@sumaris-net/ngx-components 1.23.1 → 1.23.2

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.
@@ -22347,7 +22347,6 @@ class EntitiesTableDataSource extends TableDataSource {
22347
22347
  this._creating = false;
22348
22348
  this._saving = false;
22349
22349
  this._stopWatching$ = new Subject();
22350
- this._editingRowCount = 0;
22351
22350
  this._fetchMoreFn = null;
22352
22351
  this.loadingSubject = new BehaviorSubject(undefined);
22353
22352
  this._entityName = removeEnd((new dataType()).__typename || 'UnknownVO', 'VO');
@@ -22394,7 +22393,6 @@ class EntitiesTableDataSource extends TableDataSource {
22394
22393
  }
22395
22394
  watchAll(offset, size, sortBy, sortDirection, filter) {
22396
22395
  this._stopWatching$.next();
22397
- this._editingRowCount = 0;
22398
22396
  this._fetchMoreFn = null;
22399
22397
  this.markAsLoading();
22400
22398
  return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
@@ -22402,8 +22400,8 @@ class EntitiesTableDataSource extends TableDataSource {
22402
22400
  if (this._saving) {
22403
22401
  console.info(`[table-datasource] Received ${this._entityName} data (from service), but still saving: skip`);
22404
22402
  }
22405
- else if (this._editingRowCount > 0) {
22406
- console.warn(`[table-datasource] Received ${this._entityName} data, while ${this._editingRowCount} rows still editing: skip; Please check save() implementation in the table!`);
22403
+ else if (this.hasSomeEditingRow()) {
22404
+ console.warn(`[table-datasource] Received ${this._entityName} data, while some row still editing: skip; Please check save() implementation in the table!`);
22407
22405
  }
22408
22406
  else {
22409
22407
  this.updateDatasource((res.data || []));
@@ -22457,7 +22455,6 @@ class EntitiesTableDataSource extends TableDataSource {
22457
22455
  // Stop with an error
22458
22456
  throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
22459
22457
  }
22460
- this._editingRowCount = 0;
22461
22458
  let data;
22462
22459
  let dataToSave;
22463
22460
  if (this.validatorService) {
@@ -22534,7 +22531,6 @@ class EntitiesTableDataSource extends TableDataSource {
22534
22531
  console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
22535
22532
  row.validator.disable({ onlySelf: true, emitEvent: false });
22536
22533
  }
22537
- this._editingRowCount--;
22538
22534
  return true;
22539
22535
  }
22540
22536
  confirmEdit(row) {
@@ -22544,7 +22540,6 @@ class EntitiesTableDataSource extends TableDataSource {
22544
22540
  console.warn('[table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
22545
22541
  row.validator.disable({ onlySelf: true, emitEvent: false });
22546
22542
  }
22547
- this._editingRowCount--;
22548
22543
  return true;
22549
22544
  }
22550
22545
  startEdit(row) {
@@ -22554,7 +22549,6 @@ class EntitiesTableDataSource extends TableDataSource {
22554
22549
  console.warn('[table-datasource] Row still has {editing: false} after startEdit()! Force editing');
22555
22550
  row.validator.enable({ onlySelf: true, emitEvent: false });
22556
22551
  }
22557
- this._editingRowCount++;
22558
22552
  }
22559
22553
  handleError(error, message) {
22560
22554
  const errorMsg = error && error.message || error;
@@ -22578,9 +22572,7 @@ class EntitiesTableDataSource extends TableDataSource {
22578
22572
  console.error(`[table-datasource] Row to delete with id=${id} not found`);
22579
22573
  return;
22580
22574
  }
22581
- if (row.editing)
22582
- this._editingRowCount--;
22583
- this.loadingSubject.next(true);
22575
+ this.markAsLoading();
22584
22576
  this.dataService.deleteAll([row.currentData], this.serviceOptions)
22585
22577
  .catch(err => this.handleServiceError(err))
22586
22578
  .then(() => {
@@ -22589,7 +22581,7 @@ class EntitiesTableDataSource extends TableDataSource {
22589
22581
  const present = this.getRow(id) === row;
22590
22582
  if (present)
22591
22583
  super.delete(id);
22592
- this.loadingSubject.next(false);
22584
+ this.markAsLoaded();
22593
22585
  }, 300);
22594
22586
  });
22595
22587
  }
@@ -22623,7 +22615,7 @@ class EntitiesTableDataSource extends TableDataSource {
22623
22615
  }
22624
22616
  }
22625
22617
  catch (err) {
22626
- // Handle sservice error
22618
+ // Handle service error
22627
22619
  this.handleServiceError(err);
22628
22620
  }
22629
22621
  finally {
@@ -22637,6 +22629,9 @@ class EntitiesTableDataSource extends TableDataSource {
22637
22629
  getRows() {
22638
22630
  return this.rowsSubject.getValue();
22639
22631
  }
22632
+ hasSomeEditingRow() {
22633
+ return (this.rowsSubject.value || []).some(row => row.editing);
22634
+ }
22640
22635
  createNew(insertAt, options = { editing: true }) {
22641
22636
  const _super = Object.create(null, {
22642
22637
  createNew: { get: () => super.createNew }
@@ -22659,8 +22654,6 @@ class EntitiesTableDataSource extends TableDataSource {
22659
22654
  console.error(err && err.message || err, err);
22660
22655
  }
22661
22656
  }
22662
- if (row.editing)
22663
- this._editingRowCount++;
22664
22657
  return row;
22665
22658
  }
22666
22659
  finally {
@@ -22679,8 +22672,8 @@ class EntitiesTableDataSource extends TableDataSource {
22679
22672
  return __awaiter(this, void 0, void 0, function* () {
22680
22673
  if (!this._fetchMoreFn)
22681
22674
  return false; // Avoid multiple call
22682
- if (this._editingRowCount > 0) {
22683
- console.warn(`Cannot fetch more ${this._entityName} because ${this._editingRowCount} row(s) still editing`);
22675
+ if (this.hasSomeEditingRow()) {
22676
+ console.warn(`Cannot fetch more ${this._entityName} because some row) still editing`);
22684
22677
  return;
22685
22678
  }
22686
22679
  console.debug(`Will fetching more row(s) still...`);
@@ -22752,7 +22745,6 @@ class AppTable {
22752
22745
  this.savingSubject = new BehaviorSubject(false);
22753
22746
  this.dirtySubject = new BehaviorSubject(false);
22754
22747
  this.errorSubject = new BehaviorSubject(undefined);
22755
- this.isRateLimitReached = false;
22756
22748
  this.selection = new SelectionModel(true, []);
22757
22749
  this.editedRow = undefined;
22758
22750
  this.i18nColumnPrefix = 'COMMON.';
@@ -23146,7 +23138,6 @@ class AppTable {
23146
23138
  if (!res)
23147
23139
  return; // Skip (e.g error)
23148
23140
  if (res && res.data) {
23149
- this.isRateLimitReached = !this.paginator || (res.data.length < this.paginator.pageSize);
23150
23141
  this.visibleRowCount = res.data.length;
23151
23142
  this.totalRowCount = isNotNil(res.total) ? res.total : ((this.paginator && this.paginator.pageIndex * (this.paginator.pageSize || DEFAULT_PAGE_SIZE) || 0) + this.visibleRowCount);
23152
23143
  if (this.debug)
@@ -23154,7 +23145,6 @@ class AppTable {
23154
23145
  }
23155
23146
  else {
23156
23147
  //if (this.debug) console.debug('[table] NO rows loaded');
23157
- this.isRateLimitReached = true;
23158
23148
  this.totalRowCount = 0;
23159
23149
  this.visibleRowCount = 0;
23160
23150
  }
@@ -23507,22 +23497,19 @@ class AppTable {
23507
23497
  if (this.saveBeforeDelete) {
23508
23498
  // Exclude invalid rows (because of save() will fail, when exists some invalid rows)
23509
23499
  rows = rows.filter(row => {
23510
- if (row.validator && !row.validator.valid) {
23511
- // When deleted (= newly created row) : decrement counter
23512
- if (row.id === -1 || !row.editing) {
23513
- row.delete();
23514
- this.visibleRowCount--;
23515
- this.totalRowCount--;
23516
- return false; // Remove this row to the list, because already deleted
23517
- }
23518
- // Mark row as pristine, to avoid row to be saved even if still invalid
23519
- else {
23520
- // Will cancel only (delete will always go into the previous 'if')
23521
- row.cancelOrDelete();
23522
- // Mark row as pristine (if possible)
23523
- this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
23524
- // Continue: the row will be deleted after the save
23525
- }
23500
+ // Delete the row, if newly created row (id = -1), or if invalid and not editing (= not cancellable)
23501
+ if (row.id === -1 || (!row.valid && !row.editing)) {
23502
+ row.delete();
23503
+ this.visibleRowCount--;
23504
+ this.totalRowCount--;
23505
+ return false;
23506
+ }
23507
+ // Cancel the row (and mark as pristine), when not valid but in edition
23508
+ else if (!row.valid && row.editing) {
23509
+ row.cancel();
23510
+ // Mark row as pristine (if possible)
23511
+ this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
23512
+ return true; // Keep the row. the row will be deleted after the save
23526
23513
  }
23527
23514
  return true;
23528
23515
  });