@coolon/angular-ui-powerups 14.22.0 → 14.24.0

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.
@@ -39,7 +39,7 @@ import { MatTableModule } from '@angular/material/table';
39
39
  import * as i4 from '@angular/material/tooltip';
40
40
  import { MatTooltipModule } from '@angular/material/tooltip';
41
41
  import * as i1$3 from '@coolon/pectin';
42
- import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, ValueModel, StoreInValueModel, Command, MutableListModel, StoreInListModel, Disposable, DelegatingListModel, MutableValueModel, FocusManager, EventListenerList, Form, Guard, Binding, DebugContext, ListModel, Functions, HasDelegate, MultipleSelectionModel, SelectionModel, AbstractComputedListModel, DelegatingSelectionModel, DirtyTrackingForm, PageController, PagedListModel, ComputedListModel, Deferred } from '@coolon/pectin';
42
+ import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, ValueModel, StoreInValueModel, Command, MutableListModel, StoreInListModel, Disposable, DelegatingListModel, MutableValueModel, FocusManager, EventListenerList, Form, Guard, Binding, DebugContext, ListModel, Functions, HasDelegate, MultipleSelectionModel, SelectionModel, AbstractComputedListModel, DirtyTrackingForm, DelegatingSelectionModel, PageController, PagedListModel, ComputedListModel, Deferred } from '@coolon/pectin';
43
43
  import { __decorate, __param, __metadata, __awaiter } from 'tslib';
44
44
  import escapeStringRegexp from 'escape-string-regexp';
45
45
  import { isEmpty, isString, isFunction, isNil, isInteger, isEqual, uniq, last, first, isObject, isNumber, isNaN as isNaN$1 } from 'lodash';
@@ -3613,9 +3613,9 @@ class PropertyColumnModel extends ColumnModel {
3613
3613
  class SelectionColumnModel extends ColumnModel {
3614
3614
  constructor(columnId, defaults, selectionModel) {
3615
3615
  super(columnId, defaults);
3616
+ this.selectionModel = selectionModel;
3616
3617
  this._enableHeaderControls = true;
3617
3618
  this._color = "accent";
3618
- this.selectionModel = DelegatingSelectionModel.createDelegate();
3619
3619
  const { chain } = Dsl.disposeWith(this);
3620
3620
  this._selectRowOnClick(false);
3621
3621
  this.cellHeaderRenderer(SelectionHeaderCellComponent, (component) => {
@@ -3628,11 +3628,10 @@ class SelectionColumnModel extends ColumnModel {
3628
3628
  component.selectionModel = this.selectionModel;
3629
3629
  component.color = this._color;
3630
3630
  }));
3631
- this.setSelectionModel(selectionModel);
3632
3631
  this.setMasterVisibility(this.selectionModel.enabled$);
3633
3632
  this.setDefaultVisibility(chain(this.selectionModel.mode$).equals(SelectionModel.Mode.MULTIPLE));
3634
3633
  }
3635
- setSelectionModel(selectionModel) {
3634
+ useSelectionModel(selectionModel) {
3636
3635
  this.selectionModel.setDelegate(selectionModel);
3637
3636
  }
3638
3637
  getDefaultHeaderText() {
@@ -3691,12 +3690,14 @@ class AbstractTableModel extends GarbageCollector {
3691
3690
  constructor() {
3692
3691
  super();
3693
3692
  this._dataSource$ = this.registerDisposable(new DelegatingListModel());
3693
+ this._filteredRows$ = this.registerDisposable(new DelegatingListModel());
3694
3694
  this._visibleRows$ = this.registerDisposable(new DelegatingListModel());
3695
3695
  this._columnList = this.registerDisposable(new ColumnListModel());
3696
3696
  this._editorSessions = new MutableListModel();
3697
3697
  this.rowClassNamePredicates = [];
3698
3698
  this.rowClickListeners = new EventListenerList();
3699
3699
  this._createForm = (row) => new DirtyTrackingForm();
3700
+ this.delegatingSelectionModel = DelegatingSelectionModel.createDelegate();
3700
3701
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
3701
3702
  this._rowsBeingEdited$ = new MutableListModel([], {
3702
3703
  identifiedWith: row => this.identityOf(row)
@@ -3713,6 +3714,9 @@ class AbstractTableModel extends GarbageCollector {
3713
3714
  this.lastVisibleColumn$ = chain(this._columnList).last();
3714
3715
  this.rowSelectionDisabledOnAllColumns$ = chain(this._columnList).select(column => column.isRowSelectionEnabled()).count().equals(0);
3715
3716
  this.dataSourceEmpty$ = chain(this.dataSource$).isEmpty();
3717
+ this.selectedItems$ = this.delegatingSelectionModel.selectedItems$;
3718
+ this.leadSelection$ = this.delegatingSelectionModel.leadSelection$;
3719
+ this.hasSelection$ = chain(this.selectedItems$).isNotEmpty();
3716
3720
  }
3717
3721
  setDataSource(dataSource$) {
3718
3722
  this._dataSource$.setDelegate(dataSource$);
@@ -3738,6 +3742,17 @@ class AbstractTableModel extends GarbageCollector {
3738
3742
  get dataSource$() {
3739
3743
  return this._dataSource$.readonly;
3740
3744
  }
3745
+ /**
3746
+ * Gets the rows that are visible after any filters are applied. If there are
3747
+ * no filters then this will be the same as the root dataset.
3748
+ */
3749
+ get filteredRows$() {
3750
+ return this._filteredRows$.readonly;
3751
+ }
3752
+ /**
3753
+ * Gets the rows are currently visible to the user. I.e. the current page in a paged table or the
3754
+ * expanded rows in a tree table.
3755
+ */
3741
3756
  get visibleRows$() {
3742
3757
  return this._visibleRows$.readonly;
3743
3758
  }
@@ -3791,7 +3806,8 @@ class AbstractTableModel extends GarbageCollector {
3791
3806
  _addSelectionColumn(selectionModel, visible) {
3792
3807
  assert.isNil(this.selectionColumnModel);
3793
3808
  const columnId = "selection-column";
3794
- this.selectionColumnModel = new SelectionColumnModel(columnId, () => this.getColumnTextProperties(columnId), selectionModel);
3809
+ this.selectionColumnModel = new SelectionColumnModel(columnId, () => this.getColumnTextProperties(columnId), this.delegatingSelectionModel);
3810
+ this.selectionColumnModel.useSelectionModel(selectionModel);
3795
3811
  this.addRowClass("aup-row-selected", row => this.selectionColumnModel.isSelected(row));
3796
3812
  const selectionColumnModel = this.addColumn(this.selectionColumnModel, 0);
3797
3813
  if (!isNil$1(visible)) {
@@ -3971,6 +3987,10 @@ class TableModel extends AbstractTableModel {
3971
3987
  this.setDataSource(sourceOfTruth);
3972
3988
  }
3973
3989
  }
3990
+ bindToTable(filteredRows$, visibleRows$) {
3991
+ this._filteredRows$.setDelegate(filteredRows$);
3992
+ this._visibleRows$.setDelegate(visibleRows$);
3993
+ }
3974
3994
  addSelectionColumn(selectionModel, showSelectionColumn) {
3975
3995
  return this._addSelectionColumn(selectionModel, showSelectionColumn);
3976
3996
  }
@@ -4292,6 +4312,7 @@ class TableComponent extends AbstractTableComponent {
4292
4312
  this._filteredRows$.setDelegate(this._dataSource$);
4293
4313
  }
4294
4314
  this.configurePaging(this.enablePaging$.value);
4315
+ this.tableModel.bindToTable(this._filteredRows$, this._visibleRows$);
4295
4316
  }
4296
4317
  getModel() {
4297
4318
  return this.tableModel;
@@ -4836,10 +4857,11 @@ class TreeTableModel extends AbstractTableModel {
4836
4857
  get isExpandedPredicate$() {
4837
4858
  return this._isExpandedPredicate$.readonly;
4838
4859
  }
4839
- bindToTable(expansionModel, visibleRows$) {
4860
+ bindToTable(expansionModel, filteredRows$, visibleRows$) {
4840
4861
  this.treeExpansionModel = expansionModel;
4841
4862
  // TODO: Move all the expansion model stuff out of here and have things use the expansion model directly
4842
4863
  this._isExpandedPredicate$.setDelegate(this.treeExpansionModel.isExpandedPredicate$);
4864
+ this._filteredRows$.setDelegate(filteredRows$);
4843
4865
  this._visibleRows$.setDelegate(visibleRows$);
4844
4866
  }
4845
4867
  treeControlColumn(builder) {
@@ -4985,9 +5007,9 @@ class TreeTableComponent extends AbstractTableComponent {
4985
5007
  }
4986
5008
  // Todo, turn this into a plain chain model
4987
5009
  const visibleRows$ = new FlattenedTreeListModel(this._dataSource$, row => this.treeTableModel.childExtractor(row), this.expansionModel);
4988
- this.expansionModel.bindToTable(this._dataSource$, visibleRows$);
4989
- this.treeTableModel.bindToTable(this.expansionModel, visibleRows$);
4990
5010
  this._visibleRows$.setDelegate(visibleRows$);
5011
+ this.expansionModel.bindToTable(this._dataSource$, visibleRows$);
5012
+ this.treeTableModel.bindToTable(this.expansionModel, visibleRows$, this._visibleRows$);
4991
5013
  }
4992
5014
  getModel() {
4993
5015
  return this.treeTableModel;