@sumaris-net/ngx-components 18.22.8 → 18.22.10

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.
@@ -38321,7 +38321,8 @@ class AppTable {
38321
38321
  }
38322
38322
  if (this.debug)
38323
38323
  console.debug('[table] Calling dataSource.watchAll()...');
38324
- return this._dataSource.watchAll(this.pageOffset, this.pageSize, this.sortActive, this.sortDirection, this._filter)
38324
+ return this._dataSource
38325
+ .watchAll(this.pageOffset, this.pageSize, this.sortActive, this.sortDirection, this._filter)
38325
38326
  .pipe(takeUntil(this.onRefresh));
38326
38327
  }), catchError((err) => {
38327
38328
  if (this.debug)
@@ -38441,58 +38442,79 @@ class AppTable {
38441
38442
  this.applyFilter(filter, opts);
38442
38443
  }
38443
38444
  }
38444
- async confirmAndAdd(event, row) {
38445
+ async confirmAndAdd(event, row, opts) {
38445
38446
  if (!this.confirmEditCreate(event, row)) {
38447
+ // If pending: Wait end of validation, then loop
38448
+ if (row.validator?.pending) {
38449
+ return (AppFormUtils.waitWhilePending(row.validator, { stop: this.destroySubject })
38450
+ // Loop after validation completed
38451
+ .then(() => this.confirmAndAdd(event, row, opts)));
38452
+ }
38453
+ // Go back to focusColumn
38454
+ if (opts?.focusColumn) {
38455
+ this.focusColumn = opts?.focusColumn;
38456
+ this.markForCheck();
38457
+ }
38446
38458
  return false;
38447
38459
  }
38448
38460
  // Add row
38449
- return this.addRow(event);
38461
+ return this.addRow(event, undefined /* insertAt: use default */, opts);
38450
38462
  }
38451
- confirmAndBackward(event, row) {
38452
- // Deleting edited row, if empty and not dirty
38463
+ confirmAndBackward(event, row, opts) {
38464
+ if (!this.inlineEdition)
38465
+ return false;
38453
38466
  const previousRow = this.editedRow;
38467
+ const focusColumn = opts?.focusColumn ?? this.lastUserColumn;
38454
38468
  event?.stopPropagation();
38469
+ // Deleting edited row, if empty and not dirty
38455
38470
  if (previousRow) {
38456
38471
  // Previous row was a nex row AND invalid: delete it
38457
38472
  if (previousRow.id === -1 && previousRow.validator?.invalid && !previousRow.validator?.dirty) {
38458
38473
  this.deleteNewRow(event, previousRow);
38459
38474
  // Wait deletion is done, then edit previous row (by id, because of reloading)
38460
- this.waitIdle().then(() => this.editRowById(event, row.id, { focusColumn: this.lastUserColumn }));
38475
+ this.waitIdle().then(() => this.editRowById(event, row.id, { focusColumn }));
38461
38476
  return true;
38462
38477
  }
38463
38478
  // If cannot confirm previous row
38464
38479
  else if (!this.confirmEditCreate(event, previousRow)) {
38465
38480
  // If pending: Wait end of validation, then loop
38466
38481
  if (previousRow.validator?.pending) {
38467
- return AppFormUtils.waitWhilePending(previousRow.validator).then(() => this.confirmAndBackward(event, row));
38482
+ return (AppFormUtils.waitWhilePending(previousRow.validator, { stop: this.destroySubject })
38483
+ // Wait end of validation and loop
38484
+ .then(() => this.confirmAndBackward(event, row, { focusColumn })));
38468
38485
  }
38469
38486
  // Go back to first column
38470
- this.focusColumn = this.lastUserColumn;
38487
+ this.focusColumn = focusColumn;
38471
38488
  this.markForCheck();
38472
38489
  return false;
38473
38490
  }
38474
38491
  }
38475
38492
  // Edit row, focusing at the end
38476
- this.editRow(event, row, { focusColumn: this.lastUserColumn });
38493
+ this.editRow(event, row, { focusColumn });
38477
38494
  return true;
38478
38495
  }
38479
- confirmAndForward(event, row) {
38496
+ confirmAndForward(event, row, opts) {
38480
38497
  if (!this.inlineEdition)
38481
38498
  return false;
38482
38499
  row = row || this.editedRow;
38500
+ const focusColumn = opts?.focusColumn ?? this.firstUserColumn;
38483
38501
  event?.stopPropagation();
38502
+ // If not confirmed
38484
38503
  if (!this.confirmEditCreate(event, row)) {
38485
38504
  // If pending: Wait end of validation, then loop
38486
38505
  if (row.validator?.pending) {
38487
- return AppFormUtils.waitWhilePending(row.validator).then(() => this.confirmAndForward(event, row));
38506
+ return (AppFormUtils.waitWhilePending(row.validator, { stop: this.destroySubject })
38507
+ // Wait end of validation and loop
38508
+ .then(() => this.confirmAndForward(event, row, { focusColumn })));
38488
38509
  }
38489
38510
  // Go back to first column
38490
- this.focusColumn = this.firstUserColumn;
38511
+ this.focusColumn = focusColumn;
38491
38512
  this.markForCheck();
38492
38513
  return false;
38493
38514
  }
38494
38515
  // Edit next row
38495
- this.editRowById(event, row.id + 1, { focusColumn: this.firstUserColumn });
38516
+ const nextRowId = row.id + 1;
38517
+ this.editRowById(event, nextRowId, { focusColumn });
38496
38518
  return true;
38497
38519
  }
38498
38520
  /**
@@ -38527,7 +38549,9 @@ class AppTable {
38527
38549
  // If pending: Wait end of validation, then loop
38528
38550
  // TODO: remove when using async isValid() function
38529
38551
  if (row.validator.pending) {
38530
- AppFormUtils.waitWhilePending(row.validator).then(() => this.confirmEditCreate(event, row));
38552
+ AppFormUtils.waitWhilePending(row.validator)
38553
+ // Wait end of validation and loop
38554
+ .then(() => this.confirmEditCreate(event, row));
38531
38555
  return false;
38532
38556
  }
38533
38557
  // NOT confirmed = row has error
@@ -39012,7 +39036,7 @@ class AppTable {
39012
39036
  if (!confirmed)
39013
39037
  return false;
39014
39038
  if (!row.editing && !this.loading) {
39015
- this.focusColumn = (opts && opts.focusColumn) || this.focusColumn;
39039
+ this.focusColumn = opts?.focusColumn ?? this.focusColumn;
39016
39040
  this._dataSource.startEdit(row);
39017
39041
  }
39018
39042
  this.editedRow = row;
@@ -41257,14 +41281,20 @@ class AppAsyncTable {
41257
41281
  this.applyFilter(filter, opts);
41258
41282
  }
41259
41283
  }
41260
- async confirmAndAdd(event, row) {
41284
+ async confirmAndAdd(event, row, opts) {
41261
41285
  if (!(await this.confirmEditCreate(event, row))) {
41286
+ // Go back to focusColumn
41287
+ if (opts?.focusColumn) {
41288
+ this.focusColumn = opts?.focusColumn;
41289
+ this.markForCheck();
41290
+ }
41262
41291
  return false;
41263
41292
  }
41264
41293
  // Add row
41265
- return this.addRow(event);
41294
+ return this.addRow(event, undefined /* insertAt: use default */, opts);
41266
41295
  }
41267
- async confirmAndBackward(event, row) {
41296
+ async confirmAndBackward(event, row, opts) {
41297
+ const focusColumn = opts?.focusColumn ?? this.lastUserColumn;
41268
41298
  // Deleting edited row, if empty and not dirty
41269
41299
  if (this.dataSource.hasSomeEditingRow()) {
41270
41300
  for (const editingRow of this.dataSource.getEditingRows().filter((row) => row.id === -1 && row.invalid && !row.dirty)) {
@@ -41272,21 +41302,27 @@ class AppAsyncTable {
41272
41302
  }
41273
41303
  // Wait deletion is done, then edit previous row (by id, because of reloading)
41274
41304
  await this.waitIdle();
41275
- await this.editRowById(event, row.id, { focusColumn: this.lastUserColumn });
41305
+ await this.editRowById(event, row.id, { focusColumn });
41276
41306
  return true;
41277
41307
  }
41278
41308
  // Edit row, focusing at the end
41279
- await this.editRow(event, row, { focusColumn: this.lastUserColumn });
41309
+ await this.editRow(event, row, { focusColumn });
41280
41310
  return true;
41281
41311
  }
41282
- async confirmAndForward(event, row) {
41312
+ async confirmAndForward(event, row, opts) {
41283
41313
  if (!this.inlineEdition)
41284
41314
  return false;
41315
+ const focusColumn = opts?.focusColumn ?? this.firstUserColumn;
41285
41316
  const confirmed = await this.confirmEditCreate(event, row);
41286
- if (!confirmed)
41287
- return false; // Not confirmed
41317
+ // If not confirmed
41318
+ if (!confirmed) {
41319
+ // Go back to first column
41320
+ this.focusColumn = focusColumn;
41321
+ this.markForCheck();
41322
+ return false;
41323
+ }
41288
41324
  // Edit next row
41289
- await this.editRowById(event, row.id + 1, { focusColumn: this.firstUserColumn });
41325
+ await this.editRowById(event, row.id + 1, { focusColumn });
41290
41326
  return true;
41291
41327
  }
41292
41328
  /**
@@ -41789,7 +41825,7 @@ class AppAsyncTable {
41789
41825
  return false;
41790
41826
  }
41791
41827
  if (!row.editing && !this.loading) {
41792
- this.focusColumn = (opts && opts.focusColumn) || this.focusColumn;
41828
+ this.focusColumn = opts?.focusColumn ?? this.focusColumn;
41793
41829
  await this._dataSource.startEdit(row);
41794
41830
  }
41795
41831
  this.onStartEditingRow.emit(row);