@sumaris-net/ngx-components 2.4.56 → 2.4.57
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 +10 -1
- package/esm2020/src/app/core/table/table.class.mjs +58 -22
- package/esm2020/src/app/core/table/table.utils.mjs +18 -1
- package/fesm2015/sumaris-net.ngx-components.mjs +81 -21
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +80 -21
- 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 +3 -0
- package/src/app/core/table/table.class.d.ts +8 -10
- package/src/app/core/table/table.utils.d.ts +4 -0
|
@@ -11463,6 +11463,15 @@ class EntityUtils {
|
|
|
11463
11463
|
static isRemoteId(id) {
|
|
11464
11464
|
return isNotNil(id) && +id >= 0;
|
|
11465
11465
|
}
|
|
11466
|
+
static getId(entity) {
|
|
11467
|
+
return entity.id;
|
|
11468
|
+
}
|
|
11469
|
+
static collectById(entities) {
|
|
11470
|
+
return (entities || []).map(e => e.id);
|
|
11471
|
+
}
|
|
11472
|
+
static arrayDistinctFilterFn(item, index, values) {
|
|
11473
|
+
return values.findIndex(e => e.id === item.id) === index;
|
|
11474
|
+
}
|
|
11466
11475
|
}
|
|
11467
11476
|
EntityUtils.getPropertyByPath = getPropertyByPath;
|
|
11468
11477
|
|
|
@@ -25534,6 +25543,21 @@ class AppTableUtils {
|
|
|
25534
25543
|
static logRowErrors(row, logPrefix) {
|
|
25535
25544
|
AppFormUtils.logFormErrors(row.validator, logPrefix);
|
|
25536
25545
|
}
|
|
25546
|
+
static getEntityId(row) {
|
|
25547
|
+
return EntityUtils.getId(row.currentData);
|
|
25548
|
+
}
|
|
25549
|
+
static getEntityIds(rows) {
|
|
25550
|
+
return (rows || [])
|
|
25551
|
+
.map((row) => row.currentData)
|
|
25552
|
+
.filter(isNotNil)
|
|
25553
|
+
.map(EntityUtils.getId)
|
|
25554
|
+
.filter(isNotNilOrNaN);
|
|
25555
|
+
}
|
|
25556
|
+
static getEntities(rows) {
|
|
25557
|
+
return (rows || [])
|
|
25558
|
+
.map((row) => row.currentData)
|
|
25559
|
+
.filter(isNotNil);
|
|
25560
|
+
}
|
|
25537
25561
|
}
|
|
25538
25562
|
|
|
25539
25563
|
// @dynamic
|
|
@@ -25947,13 +25971,13 @@ class AppTable {
|
|
|
25947
25971
|
this.dirtySubject = new BehaviorSubject(false);
|
|
25948
25972
|
this.errorSubject = new BehaviorSubject(undefined);
|
|
25949
25973
|
this.selection = new SelectionModel(true, []);
|
|
25974
|
+
this.permanentSelection = null;
|
|
25950
25975
|
this.editedRow = undefined;
|
|
25951
25976
|
this.i18nColumnPrefix = 'COMMON.';
|
|
25952
25977
|
this.autoLoad = true;
|
|
25953
25978
|
this.focusFirstColumn = false;
|
|
25954
25979
|
this.confirmBeforeDelete = false;
|
|
25955
25980
|
this.confirmBeforeCancel = false;
|
|
25956
|
-
this.clearSelectionBeforeOpen = true;
|
|
25957
25981
|
this.undoableDeletion = false;
|
|
25958
25982
|
this.propagateRowError = false;
|
|
25959
25983
|
this.defaultPageSize = DEFAULT_PAGE_SIZE;
|
|
@@ -26001,18 +26025,6 @@ class AppTable {
|
|
|
26001
26025
|
set error(error) {
|
|
26002
26026
|
this.setError(error);
|
|
26003
26027
|
}
|
|
26004
|
-
/**
|
|
26005
|
-
* @deprecated
|
|
26006
|
-
*/
|
|
26007
|
-
get loading$() {
|
|
26008
|
-
return this.loadingSubject.asObservable();
|
|
26009
|
-
}
|
|
26010
|
-
/**
|
|
26011
|
-
* @deprecated
|
|
26012
|
-
*/
|
|
26013
|
-
get saving$() {
|
|
26014
|
-
return this.savingSubject.asObservable();
|
|
26015
|
-
}
|
|
26016
26028
|
get firstUserColumn() {
|
|
26017
26029
|
return this.displayedColumns[RESERVED_START_COLUMNS.length];
|
|
26018
26030
|
}
|
|
@@ -26034,6 +26046,10 @@ class AppTable {
|
|
|
26034
26046
|
get empty() {
|
|
26035
26047
|
return this.loading || this.totalRowCount === 0;
|
|
26036
26048
|
}
|
|
26049
|
+
get selectedEntities() {
|
|
26050
|
+
return this.permanentSelection?.selected
|
|
26051
|
+
|| AppTableUtils.getEntities(this.selection.selected);
|
|
26052
|
+
}
|
|
26037
26053
|
get dirty() {
|
|
26038
26054
|
return this.dirtySubject.value;
|
|
26039
26055
|
}
|
|
@@ -26586,8 +26602,7 @@ class AppTable {
|
|
|
26586
26602
|
isAllSelected() {
|
|
26587
26603
|
// DEBUG
|
|
26588
26604
|
//console.debug('isAllSelected. lengths', this.selection.selected.length, this.totalRowCount);
|
|
26589
|
-
return this.selection.selected.length === this.
|
|
26590
|
-
this.selection.selected.length === this.visibleRowCount;
|
|
26605
|
+
return this.selection.selected.length === this.visibleRowCount;
|
|
26591
26606
|
}
|
|
26592
26607
|
/** Selects all rows if they are not all selected; otherwise clear selection. */
|
|
26593
26608
|
async masterToggle() {
|
|
@@ -26708,7 +26723,8 @@ class AppTable {
|
|
|
26708
26723
|
// DO not update manually, because watchALl().subscribe() will update this count
|
|
26709
26724
|
//this.totalRowCount -= deleteCount;
|
|
26710
26725
|
//this.visibleRowCount -= deleteCount;
|
|
26711
|
-
|
|
26726
|
+
// Deselect deleted rows
|
|
26727
|
+
this.selection.deselect(...rows);
|
|
26712
26728
|
this.editedRow = undefined;
|
|
26713
26729
|
this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
|
|
26714
26730
|
this.markForCheck();
|
|
@@ -26772,8 +26788,6 @@ class AppTable {
|
|
|
26772
26788
|
event.preventDefault();
|
|
26773
26789
|
}
|
|
26774
26790
|
this.markAsLoading();
|
|
26775
|
-
if (this.clearSelectionBeforeOpen)
|
|
26776
|
-
this.selection.clear();
|
|
26777
26791
|
this.openRow(row.currentData.id, row)
|
|
26778
26792
|
.then(() => this.markAsLoaded())
|
|
26779
26793
|
.catch(() => this.markAsLoaded());
|
|
@@ -27481,9 +27495,56 @@ class AppTable {
|
|
|
27481
27495
|
def.subject.unsubscribe();
|
|
27482
27496
|
}
|
|
27483
27497
|
}
|
|
27498
|
+
/**
|
|
27499
|
+
* Initialize the permanent selection model
|
|
27500
|
+
* @protected
|
|
27501
|
+
*/
|
|
27502
|
+
initPermanentSelection() {
|
|
27503
|
+
if (this.permanentSelection)
|
|
27504
|
+
throw new Error('initPermanentSelection() already called!');
|
|
27505
|
+
this.permanentSelection = new SelectionModel(true, []);
|
|
27506
|
+
let selectionChangedPrevented = false;
|
|
27507
|
+
// Listen sort change
|
|
27508
|
+
this.registerSubscription(this.onSort.subscribe(() => (selectionChangedPrevented = true)) // prevent selection change on sort
|
|
27509
|
+
);
|
|
27510
|
+
// Listen datasource update
|
|
27511
|
+
this.registerSubscription(this.dataSource.rowsSubject
|
|
27512
|
+
// restore the 'adding' selection (for example after a page or sort change)
|
|
27513
|
+
.subscribe((rows) => {
|
|
27514
|
+
selectionChangedPrevented = true;
|
|
27515
|
+
try {
|
|
27516
|
+
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
27517
|
+
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
27518
|
+
this.markForCheck();
|
|
27519
|
+
}
|
|
27520
|
+
finally {
|
|
27521
|
+
selectionChangedPrevented = false;
|
|
27522
|
+
}
|
|
27523
|
+
}));
|
|
27524
|
+
// Listen selection change
|
|
27525
|
+
this.registerSubscription(this.selection.changed
|
|
27526
|
+
.pipe(filter(() => !selectionChangedPrevented))
|
|
27527
|
+
.subscribe((selectionChange) => {
|
|
27528
|
+
// add to selection
|
|
27529
|
+
if (selectionChange.added.length) {
|
|
27530
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
27531
|
+
// Add new elements
|
|
27532
|
+
.concat(...AppTableUtils.getEntities(selectionChange.added))
|
|
27533
|
+
// Avoid duplicated entities (Mantis #55351)
|
|
27534
|
+
.filter(EntityUtils.arrayDistinctFilterFn));
|
|
27535
|
+
}
|
|
27536
|
+
// remove from selection
|
|
27537
|
+
if (selectionChange.removed.length) {
|
|
27538
|
+
const removedIds = AppTableUtils.getEntityIds(selectionChange.removed);
|
|
27539
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
27540
|
+
.filter((entity) => !removedIds.includes(entity.id)));
|
|
27541
|
+
}
|
|
27542
|
+
this.markForCheck();
|
|
27543
|
+
}));
|
|
27544
|
+
}
|
|
27484
27545
|
}
|
|
27485
27546
|
AppTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AppTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
27486
|
-
AppTable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: AppTable, inputs: { settingsId: "settingsId", debug: "debug", i18nColumnPrefix: "i18nColumnPrefix", i18nColumnSuffix: "i18nColumnSuffix", autoLoad: "autoLoad", readOnly: "readOnly", inlineEdition: "inlineEdition", focusFirstColumn: "focusFirstColumn", confirmBeforeDelete: "confirmBeforeDelete", confirmBeforeCancel: "confirmBeforeCancel",
|
|
27547
|
+
AppTable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: AppTable, 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", 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 });
|
|
27487
27548
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AppTable, decorators: [{
|
|
27488
27549
|
type: Directive
|
|
27489
27550
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined }, { type: EntitiesTableDataSource }, { type: undefined }]; }, propDecorators: { settingsId: [{
|
|
@@ -27506,8 +27567,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
27506
27567
|
type: Input
|
|
27507
27568
|
}], confirmBeforeCancel: [{
|
|
27508
27569
|
type: Input
|
|
27509
|
-
}], clearSelectionBeforeOpen: [{
|
|
27510
|
-
type: Input
|
|
27511
27570
|
}], undoableDeletion: [{
|
|
27512
27571
|
type: Input
|
|
27513
27572
|
}], saveBeforeDelete: [{
|