@sumaris-net/ngx-components 2.4.106 → 2.4.107
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/esm2020/src/app/core/services/model/entity.model.mjs +4 -1
- package/esm2020/src/app/core/table/table.class.mjs +10 -3
- package/esm2020/src/app/core/table/table.utils.mjs +6 -3
- package/fesm2015/sumaris-net.ngx-components.mjs +16 -3
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +16 -3
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/model/entity.model.d.ts +1 -0
|
@@ -11609,6 +11609,9 @@ class EntityUtils {
|
|
|
11609
11609
|
static getId(entity) {
|
|
11610
11610
|
return entity.id;
|
|
11611
11611
|
}
|
|
11612
|
+
static hasId(entity) {
|
|
11613
|
+
return isNotNil(entity.id);
|
|
11614
|
+
}
|
|
11612
11615
|
static collectById(entities) {
|
|
11613
11616
|
return (entities || []).map(e => e.id);
|
|
11614
11617
|
}
|
|
@@ -26484,6 +26487,9 @@ class AppTableUtils {
|
|
|
26484
26487
|
AppFormUtils.logFormErrors(row.validator, logPrefix);
|
|
26485
26488
|
}
|
|
26486
26489
|
static getEntityId(row) {
|
|
26490
|
+
// When using validator: use the control (avoid to load the full form's value)
|
|
26491
|
+
if (row.validator)
|
|
26492
|
+
return row.validator.get('id').value;
|
|
26487
26493
|
return EntityUtils.getId(row.currentData);
|
|
26488
26494
|
}
|
|
26489
26495
|
static getEntityIds(rows) {
|
|
@@ -26491,7 +26497,7 @@ class AppTableUtils {
|
|
|
26491
26497
|
.map((row) => row.currentData)
|
|
26492
26498
|
.filter(isNotNil)
|
|
26493
26499
|
.map(EntityUtils.getId)
|
|
26494
|
-
.filter(
|
|
26500
|
+
.filter(isNotNil);
|
|
26495
26501
|
}
|
|
26496
26502
|
static getEntities(rows) {
|
|
26497
26503
|
return (rows || [])
|
|
@@ -27233,6 +27239,11 @@ class AppTable {
|
|
|
27233
27239
|
// Listen dataSource loading events
|
|
27234
27240
|
if (this._dataSource)
|
|
27235
27241
|
this.listenDatasourceLoading(this._dataSource);
|
|
27242
|
+
// Enable permanent selection (to keep selected rows after reloading)
|
|
27243
|
+
// (only on desktop, if not already done)
|
|
27244
|
+
if (!this.mobile && !this.permanentSelection) {
|
|
27245
|
+
this.initPermanentSelection();
|
|
27246
|
+
}
|
|
27236
27247
|
}
|
|
27237
27248
|
ngAfterViewInit() {
|
|
27238
27249
|
// Detect when parent ngOnInit() not call
|
|
@@ -27625,6 +27636,7 @@ class AppTable {
|
|
|
27625
27636
|
if (row.id === -1 || (!row.editing && row.invalid /*do not use !valid because if row is disabled, it will be always !valid */)) {
|
|
27626
27637
|
if (this.debug)
|
|
27627
27638
|
console.debug(`[table] Delete row #${row.id}`);
|
|
27639
|
+
this.selection.deselect(row);
|
|
27628
27640
|
row.delete();
|
|
27629
27641
|
this.visibleRowCount--;
|
|
27630
27642
|
this.totalRowCount--;
|
|
@@ -27635,6 +27647,7 @@ class AppTable {
|
|
|
27635
27647
|
}
|
|
27636
27648
|
// Cancel the row (and mark as pristine), when not valid but in edition
|
|
27637
27649
|
else if (row.editing && !row.valid) {
|
|
27650
|
+
this.selection.deselect(row);
|
|
27638
27651
|
row.cancel();
|
|
27639
27652
|
// Mark row as pristine (if possible)
|
|
27640
27653
|
this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|
|
@@ -28470,7 +28483,7 @@ class AppTable {
|
|
|
28470
28483
|
if (selectionChange.added.length) {
|
|
28471
28484
|
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
28472
28485
|
// Add new elements
|
|
28473
|
-
.concat(...AppTableUtils.getEntities(selectionChange.added))
|
|
28486
|
+
.concat(...AppTableUtils.getEntities(selectionChange.added).filter(EntityUtils.hasId))
|
|
28474
28487
|
// Avoid duplicated entities (Mantis #55351)
|
|
28475
28488
|
.filter(EntityUtils.arrayDistinctFilterFn));
|
|
28476
28489
|
}
|
|
@@ -28478,7 +28491,7 @@ class AppTable {
|
|
|
28478
28491
|
if (selectionChange.removed.length) {
|
|
28479
28492
|
const removedIds = AppTableUtils.getEntityIds(selectionChange.removed);
|
|
28480
28493
|
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
28481
|
-
.filter((entity) => !removedIds.includes(entity.id)));
|
|
28494
|
+
.filter((entity) => EntityUtils.hasId(entity) && !removedIds.includes(entity.id)));
|
|
28482
28495
|
}
|
|
28483
28496
|
this.markForCheck();
|
|
28484
28497
|
}));
|