@sumaris-net/ngx-components 2.6.1 → 2.6.2-rc2
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/table/async-table.class.mjs +63 -2
- package/esm2020/src/app/core/table/table.class.mjs +15 -7
- package/fesm2015/sumaris-net.ngx-components.mjs +76 -7
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +75 -7
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/core/table/async-table.class.d.ts +11 -1
- package/src/app/core/table/table.class.d.ts +5 -2
- package/src/assets/manifest.json +1 -1
|
@@ -26126,6 +26126,7 @@ class AppTable {
|
|
|
26126
26126
|
this.errorSubject = new BehaviorSubject(undefined);
|
|
26127
26127
|
this.selection = new SelectionModel(true, []);
|
|
26128
26128
|
this.permanentSelection = null;
|
|
26129
|
+
this.permanentSelectionChangedPrevented = false;
|
|
26129
26130
|
this.editedRow = undefined;
|
|
26130
26131
|
this.i18nColumnPrefix = 'COMMON.';
|
|
26131
26132
|
this.autoLoad = true;
|
|
@@ -26134,6 +26135,7 @@ class AppTable {
|
|
|
26134
26135
|
this.confirmBeforeCancel = false;
|
|
26135
26136
|
this.undoableDeletion = false;
|
|
26136
26137
|
this.propagateRowError = false;
|
|
26138
|
+
this.permanentSelectionAllowed = false; // Allow keep selected rows over page change or sort change
|
|
26137
26139
|
this.defaultPageSize = DEFAULT_PAGE_SIZE;
|
|
26138
26140
|
this.defaultPageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS;
|
|
26139
26141
|
this.onRefresh = new EventEmitter();
|
|
@@ -26456,6 +26458,9 @@ class AppTable {
|
|
|
26456
26458
|
// Listen dataSource loading events
|
|
26457
26459
|
if (this._dataSource)
|
|
26458
26460
|
this.listenDatasourceLoading(this._dataSource);
|
|
26461
|
+
// Permanent selection behavior
|
|
26462
|
+
if (this.permanentSelectionAllowed)
|
|
26463
|
+
this.initPermanentSelection();
|
|
26459
26464
|
}
|
|
26460
26465
|
ngAfterViewInit() {
|
|
26461
26466
|
// Detect when parent ngOnInit() not call
|
|
@@ -26539,6 +26544,8 @@ class AppTable {
|
|
|
26539
26544
|
}
|
|
26540
26545
|
setFilter(filter, opts) {
|
|
26541
26546
|
opts = opts || { emitEvent: true };
|
|
26547
|
+
// Prevent permanent selection change events
|
|
26548
|
+
this.permanentSelectionChangedPrevented = toBoolean(opts.permanentSelectionChangedPrevented, this.permanentSelectionChangedPrevented);
|
|
26542
26549
|
if (this.saveBeforeFilter) {
|
|
26543
26550
|
// if a dirty table is to be saved before filter
|
|
26544
26551
|
if (this.dirty) {
|
|
@@ -27732,27 +27739,26 @@ class AppTable {
|
|
|
27732
27739
|
if (this.permanentSelection)
|
|
27733
27740
|
throw new Error('initPermanentSelection() already called!');
|
|
27734
27741
|
this.permanentSelection = new SelectionModel(true, []);
|
|
27735
|
-
let selectionChangedPrevented = false;
|
|
27736
27742
|
// Listen sort change
|
|
27737
|
-
this.registerSubscription(this.onSort.subscribe(() => (
|
|
27743
|
+
this.registerSubscription(this.onSort.subscribe(() => (this.permanentSelectionChangedPrevented = true)) // prevent selection change on sort
|
|
27738
27744
|
);
|
|
27739
27745
|
// Listen datasource update
|
|
27740
27746
|
this.registerSubscription(this.dataSource.rowsSubject
|
|
27741
27747
|
// restore the 'adding' selection (for example after a page or sort change)
|
|
27742
27748
|
.subscribe((rows) => {
|
|
27743
|
-
|
|
27749
|
+
this.permanentSelectionChangedPrevented = true;
|
|
27744
27750
|
try {
|
|
27745
27751
|
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
27746
27752
|
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
27747
27753
|
this.markForCheck();
|
|
27748
27754
|
}
|
|
27749
27755
|
finally {
|
|
27750
|
-
|
|
27756
|
+
this.permanentSelectionChangedPrevented = false;
|
|
27751
27757
|
}
|
|
27752
27758
|
}));
|
|
27753
27759
|
// Listen selection change
|
|
27754
27760
|
this.registerSubscription(this.selection.changed
|
|
27755
|
-
.pipe(filter(() => !
|
|
27761
|
+
.pipe(filter(() => !this.permanentSelectionChangedPrevented))
|
|
27756
27762
|
.subscribe((selectionChange) => {
|
|
27757
27763
|
// add to selection
|
|
27758
27764
|
if (selectionChange.added.length) {
|
|
@@ -27773,7 +27779,7 @@ class AppTable {
|
|
|
27773
27779
|
}
|
|
27774
27780
|
}
|
|
27775
27781
|
AppTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
27776
|
-
AppTable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", 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 });
|
|
27782
|
+
AppTable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", 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", 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 });
|
|
27777
27783
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppTable, decorators: [{
|
|
27778
27784
|
type: Directive
|
|
27779
27785
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined }, { type: EntitiesTableDataSource }, { type: undefined }]; }, propDecorators: { settingsId: [{
|
|
@@ -27808,6 +27814,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
27808
27814
|
type: Input
|
|
27809
27815
|
}], propagateRowError: [{
|
|
27810
27816
|
type: Input
|
|
27817
|
+
}], permanentSelectionAllowed: [{
|
|
27818
|
+
type: Input
|
|
27811
27819
|
}], defaultSortBy: [{
|
|
27812
27820
|
type: Input
|
|
27813
27821
|
}], defaultSortDirection: [{
|
|
@@ -32215,6 +32223,8 @@ class AppAsyncTable {
|
|
|
32215
32223
|
this.dirtySubject = new BehaviorSubject(false);
|
|
32216
32224
|
this.errorSubject = new BehaviorSubject(undefined);
|
|
32217
32225
|
this.selection = new SelectionModel(true, []);
|
|
32226
|
+
this.permanentSelection = null;
|
|
32227
|
+
this.permanentSelectionChangedPrevented = false;
|
|
32218
32228
|
this.i18nColumnPrefix = 'COMMON.';
|
|
32219
32229
|
this.autoLoad = true;
|
|
32220
32230
|
this.focusFirstColumn = false;
|
|
@@ -32222,6 +32232,7 @@ class AppAsyncTable {
|
|
|
32222
32232
|
this.confirmBeforeCancel = false;
|
|
32223
32233
|
this.undoableDeletion = false;
|
|
32224
32234
|
this.propagateRowError = false;
|
|
32235
|
+
this.permanentSelectionAllowed = false; // Allow keep selected rows over page change or sort change
|
|
32225
32236
|
this.defaultPageSize = DEFAULT_PAGE_SIZE;
|
|
32226
32237
|
this.defaultPageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS;
|
|
32227
32238
|
this.onRefresh = new EventEmitter();
|
|
@@ -32281,6 +32292,11 @@ class AppAsyncTable {
|
|
|
32281
32292
|
get empty() {
|
|
32282
32293
|
return this.loading || this.totalRowCount === 0;
|
|
32283
32294
|
}
|
|
32295
|
+
get selectedEntities() {
|
|
32296
|
+
var _a;
|
|
32297
|
+
return ((_a = this.permanentSelection) === null || _a === void 0 ? void 0 : _a.selected)
|
|
32298
|
+
|| AppTableUtils.getEntities(this.selection.selected);
|
|
32299
|
+
}
|
|
32284
32300
|
get dirty() {
|
|
32285
32301
|
return this.dirtySubject.value;
|
|
32286
32302
|
}
|
|
@@ -32529,6 +32545,9 @@ class AppAsyncTable {
|
|
|
32529
32545
|
// Listen dataSource loading events
|
|
32530
32546
|
if (this._dataSource)
|
|
32531
32547
|
this.listenDatasourceLoading(this._dataSource);
|
|
32548
|
+
// Permanent selection behavior
|
|
32549
|
+
if (this.permanentSelectionAllowed)
|
|
32550
|
+
this.initPermanentSelection();
|
|
32532
32551
|
}
|
|
32533
32552
|
ngAfterViewInit() {
|
|
32534
32553
|
// Detect when parent ngOnInit() not call
|
|
@@ -32612,6 +32631,8 @@ class AppAsyncTable {
|
|
|
32612
32631
|
}
|
|
32613
32632
|
setFilter(filter, opts) {
|
|
32614
32633
|
opts = opts || { emitEvent: true };
|
|
32634
|
+
// Prevent permanent selection change events
|
|
32635
|
+
this.permanentSelectionChangedPrevented = toBoolean(opts.permanentSelectionChangedPrevented, this.permanentSelectionChangedPrevented);
|
|
32615
32636
|
if (this.saveBeforeFilter) {
|
|
32616
32637
|
// if a dirty table is to be saved before filter
|
|
32617
32638
|
if (this.dirty) {
|
|
@@ -33795,9 +33816,55 @@ class AppAsyncTable {
|
|
|
33795
33816
|
def.subject.unsubscribe();
|
|
33796
33817
|
}
|
|
33797
33818
|
}
|
|
33819
|
+
/**
|
|
33820
|
+
* Initialize the permanent selection model
|
|
33821
|
+
* @protected
|
|
33822
|
+
*/
|
|
33823
|
+
initPermanentSelection() {
|
|
33824
|
+
if (this.permanentSelection)
|
|
33825
|
+
throw new Error('initPermanentSelection() already called!');
|
|
33826
|
+
this.permanentSelection = new SelectionModel(true, []);
|
|
33827
|
+
// Listen sort change
|
|
33828
|
+
this.registerSubscription(this.onSort.subscribe(() => (this.permanentSelectionChangedPrevented = true)) // prevent selection change on sort
|
|
33829
|
+
);
|
|
33830
|
+
// Listen datasource update
|
|
33831
|
+
this.registerSubscription(this.dataSource.rowsSubject
|
|
33832
|
+
// restore the 'adding' selection (for example after a page or sort change)
|
|
33833
|
+
.subscribe((rows) => {
|
|
33834
|
+
this.permanentSelectionChangedPrevented = true;
|
|
33835
|
+
try {
|
|
33836
|
+
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
33837
|
+
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
33838
|
+
this.markForCheck();
|
|
33839
|
+
}
|
|
33840
|
+
finally {
|
|
33841
|
+
this.permanentSelectionChangedPrevented = false;
|
|
33842
|
+
}
|
|
33843
|
+
}));
|
|
33844
|
+
// Listen selection change
|
|
33845
|
+
this.registerSubscription(this.selection.changed
|
|
33846
|
+
.pipe(filter(() => !this.permanentSelectionChangedPrevented))
|
|
33847
|
+
.subscribe((selectionChange) => {
|
|
33848
|
+
// add to selection
|
|
33849
|
+
if (selectionChange.added.length) {
|
|
33850
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
33851
|
+
// Add new elements
|
|
33852
|
+
.concat(...AppTableUtils.getEntities(selectionChange.added))
|
|
33853
|
+
// Avoid duplicated entities (Mantis #55351)
|
|
33854
|
+
.filter(EntityUtils.arrayDistinctFilterFn));
|
|
33855
|
+
}
|
|
33856
|
+
// remove from selection
|
|
33857
|
+
if (selectionChange.removed.length) {
|
|
33858
|
+
const removedIds = AppTableUtils.getEntityIds(selectionChange.removed);
|
|
33859
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
33860
|
+
.filter((entity) => !removedIds.includes(entity.id)));
|
|
33861
|
+
}
|
|
33862
|
+
this.markForCheck();
|
|
33863
|
+
}));
|
|
33864
|
+
}
|
|
33798
33865
|
}
|
|
33799
33866
|
AppAsyncTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppAsyncTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
33800
|
-
AppAsyncTable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", 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", 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 });
|
|
33867
|
+
AppAsyncTable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", 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 });
|
|
33801
33868
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppAsyncTable, decorators: [{
|
|
33802
33869
|
type: Directive
|
|
33803
33870
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined }, { type: EntitiesAsyncTableDataSource }, { type: undefined }]; }, propDecorators: { settingsId: [{
|
|
@@ -33832,6 +33899,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
33832
33899
|
type: Input
|
|
33833
33900
|
}], propagateRowError: [{
|
|
33834
33901
|
type: Input
|
|
33902
|
+
}], permanentSelectionAllowed: [{
|
|
33903
|
+
type: Input
|
|
33835
33904
|
}], defaultSortBy: [{
|
|
33836
33905
|
type: Input
|
|
33837
33906
|
}], defaultSortDirection: [{
|