@sumaris-net/ngx-components 18.27.13 → 18.27.14
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.
- package/doc/changelog.md +3 -0
- package/esm2022/src/app/core/table/async-table.class.mjs +28 -6
- package/fesm2022/sumaris-net.ngx-components.mjs +27 -5
- package/fesm2022/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/core/table/async-table.class.d.ts +12 -0
- package/src/app/shared/inputs.d.ts +1 -1
- package/src/assets/manifest.json +1 -1
|
@@ -44756,6 +44756,14 @@ class AppAsyncTable {
|
|
|
44756
44756
|
const row = await this.addRowToTable(insertAt, opts);
|
|
44757
44757
|
return !!row;
|
|
44758
44758
|
}
|
|
44759
|
+
/**
|
|
44760
|
+
* Save the table
|
|
44761
|
+
*
|
|
44762
|
+
* @param opts.keepEditing if true, the edited row will be kept after save (defaulting to this.keepEditedRowOnSave)
|
|
44763
|
+
* @param opts.keepSelection if true, the selected row will be kept after save (no effect if opts.keepEditing is true)
|
|
44764
|
+
* @param opts.confirmRow if true or not provided, the edited row will be confirmed before save
|
|
44765
|
+
* @param opts.throwIfNotConfirmed if true or not provided, an error will be thrown if the edited row is not confirmed
|
|
44766
|
+
*/
|
|
44759
44767
|
async save(opts) {
|
|
44760
44768
|
opts = {
|
|
44761
44769
|
keepEditing: this.keepEditedRowOnSave,
|
|
@@ -44765,15 +44773,22 @@ class AppAsyncTable {
|
|
|
44765
44773
|
throw { code: ErrorCodes.TABLE_READ_ONLY, message: 'ERROR.TABLE_READ_ONLY' };
|
|
44766
44774
|
}
|
|
44767
44775
|
this.resetError();
|
|
44768
|
-
// Keep edited row id (should be done BEFORE confirmEditCreate()
|
|
44776
|
+
// Keep edited row id (should be done BEFORE confirmEditCreate())
|
|
44769
44777
|
const editedRow = this.dataSource.getSingleEditingRow();
|
|
44770
|
-
this.previouslyEditedRowId = opts.keepEditing ? (editedRow?.editing ? editedRow.id : undefined)
|
|
44778
|
+
this.previouslyEditedRowId = opts.keepEditing ? ((editedRow?.editing ? editedRow.id : undefined) ?? this.singleSelectedRow?.id) : undefined;
|
|
44771
44779
|
const previouslyEditedRowId = this.previouslyEditedRowId;
|
|
44772
44780
|
const previouslyEditedData = opts.keepEditing
|
|
44773
|
-
? (isNotNil(previouslyEditedRowId) && editedRow?.currentData)
|
|
44781
|
+
? ((isNotNil(previouslyEditedRowId) && editedRow?.currentData) ?? this.singleSelectedRow?.currentData)
|
|
44774
44782
|
: undefined;
|
|
44775
|
-
|
|
44776
|
-
|
|
44783
|
+
const previouslySelectedRowIds = !opts.keepEditing && opts.keepSelection && this.selection.hasValue() ? this.selection.selected.map((row) => row.id) : undefined;
|
|
44784
|
+
if (opts.confirmRow !== false && !(await this.confirmEditCreate())) {
|
|
44785
|
+
if (opts.throwIfNotConfirmed !== false) {
|
|
44786
|
+
throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
44787
|
+
}
|
|
44788
|
+
else {
|
|
44789
|
+
// Return false if confirmRow is true and throwIfNotConfirmed is false
|
|
44790
|
+
return false;
|
|
44791
|
+
}
|
|
44777
44792
|
}
|
|
44778
44793
|
// Mark as saving
|
|
44779
44794
|
this.markAsSaving();
|
|
@@ -44796,8 +44811,15 @@ class AppAsyncTable {
|
|
|
44796
44811
|
if (isNotNil(previouslyEditedRowId)) {
|
|
44797
44812
|
await this.selectRowByIdOrData(previouslyEditedRowId, previouslyEditedData);
|
|
44798
44813
|
}
|
|
44814
|
+
else if (isNotEmptyArray(previouslySelectedRowIds)) {
|
|
44815
|
+
await this.selectRowsByIds(previouslySelectedRowIds);
|
|
44816
|
+
}
|
|
44799
44817
|
}
|
|
44800
44818
|
}
|
|
44819
|
+
async selectRowsByIds(rowIds) {
|
|
44820
|
+
await this.waitIdle();
|
|
44821
|
+
this.selection.setSelection(...(this.dataSource?.getRows() ?? []).filter((row) => rowIds.includes(row.id)));
|
|
44822
|
+
}
|
|
44801
44823
|
async cancel(event, opts) {
|
|
44802
44824
|
// Check confirmation
|
|
44803
44825
|
if ((!opts || opts.interactive !== false) && this.dirty && (this.confirmBeforeCancel || this.onBeforeCancelRows.observed)) {
|