@sumaris-net/ngx-components 2.6.2-rc1 → 2.6.2

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.
@@ -32223,6 +32223,8 @@ class AppAsyncTable {
32223
32223
  this.dirtySubject = new BehaviorSubject(false);
32224
32224
  this.errorSubject = new BehaviorSubject(undefined);
32225
32225
  this.selection = new SelectionModel(true, []);
32226
+ this.permanentSelection = null;
32227
+ this.permanentSelectionChangedPrevented = false;
32226
32228
  this.i18nColumnPrefix = 'COMMON.';
32227
32229
  this.autoLoad = true;
32228
32230
  this.focusFirstColumn = false;
@@ -32230,6 +32232,7 @@ class AppAsyncTable {
32230
32232
  this.confirmBeforeCancel = false;
32231
32233
  this.undoableDeletion = false;
32232
32234
  this.propagateRowError = false;
32235
+ this.permanentSelectionAllowed = false; // Allow keep selected rows over page change or sort change
32233
32236
  this.defaultPageSize = DEFAULT_PAGE_SIZE;
32234
32237
  this.defaultPageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS;
32235
32238
  this.onRefresh = new EventEmitter();
@@ -32289,6 +32292,11 @@ class AppAsyncTable {
32289
32292
  get empty() {
32290
32293
  return this.loading || this.totalRowCount === 0;
32291
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
+ }
32292
32300
  get dirty() {
32293
32301
  return this.dirtySubject.value;
32294
32302
  }
@@ -32537,6 +32545,9 @@ class AppAsyncTable {
32537
32545
  // Listen dataSource loading events
32538
32546
  if (this._dataSource)
32539
32547
  this.listenDatasourceLoading(this._dataSource);
32548
+ // Permanent selection behavior
32549
+ if (this.permanentSelectionAllowed)
32550
+ this.initPermanentSelection();
32540
32551
  }
32541
32552
  ngAfterViewInit() {
32542
32553
  // Detect when parent ngOnInit() not call
@@ -32620,6 +32631,8 @@ class AppAsyncTable {
32620
32631
  }
32621
32632
  setFilter(filter, opts) {
32622
32633
  opts = opts || { emitEvent: true };
32634
+ // Prevent permanent selection change events
32635
+ this.permanentSelectionChangedPrevented = toBoolean(opts.permanentSelectionChangedPrevented, this.permanentSelectionChangedPrevented);
32623
32636
  if (this.saveBeforeFilter) {
32624
32637
  // if a dirty table is to be saved before filter
32625
32638
  if (this.dirty) {
@@ -33803,9 +33816,55 @@ class AppAsyncTable {
33803
33816
  def.subject.unsubscribe();
33804
33817
  }
33805
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
+ }
33806
33865
  }
33807
33866
  AppAsyncTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppAsyncTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
33808
- 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 });
33809
33868
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppAsyncTable, decorators: [{
33810
33869
  type: Directive
33811
33870
  }], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined }, { type: EntitiesAsyncTableDataSource }, { type: undefined }]; }, propDecorators: { settingsId: [{
@@ -33840,6 +33899,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
33840
33899
  type: Input
33841
33900
  }], propagateRowError: [{
33842
33901
  type: Input
33902
+ }], permanentSelectionAllowed: [{
33903
+ type: Input
33843
33904
  }], defaultSortBy: [{
33844
33905
  type: Input
33845
33906
  }], defaultSortDirection: [{