@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
|
@@ -25644,6 +25644,7 @@ class AppTable {
|
|
|
25644
25644
|
this.errorSubject = new BehaviorSubject(undefined);
|
|
25645
25645
|
this.selection = new SelectionModel(true, []);
|
|
25646
25646
|
this.permanentSelection = null;
|
|
25647
|
+
this.permanentSelectionChangedPrevented = false;
|
|
25647
25648
|
this.editedRow = undefined;
|
|
25648
25649
|
this.i18nColumnPrefix = 'COMMON.';
|
|
25649
25650
|
this.autoLoad = true;
|
|
@@ -25652,6 +25653,7 @@ class AppTable {
|
|
|
25652
25653
|
this.confirmBeforeCancel = false;
|
|
25653
25654
|
this.undoableDeletion = false;
|
|
25654
25655
|
this.propagateRowError = false;
|
|
25656
|
+
this.permanentSelectionAllowed = false; // Allow keep selected rows over page change or sort change
|
|
25655
25657
|
this.defaultPageSize = DEFAULT_PAGE_SIZE;
|
|
25656
25658
|
this.defaultPageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS;
|
|
25657
25659
|
this.onRefresh = new EventEmitter();
|
|
@@ -25965,6 +25967,9 @@ class AppTable {
|
|
|
25965
25967
|
// Listen dataSource loading events
|
|
25966
25968
|
if (this._dataSource)
|
|
25967
25969
|
this.listenDatasourceLoading(this._dataSource);
|
|
25970
|
+
// Permanent selection behavior
|
|
25971
|
+
if (this.permanentSelectionAllowed)
|
|
25972
|
+
this.initPermanentSelection();
|
|
25968
25973
|
}
|
|
25969
25974
|
ngAfterViewInit() {
|
|
25970
25975
|
// Detect when parent ngOnInit() not call
|
|
@@ -26046,6 +26051,8 @@ class AppTable {
|
|
|
26046
26051
|
}
|
|
26047
26052
|
setFilter(filter, opts) {
|
|
26048
26053
|
opts = opts || { emitEvent: true };
|
|
26054
|
+
// Prevent permanent selection change events
|
|
26055
|
+
this.permanentSelectionChangedPrevented = toBoolean(opts.permanentSelectionChangedPrevented, this.permanentSelectionChangedPrevented);
|
|
26049
26056
|
if (this.saveBeforeFilter) {
|
|
26050
26057
|
// if a dirty table is to be saved before filter
|
|
26051
26058
|
if (this.dirty) {
|
|
@@ -27183,27 +27190,26 @@ class AppTable {
|
|
|
27183
27190
|
if (this.permanentSelection)
|
|
27184
27191
|
throw new Error('initPermanentSelection() already called!');
|
|
27185
27192
|
this.permanentSelection = new SelectionModel(true, []);
|
|
27186
|
-
let selectionChangedPrevented = false;
|
|
27187
27193
|
// Listen sort change
|
|
27188
|
-
this.registerSubscription(this.onSort.subscribe(() => (
|
|
27194
|
+
this.registerSubscription(this.onSort.subscribe(() => (this.permanentSelectionChangedPrevented = true)) // prevent selection change on sort
|
|
27189
27195
|
);
|
|
27190
27196
|
// Listen datasource update
|
|
27191
27197
|
this.registerSubscription(this.dataSource.rowsSubject
|
|
27192
27198
|
// restore the 'adding' selection (for example after a page or sort change)
|
|
27193
27199
|
.subscribe((rows) => {
|
|
27194
|
-
|
|
27200
|
+
this.permanentSelectionChangedPrevented = true;
|
|
27195
27201
|
try {
|
|
27196
27202
|
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
27197
27203
|
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
27198
27204
|
this.markForCheck();
|
|
27199
27205
|
}
|
|
27200
27206
|
finally {
|
|
27201
|
-
|
|
27207
|
+
this.permanentSelectionChangedPrevented = false;
|
|
27202
27208
|
}
|
|
27203
27209
|
}));
|
|
27204
27210
|
// Listen selection change
|
|
27205
27211
|
this.registerSubscription(this.selection.changed
|
|
27206
|
-
.pipe(filter(() => !
|
|
27212
|
+
.pipe(filter(() => !this.permanentSelectionChangedPrevented))
|
|
27207
27213
|
.subscribe((selectionChange) => {
|
|
27208
27214
|
// add to selection
|
|
27209
27215
|
if (selectionChange.added.length) {
|
|
@@ -27224,7 +27230,7 @@ class AppTable {
|
|
|
27224
27230
|
}
|
|
27225
27231
|
}
|
|
27226
27232
|
AppTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
27227
|
-
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 });
|
|
27233
|
+
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 });
|
|
27228
27234
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppTable, decorators: [{
|
|
27229
27235
|
type: Directive
|
|
27230
27236
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined }, { type: EntitiesTableDataSource }, { type: undefined }]; }, propDecorators: { settingsId: [{
|
|
@@ -27259,6 +27265,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
27259
27265
|
type: Input
|
|
27260
27266
|
}], propagateRowError: [{
|
|
27261
27267
|
type: Input
|
|
27268
|
+
}], permanentSelectionAllowed: [{
|
|
27269
|
+
type: Input
|
|
27262
27270
|
}], defaultSortBy: [{
|
|
27263
27271
|
type: Input
|
|
27264
27272
|
}], defaultSortDirection: [{
|
|
@@ -31495,6 +31503,8 @@ class AppAsyncTable {
|
|
|
31495
31503
|
this.dirtySubject = new BehaviorSubject(false);
|
|
31496
31504
|
this.errorSubject = new BehaviorSubject(undefined);
|
|
31497
31505
|
this.selection = new SelectionModel(true, []);
|
|
31506
|
+
this.permanentSelection = null;
|
|
31507
|
+
this.permanentSelectionChangedPrevented = false;
|
|
31498
31508
|
this.i18nColumnPrefix = 'COMMON.';
|
|
31499
31509
|
this.autoLoad = true;
|
|
31500
31510
|
this.focusFirstColumn = false;
|
|
@@ -31502,6 +31512,7 @@ class AppAsyncTable {
|
|
|
31502
31512
|
this.confirmBeforeCancel = false;
|
|
31503
31513
|
this.undoableDeletion = false;
|
|
31504
31514
|
this.propagateRowError = false;
|
|
31515
|
+
this.permanentSelectionAllowed = false; // Allow keep selected rows over page change or sort change
|
|
31505
31516
|
this.defaultPageSize = DEFAULT_PAGE_SIZE;
|
|
31506
31517
|
this.defaultPageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS;
|
|
31507
31518
|
this.onRefresh = new EventEmitter();
|
|
@@ -31561,6 +31572,10 @@ class AppAsyncTable {
|
|
|
31561
31572
|
get empty() {
|
|
31562
31573
|
return this.loading || this.totalRowCount === 0;
|
|
31563
31574
|
}
|
|
31575
|
+
get selectedEntities() {
|
|
31576
|
+
return this.permanentSelection?.selected
|
|
31577
|
+
|| AppTableUtils.getEntities(this.selection.selected);
|
|
31578
|
+
}
|
|
31564
31579
|
get dirty() {
|
|
31565
31580
|
return this.dirtySubject.value;
|
|
31566
31581
|
}
|
|
@@ -31805,6 +31820,9 @@ class AppAsyncTable {
|
|
|
31805
31820
|
// Listen dataSource loading events
|
|
31806
31821
|
if (this._dataSource)
|
|
31807
31822
|
this.listenDatasourceLoading(this._dataSource);
|
|
31823
|
+
// Permanent selection behavior
|
|
31824
|
+
if (this.permanentSelectionAllowed)
|
|
31825
|
+
this.initPermanentSelection();
|
|
31808
31826
|
}
|
|
31809
31827
|
ngAfterViewInit() {
|
|
31810
31828
|
// Detect when parent ngOnInit() not call
|
|
@@ -31886,6 +31904,8 @@ class AppAsyncTable {
|
|
|
31886
31904
|
}
|
|
31887
31905
|
setFilter(filter, opts) {
|
|
31888
31906
|
opts = opts || { emitEvent: true };
|
|
31907
|
+
// Prevent permanent selection change events
|
|
31908
|
+
this.permanentSelectionChangedPrevented = toBoolean(opts.permanentSelectionChangedPrevented, this.permanentSelectionChangedPrevented);
|
|
31889
31909
|
if (this.saveBeforeFilter) {
|
|
31890
31910
|
// if a dirty table is to be saved before filter
|
|
31891
31911
|
if (this.dirty) {
|
|
@@ -32990,9 +33010,55 @@ class AppAsyncTable {
|
|
|
32990
33010
|
def.subject.unsubscribe();
|
|
32991
33011
|
}
|
|
32992
33012
|
}
|
|
33013
|
+
/**
|
|
33014
|
+
* Initialize the permanent selection model
|
|
33015
|
+
* @protected
|
|
33016
|
+
*/
|
|
33017
|
+
initPermanentSelection() {
|
|
33018
|
+
if (this.permanentSelection)
|
|
33019
|
+
throw new Error('initPermanentSelection() already called!');
|
|
33020
|
+
this.permanentSelection = new SelectionModel(true, []);
|
|
33021
|
+
// Listen sort change
|
|
33022
|
+
this.registerSubscription(this.onSort.subscribe(() => (this.permanentSelectionChangedPrevented = true)) // prevent selection change on sort
|
|
33023
|
+
);
|
|
33024
|
+
// Listen datasource update
|
|
33025
|
+
this.registerSubscription(this.dataSource.rowsSubject
|
|
33026
|
+
// restore the 'adding' selection (for example after a page or sort change)
|
|
33027
|
+
.subscribe((rows) => {
|
|
33028
|
+
this.permanentSelectionChangedPrevented = true;
|
|
33029
|
+
try {
|
|
33030
|
+
const permanentSelectionIds = (this.permanentSelection.selected || []).map(EntityUtils.getId);
|
|
33031
|
+
this.selection.setSelection(...rows.filter((row) => permanentSelectionIds.includes(AppTableUtils.getEntityId(row))));
|
|
33032
|
+
this.markForCheck();
|
|
33033
|
+
}
|
|
33034
|
+
finally {
|
|
33035
|
+
this.permanentSelectionChangedPrevented = false;
|
|
33036
|
+
}
|
|
33037
|
+
}));
|
|
33038
|
+
// Listen selection change
|
|
33039
|
+
this.registerSubscription(this.selection.changed
|
|
33040
|
+
.pipe(filter(() => !this.permanentSelectionChangedPrevented))
|
|
33041
|
+
.subscribe((selectionChange) => {
|
|
33042
|
+
// add to selection
|
|
33043
|
+
if (selectionChange.added.length) {
|
|
33044
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
33045
|
+
// Add new elements
|
|
33046
|
+
.concat(...AppTableUtils.getEntities(selectionChange.added))
|
|
33047
|
+
// Avoid duplicated entities (Mantis #55351)
|
|
33048
|
+
.filter(EntityUtils.arrayDistinctFilterFn));
|
|
33049
|
+
}
|
|
33050
|
+
// remove from selection
|
|
33051
|
+
if (selectionChange.removed.length) {
|
|
33052
|
+
const removedIds = AppTableUtils.getEntityIds(selectionChange.removed);
|
|
33053
|
+
this.permanentSelection.setSelection(...(this.permanentSelection.selected || [])
|
|
33054
|
+
.filter((entity) => !removedIds.includes(entity.id)));
|
|
33055
|
+
}
|
|
33056
|
+
this.markForCheck();
|
|
33057
|
+
}));
|
|
33058
|
+
}
|
|
32993
33059
|
}
|
|
32994
33060
|
AppAsyncTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppAsyncTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
32995
|
-
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 });
|
|
33061
|
+
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 });
|
|
32996
33062
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppAsyncTable, decorators: [{
|
|
32997
33063
|
type: Directive
|
|
32998
33064
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined }, { type: EntitiesAsyncTableDataSource }, { type: undefined }]; }, propDecorators: { settingsId: [{
|
|
@@ -33027,6 +33093,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
33027
33093
|
type: Input
|
|
33028
33094
|
}], propagateRowError: [{
|
|
33029
33095
|
type: Input
|
|
33096
|
+
}], permanentSelectionAllowed: [{
|
|
33097
|
+
type: Input
|
|
33030
33098
|
}], defaultSortBy: [{
|
|
33031
33099
|
type: Input
|
|
33032
33100
|
}], defaultSortDirection: [{
|