@sumaris-net/ngx-components 2.8.2-beta5 → 2.8.3-beta7
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 -2
- package/esm2022/src/app/core/table/async-table.class.mjs +82 -74
- package/esm2022/src/app/core/table/table.class.mjs +15 -19
- package/fesm2022/sumaris-net.ngx-components.mjs +94 -90
- 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 +11 -9
- package/src/app/core/table/table.class.d.ts +2 -2
- package/src/assets/manifest.json +1 -1
|
@@ -29250,7 +29250,7 @@ class AppTable {
|
|
|
29250
29250
|
isAllSelected() {
|
|
29251
29251
|
// DEBUG
|
|
29252
29252
|
//console.debug('isAllSelected. lengths', this.selection.selected.length, this.totalRowCount);
|
|
29253
|
-
return this.selection.selected.length === this.visibleRowCount;
|
|
29253
|
+
return this.selection.selected.length === this.totalRowCount || this.selection.selected.length === this.visibleRowCount;
|
|
29254
29254
|
}
|
|
29255
29255
|
/** Selects all rows if they are not all selected; otherwise clear selection. */
|
|
29256
29256
|
async masterToggle() {
|
|
@@ -29266,9 +29266,8 @@ class AppTable {
|
|
|
29266
29266
|
}
|
|
29267
29267
|
async deleteSelection(event, opts) {
|
|
29268
29268
|
const deleteCount = await this.deleteRows(event, this.selection.selected, opts);
|
|
29269
|
-
if (deleteCount > 0)
|
|
29269
|
+
if (deleteCount > 0)
|
|
29270
29270
|
this.selection.clear();
|
|
29271
|
-
}
|
|
29272
29271
|
return deleteCount;
|
|
29273
29272
|
}
|
|
29274
29273
|
/**
|
|
@@ -29279,11 +29278,7 @@ class AppTable {
|
|
|
29279
29278
|
* And to force deletion even if table is busy
|
|
29280
29279
|
*/
|
|
29281
29280
|
async deleteRow(event, row, opts) {
|
|
29282
|
-
const isSelected = this.selection.isSelected(row);
|
|
29283
29281
|
const deleteCount = await this.deleteRows(event, [row], opts);
|
|
29284
|
-
// Unselect the deleted row
|
|
29285
|
-
if (deleteCount && isSelected)
|
|
29286
|
-
this.selection.deselect(row);
|
|
29287
29282
|
return deleteCount === 1;
|
|
29288
29283
|
}
|
|
29289
29284
|
/**
|
|
@@ -29461,7 +29456,8 @@ class AppTable {
|
|
|
29461
29456
|
return Promise.resolve();
|
|
29462
29457
|
return waitForFalse(this.loadingSubject, { stop: this.destroySubject, ...opts });
|
|
29463
29458
|
}
|
|
29464
|
-
async openSelectColumnsModal(
|
|
29459
|
+
async openSelectColumnsModal(event) {
|
|
29460
|
+
event?.preventDefault();
|
|
29465
29461
|
// Copy current columns (deep copy)
|
|
29466
29462
|
const columns = this.getCurrentColumns();
|
|
29467
29463
|
const hasTopModal = !!(await this.modalCtrl.getTop());
|
|
@@ -29523,12 +29519,12 @@ class AppTable {
|
|
|
29523
29519
|
if (row.id === -1) {
|
|
29524
29520
|
if (row.validator) {
|
|
29525
29521
|
// If pending: Wait end of validation, then loop
|
|
29526
|
-
if (row.
|
|
29522
|
+
if (row.pending) {
|
|
29527
29523
|
AppFormUtils.waitWhilePending(row.validator).then(() => this.escapeEditingRow(event, row));
|
|
29528
29524
|
return;
|
|
29529
29525
|
}
|
|
29530
29526
|
// Row is invalid: delete the row
|
|
29531
|
-
if (row.
|
|
29527
|
+
if (row.invalid) {
|
|
29532
29528
|
this.deleteNewRow(event, row);
|
|
29533
29529
|
return;
|
|
29534
29530
|
}
|
|
@@ -29536,7 +29532,7 @@ class AppTable {
|
|
|
29536
29532
|
}
|
|
29537
29533
|
// If the row exists (has an id)
|
|
29538
29534
|
else {
|
|
29539
|
-
// need to call cancel function (if confirmation will be
|
|
29535
|
+
// need to call cancel function (if confirmation will be called before)
|
|
29540
29536
|
if (this.confirmBeforeCancel) {
|
|
29541
29537
|
this.cancelExistingRow(event, row, { keepEditing: false });
|
|
29542
29538
|
return;
|
|
@@ -29546,7 +29542,7 @@ class AppTable {
|
|
|
29546
29542
|
this.confirmEditCreate(event, row);
|
|
29547
29543
|
}
|
|
29548
29544
|
translateControlPath(path) {
|
|
29549
|
-
// Can be
|
|
29545
|
+
// Can be overridden by subclasses, to resolve all field name
|
|
29550
29546
|
// Use columns key, has default name
|
|
29551
29547
|
const i18nColumnKey = this.getI18nColumnName(path);
|
|
29552
29548
|
return this.translate?.instant(i18nColumnKey) || i18nColumnKey;
|
|
@@ -29710,7 +29706,7 @@ class AppTable {
|
|
|
29710
29706
|
}
|
|
29711
29707
|
/**
|
|
29712
29708
|
* Open a row detail view. By default, will to open row detail page.
|
|
29713
|
-
* Can be
|
|
29709
|
+
* Can be overridden by subclasses, BUT prefer to subscribe on onOpenRow
|
|
29714
29710
|
*
|
|
29715
29711
|
* @param id
|
|
29716
29712
|
* @param row
|
|
@@ -29730,7 +29726,7 @@ class AppTable {
|
|
|
29730
29726
|
console.warn('[table] Opening row details, but data has no id!');
|
|
29731
29727
|
return false;
|
|
29732
29728
|
}
|
|
29733
|
-
return this.navController.navigateForward(`${this.router.url}/${id
|
|
29729
|
+
return this.navController.navigateForward(`${this.router.url}/${id}`, {
|
|
29734
29730
|
queryParams: {},
|
|
29735
29731
|
});
|
|
29736
29732
|
}
|
|
@@ -29811,17 +29807,17 @@ class AppTable {
|
|
|
29811
29807
|
return (this.i18nColumnPrefix || '') + changeCaseToUnderscore(columnName).toUpperCase();
|
|
29812
29808
|
}
|
|
29813
29809
|
generateTableId() {
|
|
29810
|
+
// noinspection JSNonASCIINames
|
|
29814
29811
|
const meta = this.constructor['ɵcmp'];
|
|
29815
29812
|
// Get a component unique name - See https://stackoverflow.com/questions/60114682/how-to-access-components-unique-encapsulation-id-in-angular-9
|
|
29816
29813
|
const componentId = (meta && (meta.selectors?.[0] || meta.id)) || this.constructor.name;
|
|
29817
29814
|
const id = this.location
|
|
29818
29815
|
.path(true)
|
|
29819
29816
|
.replace(/[?].*$/g, '')
|
|
29820
|
-
.replace(
|
|
29817
|
+
.replace(/\/\d+/g, '_id') +
|
|
29821
29818
|
'_' +
|
|
29822
29819
|
componentId;
|
|
29823
|
-
//if (this.debug)
|
|
29824
|
-
console.debug('[table] id = ' + id);
|
|
29820
|
+
//if (this.debug) console.debug('[table] id = ' + id);
|
|
29825
29821
|
return id;
|
|
29826
29822
|
}
|
|
29827
29823
|
async addRowToTable(insertAt, opts) {
|
|
@@ -29896,7 +29892,7 @@ class AppTable {
|
|
|
29896
29892
|
return input && input.toUpperCase().startsWith(search);
|
|
29897
29893
|
}
|
|
29898
29894
|
markForCheck() {
|
|
29899
|
-
// Should be
|
|
29895
|
+
// Should be overridden by subclasses, depending on ChangeDetectionStrategy
|
|
29900
29896
|
}
|
|
29901
29897
|
async askDeleteConfirmation(event, rows) {
|
|
29902
29898
|
if (this.undoableDeletion) {
|
|
@@ -34567,6 +34563,7 @@ class AppAsyncTable {
|
|
|
34567
34563
|
allowRowDetail = true;
|
|
34568
34564
|
route;
|
|
34569
34565
|
router;
|
|
34566
|
+
navController;
|
|
34570
34567
|
location;
|
|
34571
34568
|
settings;
|
|
34572
34569
|
translate;
|
|
@@ -34663,13 +34660,13 @@ class AppAsyncTable {
|
|
|
34663
34660
|
return this.dirtySubject.value;
|
|
34664
34661
|
}
|
|
34665
34662
|
get valid() {
|
|
34666
|
-
return this.dataSource.
|
|
34663
|
+
return this.dataSource.getEditingRows().every((row) => (row.editing ? row.valid : true));
|
|
34667
34664
|
}
|
|
34668
34665
|
get invalid() {
|
|
34669
|
-
return this.dataSource.
|
|
34666
|
+
return this.dataSource.getEditingRows().some((row) => (row.editing ? row.invalid : false));
|
|
34670
34667
|
}
|
|
34671
34668
|
get pending() {
|
|
34672
|
-
return this.dataSource.
|
|
34669
|
+
return this.dataSource.getEditingRows().some((row) => (row.editing ? row.pending : false));
|
|
34673
34670
|
}
|
|
34674
34671
|
get touched() {
|
|
34675
34672
|
return this.touchedSubject.value;
|
|
@@ -34707,7 +34704,7 @@ class AppAsyncTable {
|
|
|
34707
34704
|
return !this._enabled;
|
|
34708
34705
|
}
|
|
34709
34706
|
markAsDirty(opts) {
|
|
34710
|
-
if (this.dirtySubject.value !== true) {
|
|
34707
|
+
if (!this.dirtySubject.closed && this.dirtySubject.value !== true) {
|
|
34711
34708
|
this.dirtySubject.next(true);
|
|
34712
34709
|
if (!opts || opts.emitEvent !== false) {
|
|
34713
34710
|
this.markForCheck();
|
|
@@ -34715,7 +34712,7 @@ class AppAsyncTable {
|
|
|
34715
34712
|
}
|
|
34716
34713
|
}
|
|
34717
34714
|
markAsPristine(opts) {
|
|
34718
|
-
if (this.dirtySubject.value !== false) {
|
|
34715
|
+
if (!this.dirtySubject.closed && this.dirtySubject.value !== false) {
|
|
34719
34716
|
this.dirtySubject.next(false);
|
|
34720
34717
|
if (!opts || opts.emitEvent !== false) {
|
|
34721
34718
|
this.markForCheck();
|
|
@@ -34728,7 +34725,7 @@ class AppAsyncTable {
|
|
|
34728
34725
|
this.touchedSubject.next(false);
|
|
34729
34726
|
needEmitEvent = true;
|
|
34730
34727
|
}
|
|
34731
|
-
if (this.dirty
|
|
34728
|
+
if (this.dirty) {
|
|
34732
34729
|
for (const row of this.dataSource.getEditingRows()) {
|
|
34733
34730
|
// Cancel the current editing row only if editing and if it was not previously saved
|
|
34734
34731
|
if (row.id === -1) {
|
|
@@ -34762,17 +34759,15 @@ class AppAsyncTable {
|
|
|
34762
34759
|
}
|
|
34763
34760
|
}
|
|
34764
34761
|
markAllAsTouched(opts) {
|
|
34765
|
-
if (this.touchedSubject.value !== true) {
|
|
34762
|
+
if (!this.touchedSubject.closed && this.touchedSubject.value !== true) {
|
|
34766
34763
|
this.touchedSubject.next(true);
|
|
34767
34764
|
if (!opts || opts.emitEvent !== false)
|
|
34768
34765
|
this.markForCheck();
|
|
34769
34766
|
}
|
|
34770
|
-
|
|
34771
|
-
this.dataSource.getEditingRows().forEach((row) => row.validator?.markAllAsTouched());
|
|
34772
|
-
}
|
|
34767
|
+
this.dataSource.getEditingRows().forEach((row) => row.validator?.markAllAsTouched());
|
|
34773
34768
|
}
|
|
34774
34769
|
markAsSaving(opts) {
|
|
34775
|
-
if (this.savingSubject.value !== true) {
|
|
34770
|
+
if (!this.savingSubject.closed && this.savingSubject.value !== true) {
|
|
34776
34771
|
this.focusColumn = undefined; // unselect focus column
|
|
34777
34772
|
this.savingSubject.next(true);
|
|
34778
34773
|
if (!opts || opts.emitEvent !== false)
|
|
@@ -34780,7 +34775,7 @@ class AppAsyncTable {
|
|
|
34780
34775
|
}
|
|
34781
34776
|
}
|
|
34782
34777
|
markAsSaved(opts) {
|
|
34783
|
-
if (this.savingSubject.value !== false) {
|
|
34778
|
+
if (!this.savingSubject.closed && this.savingSubject.value !== false) {
|
|
34784
34779
|
this.savingSubject.next(false);
|
|
34785
34780
|
if (!opts || opts.emitEvent !== false)
|
|
34786
34781
|
this.markForCheck();
|
|
@@ -34793,7 +34788,7 @@ class AppAsyncTable {
|
|
|
34793
34788
|
this.setLoading(false, opts);
|
|
34794
34789
|
}
|
|
34795
34790
|
markAsReady(opts) {
|
|
34796
|
-
if (this.readySubject.value !== true) {
|
|
34791
|
+
if (!this.readySubject.closed && this.readySubject.value !== true) {
|
|
34797
34792
|
this.readySubject.next(true);
|
|
34798
34793
|
// If subclasses implements OnReady
|
|
34799
34794
|
if (typeof this['ngOnReady'] === 'function') {
|
|
@@ -34852,6 +34847,7 @@ class AppAsyncTable {
|
|
|
34852
34847
|
this._filter = _filter;
|
|
34853
34848
|
this.route = injector.get(ActivatedRoute);
|
|
34854
34849
|
this.router = injector.get(Router);
|
|
34850
|
+
this.navController = injector.get(NavController);
|
|
34855
34851
|
this.location = injector.get(Location);
|
|
34856
34852
|
this.settings = injector.get(LocalSettingsService);
|
|
34857
34853
|
this.translate = injector.get(TranslateService);
|
|
@@ -35290,7 +35286,7 @@ class AppAsyncTable {
|
|
|
35290
35286
|
if (!confirmed)
|
|
35291
35287
|
return 0; // Cannot delete (e.g. edited row is invalid)
|
|
35292
35288
|
}
|
|
35293
|
-
// Check if
|
|
35289
|
+
// Check if can delete
|
|
35294
35290
|
const canDelete = await this.canDeleteRows(rows, opts);
|
|
35295
35291
|
if (!canDelete)
|
|
35296
35292
|
return 0; // Cannot delete
|
|
@@ -35309,6 +35305,7 @@ class AppAsyncTable {
|
|
|
35309
35305
|
if (row.id === -1 || (!row.editing && row.invalid) /*do not use !valid because if row is disabled, it will be always !valid */) {
|
|
35310
35306
|
if (this.debug)
|
|
35311
35307
|
console.debug(`[table] Delete row #${row.id}`);
|
|
35308
|
+
this.selection.deselect(row);
|
|
35312
35309
|
row.delete();
|
|
35313
35310
|
this.visibleRowCount--;
|
|
35314
35311
|
this.totalRowCount--;
|
|
@@ -35317,6 +35314,7 @@ class AppAsyncTable {
|
|
|
35317
35314
|
}
|
|
35318
35315
|
// Cancel the row (and mark as pristine), when not valid but in edition
|
|
35319
35316
|
else if (row.editing && !row.valid) {
|
|
35317
|
+
this.selection.deselect(row);
|
|
35320
35318
|
row.cancel();
|
|
35321
35319
|
// Mark row as pristine (if possible)
|
|
35322
35320
|
this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|
|
@@ -35346,7 +35344,8 @@ class AppAsyncTable {
|
|
|
35346
35344
|
// DO not update manually, because watchALl().subscribe() will update this count
|
|
35347
35345
|
//this.totalRowCount -= deleteCount;
|
|
35348
35346
|
//this.visibleRowCount -= deleteCount;
|
|
35349
|
-
|
|
35347
|
+
// Deselect deleted rows
|
|
35348
|
+
this.selection.deselect(...rows);
|
|
35350
35349
|
this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
|
|
35351
35350
|
this.markForCheck();
|
|
35352
35351
|
this.onAfterDeletedRows.next(rows);
|
|
@@ -35367,7 +35366,7 @@ class AppAsyncTable {
|
|
|
35367
35366
|
return this.clickRow(null, row);
|
|
35368
35367
|
}
|
|
35369
35368
|
/**
|
|
35370
|
-
* Try to select row by data. Will use
|
|
35369
|
+
* Try to select row by data. Will use equals() to find same row's data
|
|
35371
35370
|
*
|
|
35372
35371
|
* @param data
|
|
35373
35372
|
*/
|
|
@@ -35380,6 +35379,10 @@ class AppAsyncTable {
|
|
|
35380
35379
|
return false;
|
|
35381
35380
|
return this.clickRow(null, row);
|
|
35382
35381
|
}
|
|
35382
|
+
toggleSelectRow(event, row) {
|
|
35383
|
+
event.stopPropagation();
|
|
35384
|
+
this.selection.toggle(row);
|
|
35385
|
+
}
|
|
35383
35386
|
async clickRow(event, row) {
|
|
35384
35387
|
if (this.loading) {
|
|
35385
35388
|
// Wait while loading, and loop
|
|
@@ -35421,10 +35424,12 @@ class AppAsyncTable {
|
|
|
35421
35424
|
await this.dataSource.move(id, direction);
|
|
35422
35425
|
}
|
|
35423
35426
|
ready(opts) {
|
|
35424
|
-
return waitForTrue(this.readySubject, opts);
|
|
35427
|
+
return waitForTrue(this.readySubject, { stop: this.destroySubject, ...opts });
|
|
35425
35428
|
}
|
|
35426
35429
|
waitIdle(opts) {
|
|
35427
|
-
|
|
35430
|
+
if (!this.loadingSubject.value)
|
|
35431
|
+
return Promise.resolve();
|
|
35432
|
+
return waitForFalse(this.loadingSubject, { stop: this.destroySubject, ...opts });
|
|
35428
35433
|
}
|
|
35429
35434
|
async openSelectColumnsModal(event) {
|
|
35430
35435
|
event?.preventDefault();
|
|
@@ -35694,8 +35699,7 @@ class AppAsyncTable {
|
|
|
35694
35699
|
console.warn('[table] Opening row details, but data has no id!');
|
|
35695
35700
|
return false;
|
|
35696
35701
|
}
|
|
35697
|
-
return this.
|
|
35698
|
-
relativeTo: this.route,
|
|
35702
|
+
return this.navController.navigateForward(`${this.router.url}/${id}`, {
|
|
35699
35703
|
queryParams: {},
|
|
35700
35704
|
});
|
|
35701
35705
|
}
|
|
@@ -35708,9 +35712,7 @@ class AppAsyncTable {
|
|
|
35708
35712
|
this.onNewRow.emit(event);
|
|
35709
35713
|
return true;
|
|
35710
35714
|
}
|
|
35711
|
-
return
|
|
35712
|
-
relativeTo: this.route,
|
|
35713
|
-
});
|
|
35715
|
+
return this.navController.navigateForward(`${this.router.url}/new`);
|
|
35714
35716
|
}
|
|
35715
35717
|
// can be overridden to add more required columns
|
|
35716
35718
|
getRequiredColumns() {
|
|
@@ -35779,14 +35781,16 @@ class AppAsyncTable {
|
|
|
35779
35781
|
}
|
|
35780
35782
|
generateTableId() {
|
|
35781
35783
|
// noinspection JSNonASCIINames
|
|
35784
|
+
const meta = this.constructor['ɵcmp'];
|
|
35785
|
+
// Get a component unique name - See https://stackoverflow.com/questions/60114682/how-to-access-components-unique-encapsulation-id-in-angular-9
|
|
35786
|
+
const componentId = (meta && (meta.selectors?.[0] || meta.id)) || this.constructor.name;
|
|
35782
35787
|
const id = this.location
|
|
35783
35788
|
.path(true)
|
|
35784
35789
|
.replace(/[?].*$/g, '')
|
|
35785
35790
|
.replace(/\/\d+/g, '_id') +
|
|
35786
35791
|
'_' +
|
|
35787
|
-
|
|
35788
|
-
|
|
35789
|
-
//if (this.debug) console.debug("[table] id = " + id);
|
|
35792
|
+
componentId;
|
|
35793
|
+
//if (this.debug) console.debug('[table] id = ' + id);
|
|
35790
35794
|
return id;
|
|
35791
35795
|
}
|
|
35792
35796
|
async addRowToTable(insertAt, opts) {
|
|
@@ -35902,7 +35906,7 @@ class AppAsyncTable {
|
|
|
35902
35906
|
}
|
|
35903
35907
|
}
|
|
35904
35908
|
/**
|
|
35905
|
-
* Compare data equality (default by id)
|
|
35909
|
+
* Compare data equality (default by id, using EntityUtils.equals())
|
|
35906
35910
|
* Can be overridden to add additional properties to compare
|
|
35907
35911
|
*
|
|
35908
35912
|
* @param d1
|
|
@@ -35930,6 +35934,50 @@ class AppAsyncTable {
|
|
|
35930
35934
|
this.onRefresh.emit(value);
|
|
35931
35935
|
}
|
|
35932
35936
|
}
|
|
35937
|
+
/**
|
|
35938
|
+
* Initialize the permanent selection model
|
|
35939
|
+
*
|
|
35940
|
+
* @protected
|
|
35941
|
+
*/
|
|
35942
|
+
initPermanentSelection() {
|
|
35943
|
+
if (this.permanentSelection)
|
|
35944
|
+
throw new Error('initPermanentSelection() already called!');
|
|
35945
|
+
this.permanentSelection = new SelectionModel(true, []);
|
|
35946
|
+
// Listen sort change
|
|
35947
|
+
this.registerSubscription(this.onSort.subscribe(() => (this.permanentSelectionChangedPrevented = true)) // prevent selection change on sort
|
|
35948
|
+
);
|
|
35949
|
+
// Listen datasource update
|
|
35950
|
+
this.registerSubscription(this.dataSource.rowsSubject
|
|
35951
|
+
// restore the 'adding' selection (for example after a page or sort change)
|
|
35952
|
+
.subscribe((rows) => {
|
|
35953
|
+
this.permanentSelectionChangedPrevented = true;
|
|
35954
|
+
try {
|
|
35955
|
+
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
35956
|
+
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
35957
|
+
this.markForCheck();
|
|
35958
|
+
}
|
|
35959
|
+
finally {
|
|
35960
|
+
this.permanentSelectionChangedPrevented = false;
|
|
35961
|
+
}
|
|
35962
|
+
}));
|
|
35963
|
+
// Listen selection change
|
|
35964
|
+
this.registerSubscription(this.selection.changed.pipe(filter(() => !this.permanentSelectionChangedPrevented)).subscribe((selectionChange) => {
|
|
35965
|
+
// add to selection
|
|
35966
|
+
if (selectionChange.added.length) {
|
|
35967
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
35968
|
+
// Add new elements
|
|
35969
|
+
.concat(...AppTableUtils.getEntities(selectionChange.added).filter(EntityUtils.hasId))
|
|
35970
|
+
// Avoid duplicated entities (Mantis #55351)
|
|
35971
|
+
.filter(EntityUtils.arrayDistinctFilterFn));
|
|
35972
|
+
}
|
|
35973
|
+
// remove from selection
|
|
35974
|
+
if (selectionChange.removed.length) {
|
|
35975
|
+
const removedIds = AppTableUtils.getEntityIds(selectionChange.removed);
|
|
35976
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || []).filter((entity) => EntityUtils.hasId(entity) && !removedIds.includes(entity.id)));
|
|
35977
|
+
}
|
|
35978
|
+
this.markForCheck();
|
|
35979
|
+
}));
|
|
35980
|
+
}
|
|
35933
35981
|
/* -- private method -- */
|
|
35934
35982
|
async listenSortAndPaginationEvents() {
|
|
35935
35983
|
if (!this.table) {
|
|
@@ -35993,8 +36041,8 @@ class AppAsyncTable {
|
|
|
35993
36041
|
event?.stopPropagation();
|
|
35994
36042
|
this.selection.clear();
|
|
35995
36043
|
await this._dataSource.cancelOrDelete(row);
|
|
35996
|
-
this.onCancelOrDeleteRow.next(row);
|
|
35997
36044
|
this.resetError();
|
|
36045
|
+
this.onCancelOrDeleteRow.next(row);
|
|
35998
36046
|
this.totalRowCount--;
|
|
35999
36047
|
this.visibleRowCount--;
|
|
36000
36048
|
}
|
|
@@ -36126,50 +36174,6 @@ class AppAsyncTable {
|
|
|
36126
36174
|
def.subject.unsubscribe();
|
|
36127
36175
|
}
|
|
36128
36176
|
}
|
|
36129
|
-
/**
|
|
36130
|
-
* Initialize the permanent selection model
|
|
36131
|
-
*
|
|
36132
|
-
* @protected
|
|
36133
|
-
*/
|
|
36134
|
-
initPermanentSelection() {
|
|
36135
|
-
if (this.permanentSelection)
|
|
36136
|
-
throw new Error('initPermanentSelection() already called!');
|
|
36137
|
-
this.permanentSelection = new SelectionModel(true, []);
|
|
36138
|
-
// Listen sort change
|
|
36139
|
-
this.registerSubscription(this.onSort.subscribe(() => (this.permanentSelectionChangedPrevented = true)) // prevent selection change on sort
|
|
36140
|
-
);
|
|
36141
|
-
// Listen datasource update
|
|
36142
|
-
this.registerSubscription(this.dataSource.rowsSubject
|
|
36143
|
-
// restore the 'adding' selection (for example after a page or sort change)
|
|
36144
|
-
.subscribe((rows) => {
|
|
36145
|
-
this.permanentSelectionChangedPrevented = true;
|
|
36146
|
-
try {
|
|
36147
|
-
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
36148
|
-
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
36149
|
-
this.markForCheck();
|
|
36150
|
-
}
|
|
36151
|
-
finally {
|
|
36152
|
-
this.permanentSelectionChangedPrevented = false;
|
|
36153
|
-
}
|
|
36154
|
-
}));
|
|
36155
|
-
// Listen selection change
|
|
36156
|
-
this.registerSubscription(this.selection.changed.pipe(filter(() => !this.permanentSelectionChangedPrevented)).subscribe((selectionChange) => {
|
|
36157
|
-
// add to selection
|
|
36158
|
-
if (selectionChange.added.length) {
|
|
36159
|
-
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
36160
|
-
// Add new elements
|
|
36161
|
-
.concat(...AppTableUtils.getEntities(selectionChange.added))
|
|
36162
|
-
// Avoid duplicated entities (Mantis #55351)
|
|
36163
|
-
.filter(EntityUtils.arrayDistinctFilterFn));
|
|
36164
|
-
}
|
|
36165
|
-
// remove from selection
|
|
36166
|
-
if (selectionChange.removed.length) {
|
|
36167
|
-
const removedIds = AppTableUtils.getEntityIds(selectionChange.removed);
|
|
36168
|
-
this.permanentSelection.setSelection(...(this.permanentSelection.selected || []).filter((entity) => !removedIds.includes(entity.id)));
|
|
36169
|
-
}
|
|
36170
|
-
this.markForCheck();
|
|
36171
|
-
}));
|
|
36172
|
-
}
|
|
36173
36177
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AppAsyncTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
36174
36178
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: AppAsyncTable, inputs: { settingsId: "settingsId", debug: "debug", i18nColumnPrefix: "i18nColumnPrefix", i18nColumnSuffix: "i18nColumnSuffix", autoLoad: "autoLoad", readOnly: "readOnly", inlineEdition: "inlineEdition", focusFirstColumn: "focusFirstColumn", confirmBeforeDelete: "confirmBeforeDelete", confirmBeforeCancel: "confirmBeforeCancel", undoableDeletion: "undoableDeletion", saveBeforeDelete: "saveBeforeDelete", keepEditedRowOnSave: "keepEditedRowOnSave", saveBeforeSort: "saveBeforeSort", saveBeforeFilter: "saveBeforeFilter", propagateRowError: "propagateRowError", permanentSelectionAllowed: "permanentSelectionAllowed", defaultSortBy: "defaultSortBy", defaultSortDirection: "defaultSortDirection", defaultPageSize: "defaultPageSize", defaultPageSizeOptions: "defaultPageSizeOptions", focusColumn: "focusColumn", dataSource: "dataSource", filter: "filter", disabled: "disabled", paginator: "paginator" }, outputs: { onRefresh: "onRefresh", onOpenRow: "onOpenRow", onNewRow: "onNewRow", onStartEditingRow: "onStartEditingRow", onConfirmEditCreateRow: "onConfirmEditCreateRow", onCancelOrDeleteRow: "onCancelOrDeleteRow", onBeforeDeleteRows: "onBeforeDeleteRows", onBeforeCancelRows: "onBeforeCancelRows", onBeforeSave: "onBeforeSave", onAfterDeletedRows: "onAfterDeletedRows", onSort: "onSort", onDirty: "onDirty", onError: "onError" }, viewQueries: [{ propertyName: "table", first: true, predicate: MatTable, descendants: true }, { propertyName: "childPaginator", first: true, predicate: MatPaginator, descendants: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true }], ngImport: i0 });
|
|
36175
36179
|
}
|