@sumaris-net/ngx-components 18.22.18 → 18.22.19

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.
@@ -38553,7 +38553,7 @@ class AppTable {
38553
38553
  if (previousRow.id === -1 && previousRow.validator?.invalid && !previousRow.validator?.dirty) {
38554
38554
  this.deleteNewRow(event, previousRow);
38555
38555
  // Wait deletion is done, then edit previous row (by id, because of reloading)
38556
- this.waitIdle().then(() => this.editRowById(event, row.id, { focusColumn }));
38556
+ this.waitIdle().then(() => this.editOrAddRowById(event, row.id, { focusColumn }));
38557
38557
  return true;
38558
38558
  }
38559
38559
  // If cannot confirm previous row
@@ -38595,7 +38595,7 @@ class AppTable {
38595
38595
  }
38596
38596
  // Edit next row
38597
38597
  const nextRowId = row.id + 1;
38598
- this.editRowById(event, nextRowId, { focusColumn });
38598
+ this.editOrAddRowById(event, nextRowId, { focusColumn });
38599
38599
  return true;
38600
38600
  }
38601
38601
  /**
@@ -39611,7 +39611,7 @@ class AppTable {
39611
39611
  this.registerSubscription(this.sort.sortChange.pipe(filter(() => !this.sort.disabled)).subscribe(() => (this.paginator.pageIndex = 0)));
39612
39612
  }
39613
39613
  }
39614
- async editRowById(event, id, opts) {
39614
+ async editOrAddRowById(event, id, opts) {
39615
39615
  if (id < 0)
39616
39616
  return;
39617
39617
  if (id >= this.visibleRowCount) {
@@ -41378,6 +41378,12 @@ class AppAsyncTable {
41378
41378
  // Add row
41379
41379
  return this.addRow(event, undefined /* insertAt: use default */, opts);
41380
41380
  }
41381
+ /**
41382
+ * Same as confirmAndUp(), but using the next focused row. Should be call by the action column components
41383
+ * @param event
41384
+ * @param row
41385
+ * @param opts
41386
+ */
41381
41387
  async confirmAndBackward(event, row, opts) {
41382
41388
  const focusColumn = opts?.focusColumn ?? this.lastUserColumn;
41383
41389
  // Deleting edited row, if empty and not dirty
@@ -41386,8 +41392,8 @@ class AppAsyncTable {
41386
41392
  await this.deleteNewRow(event, editingRow);
41387
41393
  }
41388
41394
  // Wait deletion is done, then edit previous row (by id, because of reloading)
41389
- await this.waitIdle();
41390
- await this.editRowById(event, row.id, { focusColumn });
41395
+ await this.waitIdle(opts);
41396
+ await this.editOrAddRowById(event, row.id, { focusColumn });
41391
41397
  return true;
41392
41398
  }
41393
41399
  // Edit row, focusing at the end
@@ -41407,7 +41413,35 @@ class AppAsyncTable {
41407
41413
  return false;
41408
41414
  }
41409
41415
  // Edit next row
41410
- await this.editRowById(event, row.id + 1, { focusColumn });
41416
+ await this.editOrAddRowById(event, row.id + 1, { focusColumn });
41417
+ return true;
41418
+ }
41419
+ /**
41420
+ * Confirms the current row and moves the focus to the upper row.
41421
+ * Typical usage is inside a <input type="number">, with `(keyup.arrowUp)="confirmAndUp(event, row, {focusColumn: columnName})"`
41422
+ * Same as confirmAndBackward, but on the current row.
41423
+ *
41424
+ *
41425
+ * @param {Event} [event] - The event associated with the confirmation and update action.
41426
+ * @param {AsyncTableElement} [row] - The current row object.
41427
+ * @param {Object} [opts] - Options.
41428
+ * @param {string} [opts.focusColumn] - The column to focus on the upper row; defaults to the current focus column
41429
+ * @return {Promise<boolean>} A promise that resolves to a boolean indicating the success of the navigation.
41430
+ */
41431
+ async confirmAndUp(event, row, opts) {
41432
+ const focusColumn = opts?.focusColumn ?? this.focusColumn;
41433
+ // Deleting edited row, if empty and not dirty
41434
+ if (this.dataSource.hasSomeEditingRow()) {
41435
+ for (const editingRow of this.dataSource.getEditingRows().filter((row) => row.id === -1 && row.invalid && !row.dirty)) {
41436
+ await this.deleteNewRow(event, editingRow);
41437
+ }
41438
+ // Wait deletion is done, then edit previous row (by id, because of reloading)
41439
+ await this.waitIdle(opts);
41440
+ await this.editOrAddRowById(event, row.id - 1, { focusColumn });
41441
+ return true;
41442
+ }
41443
+ // Edit row, focusing at the end
41444
+ await this.editRow(event, row, { focusColumn });
41411
41445
  return true;
41412
41446
  }
41413
41447
  /**
@@ -42401,7 +42435,7 @@ class AppAsyncTable {
42401
42435
  this.registerSubscription(this.sort.sortChange.pipe(filter(() => !this.sort.disabled)).subscribe(() => (this.paginator.pageIndex = 0)));
42402
42436
  }
42403
42437
  }
42404
- async editRowById(event, id, opts) {
42438
+ async editOrAddRowById(event, id, opts) {
42405
42439
  if (id < 0)
42406
42440
  return;
42407
42441
  if (id >= this.visibleRowCount) {