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

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.
@@ -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(() => (selectionChangedPrevented = true)) // prevent selection change on sort
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
- selectionChangedPrevented = true;
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
- selectionChangedPrevented = false;
27207
+ this.permanentSelectionChangedPrevented = false;
27202
27208
  }
27203
27209
  }));
27204
27210
  // Listen selection change
27205
27211
  this.registerSubscription(this.selection.changed
27206
- .pipe(filter(() => !selectionChangedPrevented))
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: [{