@sumaris-net/ngx-components 1.12.3 → 1.12.4
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/bundles/sumaris-net.ngx-components.umd.js +13 -8
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +4 -0
- package/esm2015/src/app/core/table/table.class.js +14 -9
- package/fesm2015/sumaris-net.ngx-components.js +13 -8
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
|
@@ -22097,19 +22097,29 @@ class AppTable {
|
|
|
22097
22097
|
const canDelete = yield this.canDeleteRows(rows, opts);
|
|
22098
22098
|
if (!canDelete)
|
|
22099
22099
|
return 0; // Cannot delete
|
|
22100
|
+
// Reverse row order (on a copy)
|
|
22101
|
+
// This is a workaround, need because row.delete() has async execution
|
|
22102
|
+
// and index cache is updated with a delay
|
|
22103
|
+
rows = rows.slice()
|
|
22104
|
+
.sort((a, b) => a.id > b.id ? -1 : 1);
|
|
22100
22105
|
// If data need to be saved first
|
|
22101
22106
|
if (this.saveBeforeDelete) {
|
|
22102
22107
|
// Cancel invalid rows (because of save() will fail, if invalid rows exists)
|
|
22103
22108
|
rows = rows.reduce((res, row) => {
|
|
22104
22109
|
if (row.validator && !row.validator.valid) {
|
|
22105
|
-
const deleted = row.id === -1;
|
|
22106
|
-
row.cancelOrDelete();
|
|
22107
22110
|
// When deleted (= newly created row) : decrement counter
|
|
22108
|
-
if (
|
|
22111
|
+
if (row.id === -1 || !row.editing) {
|
|
22112
|
+
row.delete();
|
|
22109
22113
|
this.visibleRowCount--;
|
|
22110
22114
|
this.totalRowCount--;
|
|
22111
22115
|
return res;
|
|
22112
22116
|
}
|
|
22117
|
+
// Mark row as pristine, to avoid row to be saved
|
|
22118
|
+
else {
|
|
22119
|
+
row.cancelOrDelete(); // Will cancel only (delete will always go into the previous 'if')
|
|
22120
|
+
row.validator.markAsPristine();
|
|
22121
|
+
// Continue: the row will be deleted after the save
|
|
22122
|
+
}
|
|
22113
22123
|
}
|
|
22114
22124
|
return res.concat(row);
|
|
22115
22125
|
}, []);
|
|
@@ -22131,11 +22141,6 @@ class AppTable {
|
|
|
22131
22141
|
if (deleteCount) {
|
|
22132
22142
|
if (this.debug)
|
|
22133
22143
|
console.debug('[table] Delete selected rows...');
|
|
22134
|
-
// Reverse row order (on a copy)
|
|
22135
|
-
// This is a workaround, need because row.delete() has async execution
|
|
22136
|
-
// and index cache is updated with a delay
|
|
22137
|
-
rows = rows.slice()
|
|
22138
|
-
.sort((a, b) => a.id > b.id ? -1 : 1);
|
|
22139
22144
|
yield this._dataSource.deleteAll(rows);
|
|
22140
22145
|
}
|
|
22141
22146
|
// DO not update manually, because watchALl().subscribe() will update this count
|