@sumaris-net/ngx-components 1.23.1 → 1.23.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 +30 -51
- 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/esm2015/src/app/core/table/entities-table-datasource.class.js +15 -29
- package/esm2015/src/app/core/table/table.class.js +18 -23
- package/fesm2015/sumaris-net.ngx-components.js +30 -49
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/table/entities-table-datasource.class.d.ts +1 -1
- package/src/app/core/table/table.class.d.ts +1 -4
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -22347,7 +22347,6 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22347
22347
|
this._creating = false;
|
|
22348
22348
|
this._saving = false;
|
|
22349
22349
|
this._stopWatching$ = new Subject();
|
|
22350
|
-
this._editingRowCount = 0;
|
|
22351
22350
|
this._fetchMoreFn = null;
|
|
22352
22351
|
this.loadingSubject = new BehaviorSubject(undefined);
|
|
22353
22352
|
this._entityName = removeEnd((new dataType()).__typename || 'UnknownVO', 'VO');
|
|
@@ -22394,7 +22393,6 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22394
22393
|
}
|
|
22395
22394
|
watchAll(offset, size, sortBy, sortDirection, filter) {
|
|
22396
22395
|
this._stopWatching$.next();
|
|
22397
|
-
this._editingRowCount = 0;
|
|
22398
22396
|
this._fetchMoreFn = null;
|
|
22399
22397
|
this.markAsLoading();
|
|
22400
22398
|
return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
|
|
@@ -22402,8 +22400,8 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22402
22400
|
if (this._saving) {
|
|
22403
22401
|
console.info(`[table-datasource] Received ${this._entityName} data (from service), but still saving: skip`);
|
|
22404
22402
|
}
|
|
22405
|
-
else if (this.
|
|
22406
|
-
console.warn(`[table-datasource] Received ${this._entityName} data, while
|
|
22403
|
+
else if (this.hasSomeEditingRow()) {
|
|
22404
|
+
console.warn(`[table-datasource] Received ${this._entityName} data, while some row still editing: skip; Please check save() implementation in the table!`);
|
|
22407
22405
|
}
|
|
22408
22406
|
else {
|
|
22409
22407
|
this.updateDatasource((res.data || []));
|
|
@@ -22457,7 +22455,6 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22457
22455
|
// Stop with an error
|
|
22458
22456
|
throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
22459
22457
|
}
|
|
22460
|
-
this._editingRowCount = 0;
|
|
22461
22458
|
let data;
|
|
22462
22459
|
let dataToSave;
|
|
22463
22460
|
if (this.validatorService) {
|
|
@@ -22534,7 +22531,6 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22534
22531
|
console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
|
|
22535
22532
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
22536
22533
|
}
|
|
22537
|
-
this._editingRowCount--;
|
|
22538
22534
|
return true;
|
|
22539
22535
|
}
|
|
22540
22536
|
confirmEdit(row) {
|
|
@@ -22544,7 +22540,6 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22544
22540
|
console.warn('[table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
|
|
22545
22541
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
22546
22542
|
}
|
|
22547
|
-
this._editingRowCount--;
|
|
22548
22543
|
return true;
|
|
22549
22544
|
}
|
|
22550
22545
|
startEdit(row) {
|
|
@@ -22554,7 +22549,6 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22554
22549
|
console.warn('[table-datasource] Row still has {editing: false} after startEdit()! Force editing');
|
|
22555
22550
|
row.validator.enable({ onlySelf: true, emitEvent: false });
|
|
22556
22551
|
}
|
|
22557
|
-
this._editingRowCount++;
|
|
22558
22552
|
}
|
|
22559
22553
|
handleError(error, message) {
|
|
22560
22554
|
const errorMsg = error && error.message || error;
|
|
@@ -22578,9 +22572,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22578
22572
|
console.error(`[table-datasource] Row to delete with id=${id} not found`);
|
|
22579
22573
|
return;
|
|
22580
22574
|
}
|
|
22581
|
-
|
|
22582
|
-
this._editingRowCount--;
|
|
22583
|
-
this.loadingSubject.next(true);
|
|
22575
|
+
this.markAsLoading();
|
|
22584
22576
|
this.dataService.deleteAll([row.currentData], this.serviceOptions)
|
|
22585
22577
|
.catch(err => this.handleServiceError(err))
|
|
22586
22578
|
.then(() => {
|
|
@@ -22589,7 +22581,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22589
22581
|
const present = this.getRow(id) === row;
|
|
22590
22582
|
if (present)
|
|
22591
22583
|
super.delete(id);
|
|
22592
|
-
this.
|
|
22584
|
+
this.markAsLoaded();
|
|
22593
22585
|
}, 300);
|
|
22594
22586
|
});
|
|
22595
22587
|
}
|
|
@@ -22600,20 +22592,13 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22600
22592
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22601
22593
|
this.markAsLoading();
|
|
22602
22594
|
const data = this.getDataFromRows(rows);
|
|
22603
|
-
const rowsById = Beans.collectById(rows);
|
|
22604
22595
|
try {
|
|
22605
22596
|
// Call service deletion
|
|
22606
22597
|
yield this.dataService.deleteAll(data, this.serviceOptions);
|
|
22607
22598
|
// Workaround, to be sure all rows have been deleted
|
|
22608
|
-
// Sometimes, the service miss deletion, or GrapQHl cache remove failed
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
const row = rowsById[id];
|
|
22612
|
-
const present = this.getRow(+id) === row;
|
|
22613
|
-
return present ? res.concat(row) : res;
|
|
22614
|
-
}, []);
|
|
22615
|
-
//this.getRows().filter(row => rows.includes(row));
|
|
22616
|
-
// Apply missing deletion
|
|
22599
|
+
// Sometimes, the service miss deletion, or GrapQHl cache remove failed.
|
|
22600
|
+
// In this case, apply missing deletion using the super.delete() function
|
|
22601
|
+
const rowNotDeleted = this.getRows().filter(rows.includes);
|
|
22617
22602
|
if (isNotEmptyArray(rowNotDeleted)) {
|
|
22618
22603
|
console.warn(`[table-datasource] Force deletion of ${rowNotDeleted.length} rows (Is service update the cache ?)`);
|
|
22619
22604
|
rowNotDeleted
|
|
@@ -22623,7 +22608,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22623
22608
|
}
|
|
22624
22609
|
}
|
|
22625
22610
|
catch (err) {
|
|
22626
|
-
// Handle
|
|
22611
|
+
// Handle service error
|
|
22627
22612
|
this.handleServiceError(err);
|
|
22628
22613
|
}
|
|
22629
22614
|
finally {
|
|
@@ -22637,6 +22622,9 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22637
22622
|
getRows() {
|
|
22638
22623
|
return this.rowsSubject.getValue();
|
|
22639
22624
|
}
|
|
22625
|
+
hasSomeEditingRow() {
|
|
22626
|
+
return (this.rowsSubject.value || []).some(row => row.editing);
|
|
22627
|
+
}
|
|
22640
22628
|
createNew(insertAt, options = { editing: true }) {
|
|
22641
22629
|
const _super = Object.create(null, {
|
|
22642
22630
|
createNew: { get: () => super.createNew }
|
|
@@ -22659,8 +22647,6 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22659
22647
|
console.error(err && err.message || err, err);
|
|
22660
22648
|
}
|
|
22661
22649
|
}
|
|
22662
|
-
if (row.editing)
|
|
22663
|
-
this._editingRowCount++;
|
|
22664
22650
|
return row;
|
|
22665
22651
|
}
|
|
22666
22652
|
finally {
|
|
@@ -22679,8 +22665,8 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22679
22665
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22680
22666
|
if (!this._fetchMoreFn)
|
|
22681
22667
|
return false; // Avoid multiple call
|
|
22682
|
-
if (this.
|
|
22683
|
-
console.warn(`Cannot fetch more ${this._entityName} because
|
|
22668
|
+
if (this.hasSomeEditingRow()) {
|
|
22669
|
+
console.warn(`Cannot fetch more ${this._entityName} because some row) still editing`);
|
|
22684
22670
|
return;
|
|
22685
22671
|
}
|
|
22686
22672
|
console.debug(`Will fetching more row(s) still...`);
|
|
@@ -22752,7 +22738,6 @@ class AppTable {
|
|
|
22752
22738
|
this.savingSubject = new BehaviorSubject(false);
|
|
22753
22739
|
this.dirtySubject = new BehaviorSubject(false);
|
|
22754
22740
|
this.errorSubject = new BehaviorSubject(undefined);
|
|
22755
|
-
this.isRateLimitReached = false;
|
|
22756
22741
|
this.selection = new SelectionModel(true, []);
|
|
22757
22742
|
this.editedRow = undefined;
|
|
22758
22743
|
this.i18nColumnPrefix = 'COMMON.';
|
|
@@ -23071,7 +23056,7 @@ class AppTable {
|
|
|
23071
23056
|
return of(undefined); // Continue
|
|
23072
23057
|
}))
|
|
23073
23058
|
.subscribe(res => this.updateView(res)));
|
|
23074
|
-
// Listen dataSource events
|
|
23059
|
+
// Listen dataSource loading events
|
|
23075
23060
|
if (this._dataSource)
|
|
23076
23061
|
this.listenDatasourceLoading(this._dataSource);
|
|
23077
23062
|
}
|
|
@@ -23146,7 +23131,6 @@ class AppTable {
|
|
|
23146
23131
|
if (!res)
|
|
23147
23132
|
return; // Skip (e.g error)
|
|
23148
23133
|
if (res && res.data) {
|
|
23149
|
-
this.isRateLimitReached = !this.paginator || (res.data.length < this.paginator.pageSize);
|
|
23150
23134
|
this.visibleRowCount = res.data.length;
|
|
23151
23135
|
this.totalRowCount = isNotNil(res.total) ? res.total : ((this.paginator && this.paginator.pageIndex * (this.paginator.pageSize || DEFAULT_PAGE_SIZE) || 0) + this.visibleRowCount);
|
|
23152
23136
|
if (this.debug)
|
|
@@ -23154,7 +23138,6 @@ class AppTable {
|
|
|
23154
23138
|
}
|
|
23155
23139
|
else {
|
|
23156
23140
|
//if (this.debug) console.debug('[table] NO rows loaded');
|
|
23157
|
-
this.isRateLimitReached = true;
|
|
23158
23141
|
this.totalRowCount = 0;
|
|
23159
23142
|
this.visibleRowCount = 0;
|
|
23160
23143
|
}
|
|
@@ -23507,22 +23490,19 @@ class AppTable {
|
|
|
23507
23490
|
if (this.saveBeforeDelete) {
|
|
23508
23491
|
// Exclude invalid rows (because of save() will fail, when exists some invalid rows)
|
|
23509
23492
|
rows = rows.filter(row => {
|
|
23510
|
-
if
|
|
23511
|
-
|
|
23512
|
-
|
|
23513
|
-
|
|
23514
|
-
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|
|
23524
|
-
// Continue: the row will be deleted after the save
|
|
23525
|
-
}
|
|
23493
|
+
// Delete the row, if newly created row (id = -1), or if invalid and not editing (= not cancellable)
|
|
23494
|
+
if (row.id === -1 || (!row.valid && !row.editing)) {
|
|
23495
|
+
row.delete();
|
|
23496
|
+
this.visibleRowCount--;
|
|
23497
|
+
this.totalRowCount--;
|
|
23498
|
+
return false;
|
|
23499
|
+
}
|
|
23500
|
+
// Cancel the row (and mark as pristine), when not valid but in edition
|
|
23501
|
+
else if (!row.valid && row.editing) {
|
|
23502
|
+
row.cancel();
|
|
23503
|
+
// Mark row as pristine (if possible)
|
|
23504
|
+
this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|
|
23505
|
+
return true; // Keep the row. the row will be deleted after the save
|
|
23526
23506
|
}
|
|
23527
23507
|
return true;
|
|
23528
23508
|
});
|
|
@@ -24237,8 +24217,9 @@ class AppTable {
|
|
|
24237
24217
|
if (this.debug)
|
|
24238
24218
|
console.debug('[table] Many call to listenDatasource(): Cleaning previous subscriptions...');
|
|
24239
24219
|
this._dataSourceLoadingSubscription.unsubscribe();
|
|
24240
|
-
this.
|
|
24220
|
+
this.unregisterSubscription(this._dataSourceLoadingSubscription);
|
|
24241
24221
|
}
|
|
24222
|
+
// Propage loading to table
|
|
24242
24223
|
this._dataSourceLoadingSubscription = this._dataSource.loadingSubject
|
|
24243
24224
|
.pipe(distinctUntilChanged(),
|
|
24244
24225
|
// If changed to True: propagate as soon as possible
|
|
@@ -24246,7 +24227,7 @@ class AppTable {
|
|
|
24246
24227
|
// If changed to False: wait 250ms before propagate (to make sure the spinner has been displayed)
|
|
24247
24228
|
debounceTime(250), tap(loading => !loading && this.setLoading(false)))
|
|
24248
24229
|
.subscribe();
|
|
24249
|
-
this.
|
|
24230
|
+
this.registerSubscription(this._dataSourceLoadingSubscription);
|
|
24250
24231
|
}
|
|
24251
24232
|
startCellValueChanges(name, row) {
|
|
24252
24233
|
const def = this._cellValueChangesDefs[name];
|