@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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AppFormUtils } from '../form/form.utils';
|
|
2
|
+
import { EntityUtils } from '../services/model/entity.model';
|
|
3
|
+
import { isNotNil, isNotNilOrNaN } from '../../shared/functions';
|
|
2
4
|
export class AppTableUtils {
|
|
3
5
|
static waitIdle(table) {
|
|
4
6
|
if (!table || !table.dataSource) {
|
|
@@ -9,5 +11,20 @@ export class AppTableUtils {
|
|
|
9
11
|
static logRowErrors(row, logPrefix) {
|
|
10
12
|
AppFormUtils.logFormErrors(row.validator, logPrefix);
|
|
11
13
|
}
|
|
14
|
+
static getEntityId(row) {
|
|
15
|
+
return EntityUtils.getId(row.currentData);
|
|
16
|
+
}
|
|
17
|
+
static getEntityIds(rows) {
|
|
18
|
+
return (rows || [])
|
|
19
|
+
.map((row) => row.currentData)
|
|
20
|
+
.filter(isNotNil)
|
|
21
|
+
.map(EntityUtils.getId)
|
|
22
|
+
.filter(isNotNilOrNaN);
|
|
23
|
+
}
|
|
24
|
+
static getEntities(rows) {
|
|
25
|
+
return (rows || [])
|
|
26
|
+
.map((row) => row.currentData)
|
|
27
|
+
.filter(isNotNil);
|
|
28
|
+
}
|
|
12
29
|
}
|
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biAgICAgIC5maWx0ZXIoaXNOb3ROaWwpXG4gICAgICAubWFwKEVudGl0eVV0aWxzLmdldElkKVxuICAgICAgLmZpbHRlcihpc05vdE5pbE9yTmFOKTtcbiAgfVxuXG4gIHN0YXRpYyBnZXRFbnRpdGllczxUIGV4dGVuZHMgSUVudGl0eTxULCBJRD4gPSBJRW50aXR5PGFueSwgYW55PiwgSUQgPSBhbnk+KHJvd3M6IFRhYmxlRWxlbWVudDxUPltdIHwgQXN5bmNUYWJsZUVsZW1lbnQ8VD5bXSk6IFRbXSB7XG4gICAgcmV0dXJuIChyb3dzIHx8IFtdKVxuICAgICAgLm1hcCgocm93KSA9PiByb3cuY3VycmVudERhdGEpXG4gICAgICAuZmlsdGVyKGlzTm90TmlsKTtcbiAgfVxufVxuIl19
|
|
@@ -11515,6 +11515,15 @@ class EntityUtils {
|
|
|
11515
11515
|
static isRemoteId(id) {
|
|
11516
11516
|
return isNotNil(id) && +id >= 0;
|
|
11517
11517
|
}
|
|
11518
|
+
static getId(entity) {
|
|
11519
|
+
return entity.id;
|
|
11520
|
+
}
|
|
11521
|
+
static collectById(entities) {
|
|
11522
|
+
return (entities || []).map(e => e.id);
|
|
11523
|
+
}
|
|
11524
|
+
static arrayDistinctFilterFn(item, index, values) {
|
|
11525
|
+
return values.findIndex(e => e.id === item.id) === index;
|
|
11526
|
+
}
|
|
11518
11527
|
}
|
|
11519
11528
|
EntityUtils.getPropertyByPath = getPropertyByPath;
|
|
11520
11529
|
|
|
@@ -25995,6 +26004,21 @@ class AppTableUtils {
|
|
|
25995
26004
|
static logRowErrors(row, logPrefix) {
|
|
25996
26005
|
AppFormUtils.logFormErrors(row.validator, logPrefix);
|
|
25997
26006
|
}
|
|
26007
|
+
static getEntityId(row) {
|
|
26008
|
+
return EntityUtils.getId(row.currentData);
|
|
26009
|
+
}
|
|
26010
|
+
static getEntityIds(rows) {
|
|
26011
|
+
return (rows || [])
|
|
26012
|
+
.map((row) => row.currentData)
|
|
26013
|
+
.filter(isNotNil)
|
|
26014
|
+
.map(EntityUtils.getId)
|
|
26015
|
+
.filter(isNotNilOrNaN);
|
|
26016
|
+
}
|
|
26017
|
+
static getEntities(rows) {
|
|
26018
|
+
return (rows || [])
|
|
26019
|
+
.map((row) => row.currentData)
|
|
26020
|
+
.filter(isNotNil);
|
|
26021
|
+
}
|
|
25998
26022
|
}
|
|
25999
26023
|
|
|
26000
26024
|
// @dynamic
|
|
@@ -26421,13 +26445,13 @@ class AppTable {
|
|
|
26421
26445
|
this.dirtySubject = new BehaviorSubject(false);
|
|
26422
26446
|
this.errorSubject = new BehaviorSubject(undefined);
|
|
26423
26447
|
this.selection = new SelectionModel(true, []);
|
|
26448
|
+
this.permanentSelection = null;
|
|
26424
26449
|
this.editedRow = undefined;
|
|
26425
26450
|
this.i18nColumnPrefix = 'COMMON.';
|
|
26426
26451
|
this.autoLoad = true;
|
|
26427
26452
|
this.focusFirstColumn = false;
|
|
26428
26453
|
this.confirmBeforeDelete = false;
|
|
26429
26454
|
this.confirmBeforeCancel = false;
|
|
26430
|
-
this.clearSelectionBeforeOpen = true;
|
|
26431
26455
|
this.undoableDeletion = false;
|
|
26432
26456
|
this.propagateRowError = false;
|
|
26433
26457
|
this.defaultPageSize = DEFAULT_PAGE_SIZE;
|
|
@@ -26475,18 +26499,6 @@ class AppTable {
|
|
|
26475
26499
|
set error(error) {
|
|
26476
26500
|
this.setError(error);
|
|
26477
26501
|
}
|
|
26478
|
-
/**
|
|
26479
|
-
* @deprecated
|
|
26480
|
-
*/
|
|
26481
|
-
get loading$() {
|
|
26482
|
-
return this.loadingSubject.asObservable();
|
|
26483
|
-
}
|
|
26484
|
-
/**
|
|
26485
|
-
* @deprecated
|
|
26486
|
-
*/
|
|
26487
|
-
get saving$() {
|
|
26488
|
-
return this.savingSubject.asObservable();
|
|
26489
|
-
}
|
|
26490
26502
|
get firstUserColumn() {
|
|
26491
26503
|
return this.displayedColumns[RESERVED_START_COLUMNS.length];
|
|
26492
26504
|
}
|
|
@@ -26508,6 +26520,11 @@ class AppTable {
|
|
|
26508
26520
|
get empty() {
|
|
26509
26521
|
return this.loading || this.totalRowCount === 0;
|
|
26510
26522
|
}
|
|
26523
|
+
get selectedEntities() {
|
|
26524
|
+
var _a;
|
|
26525
|
+
return ((_a = this.permanentSelection) === null || _a === void 0 ? void 0 : _a.selected)
|
|
26526
|
+
|| AppTableUtils.getEntities(this.selection.selected);
|
|
26527
|
+
}
|
|
26511
26528
|
get dirty() {
|
|
26512
26529
|
return this.dirtySubject.value;
|
|
26513
26530
|
}
|
|
@@ -27077,8 +27094,7 @@ class AppTable {
|
|
|
27077
27094
|
isAllSelected() {
|
|
27078
27095
|
// DEBUG
|
|
27079
27096
|
//console.debug('isAllSelected. lengths', this.selection.selected.length, this.totalRowCount);
|
|
27080
|
-
return this.selection.selected.length === this.
|
|
27081
|
-
this.selection.selected.length === this.visibleRowCount;
|
|
27097
|
+
return this.selection.selected.length === this.visibleRowCount;
|
|
27082
27098
|
}
|
|
27083
27099
|
/** Selects all rows if they are not all selected; otherwise clear selection. */
|
|
27084
27100
|
masterToggle() {
|
|
@@ -27207,7 +27223,8 @@ class AppTable {
|
|
|
27207
27223
|
// DO not update manually, because watchALl().subscribe() will update this count
|
|
27208
27224
|
//this.totalRowCount -= deleteCount;
|
|
27209
27225
|
//this.visibleRowCount -= deleteCount;
|
|
27210
|
-
|
|
27226
|
+
// Deselect deleted rows
|
|
27227
|
+
this.selection.deselect(...rows);
|
|
27211
27228
|
this.editedRow = undefined;
|
|
27212
27229
|
this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
|
|
27213
27230
|
this.markForCheck();
|
|
@@ -27276,8 +27293,6 @@ class AppTable {
|
|
|
27276
27293
|
event.preventDefault();
|
|
27277
27294
|
}
|
|
27278
27295
|
this.markAsLoading();
|
|
27279
|
-
if (this.clearSelectionBeforeOpen)
|
|
27280
|
-
this.selection.clear();
|
|
27281
27296
|
this.openRow(row.currentData.id, row)
|
|
27282
27297
|
.then(() => this.markAsLoaded())
|
|
27283
27298
|
.catch(() => this.markAsLoaded());
|
|
@@ -28019,9 +28034,56 @@ class AppTable {
|
|
|
28019
28034
|
def.subject.unsubscribe();
|
|
28020
28035
|
}
|
|
28021
28036
|
}
|
|
28037
|
+
/**
|
|
28038
|
+
* Initialize the permanent selection model
|
|
28039
|
+
* @protected
|
|
28040
|
+
*/
|
|
28041
|
+
initPermanentSelection() {
|
|
28042
|
+
if (this.permanentSelection)
|
|
28043
|
+
throw new Error('initPermanentSelection() already called!');
|
|
28044
|
+
this.permanentSelection = new SelectionModel(true, []);
|
|
28045
|
+
let selectionChangedPrevented = false;
|
|
28046
|
+
// Listen sort change
|
|
28047
|
+
this.registerSubscription(this.onSort.subscribe(() => (selectionChangedPrevented = true)) // prevent selection change on sort
|
|
28048
|
+
);
|
|
28049
|
+
// Listen datasource update
|
|
28050
|
+
this.registerSubscription(this.dataSource.rowsSubject
|
|
28051
|
+
// restore the 'adding' selection (for example after a page or sort change)
|
|
28052
|
+
.subscribe((rows) => {
|
|
28053
|
+
selectionChangedPrevented = true;
|
|
28054
|
+
try {
|
|
28055
|
+
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
28056
|
+
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
28057
|
+
this.markForCheck();
|
|
28058
|
+
}
|
|
28059
|
+
finally {
|
|
28060
|
+
selectionChangedPrevented = false;
|
|
28061
|
+
}
|
|
28062
|
+
}));
|
|
28063
|
+
// Listen selection change
|
|
28064
|
+
this.registerSubscription(this.selection.changed
|
|
28065
|
+
.pipe(filter(() => !selectionChangedPrevented))
|
|
28066
|
+
.subscribe((selectionChange) => {
|
|
28067
|
+
// add to selection
|
|
28068
|
+
if (selectionChange.added.length) {
|
|
28069
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
28070
|
+
// Add new elements
|
|
28071
|
+
.concat(...AppTableUtils.getEntities(selectionChange.added))
|
|
28072
|
+
// Avoid duplicated entities (Mantis #55351)
|
|
28073
|
+
.filter(EntityUtils.arrayDistinctFilterFn));
|
|
28074
|
+
}
|
|
28075
|
+
// remove from selection
|
|
28076
|
+
if (selectionChange.removed.length) {
|
|
28077
|
+
const removedIds = AppTableUtils.getEntityIds(selectionChange.removed);
|
|
28078
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
28079
|
+
.filter((entity) => !removedIds.includes(entity.id)));
|
|
28080
|
+
}
|
|
28081
|
+
this.markForCheck();
|
|
28082
|
+
}));
|
|
28083
|
+
}
|
|
28022
28084
|
}
|
|
28023
28085
|
AppTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AppTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
28024
|
-
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",
|
|
28086
|
+
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 });
|
|
28025
28087
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AppTable, decorators: [{
|
|
28026
28088
|
type: Directive
|
|
28027
28089
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined }, { type: EntitiesTableDataSource }, { type: undefined }]; }, propDecorators: { settingsId: [{
|
|
@@ -28044,8 +28106,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
28044
28106
|
type: Input
|
|
28045
28107
|
}], confirmBeforeCancel: [{
|
|
28046
28108
|
type: Input
|
|
28047
|
-
}], clearSelectionBeforeOpen: [{
|
|
28048
|
-
type: Input
|
|
28049
28109
|
}], undoableDeletion: [{
|
|
28050
28110
|
type: Input
|
|
28051
28111
|
}], saveBeforeDelete: [{
|