@coolon/angular-ui-powerups 16.1.0-aplpha.123 → 16.1.0-aplpha.124

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.
@@ -4072,29 +4072,34 @@ class PropertyColumnModel extends ColumnModel {
4072
4072
  }
4073
4073
 
4074
4074
  class SelectionColumnModel extends ColumnModel {
4075
- selectionModel;
4076
4075
  _enableHeaderControls = true;
4077
4076
  _color = "accent";
4078
- constructor(columnId, order, defaults, selectionModel) {
4077
+ _selectionModelProxy = proxify((SelectionModel));
4078
+ _isUsingTemporarySelection$ = new MutableValueModel(false);
4079
+ _userSelectionModel;
4080
+ constructor(columnId, order, defaults) {
4079
4081
  super(columnId, order, defaults);
4080
- this.selectionModel = selectionModel;
4081
4082
  const { chain } = Dsl.disposeWith(this);
4082
4083
  this._selectRowOnClick(false);
4083
4084
  this.cellHeaderRenderer(SelectionHeaderCellComponent, (component) => {
4084
- component.selectionModel = this.selectionModel;
4085
+ component.selectionModel = this._selectionModelProxy;
4085
4086
  component.enableHeaderControls = this._enableHeaderControls;
4086
4087
  component.color = this._color;
4087
4088
  });
4088
4089
  this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectionCellComponent, (component, rowData) => {
4089
4090
  component.row = rowData.row;
4090
- component.selectionModel = this.selectionModel;
4091
+ component.selectionModel = this._selectionModelProxy;
4091
4092
  component.color = this._color;
4092
4093
  }));
4093
- this.setMasterVisibility(this.selectionModel.enabled$);
4094
- this.setDefaultVisibility(chain(this.selectionModel.mode$).equals(SelectionModel.Mode.MULTIPLE));
4094
+ this.setMasterVisibility(this._selectionModelProxy.enabled$);
4095
+ this.setDefaultVisibility(chain(this._selectionModelProxy.mode$).equals(SelectionModel.Mode.MULTIPLE));
4096
+ }
4097
+ get selectionModel() {
4098
+ return this._selectionModelProxy;
4095
4099
  }
4096
4100
  useSelectionModel(selectionModel) {
4097
- this.selectionModel.setProxyTarget(selectionModel);
4101
+ this._userSelectionModel = selectionModel;
4102
+ this._selectionModelProxy.setProxyTarget(selectionModel);
4098
4103
  }
4099
4104
  getDefaultHeaderText() {
4100
4105
  return '';
@@ -4110,10 +4115,24 @@ class SelectionColumnModel extends ColumnModel {
4110
4115
  this._color = color;
4111
4116
  }
4112
4117
  selectRow(row) {
4113
- this.selectionModel.selectCommand.execute(row);
4118
+ this._selectionModelProxy.selectCommand.execute(row);
4114
4119
  }
4115
4120
  isSelected(row) {
4116
- return this.selectionModel.isSelected(row);
4121
+ return this._selectionModelProxy.isSelected(row);
4122
+ }
4123
+ async withTemporarySelectionModel(createSelectionModel, process) {
4124
+ const garbage = new GarbageCollector();
4125
+ this._isUsingTemporarySelection$.value = true;
4126
+ const selectionModel = createSelectionModel(garbage);
4127
+ this._selectionModelProxy.setProxyTarget(selectionModel);
4128
+ try {
4129
+ await process(selectionModel);
4130
+ }
4131
+ finally {
4132
+ this._selectionModelProxy.setProxyTarget(this._userSelectionModel);
4133
+ garbage.dispose();
4134
+ this._isUsingTemporarySelection$.value = false;
4135
+ }
4117
4136
  }
4118
4137
  }
4119
4138
 
@@ -4249,7 +4268,6 @@ class AbstractTableModel extends GarbageCollector {
4249
4268
  textSearchPredicate$;
4250
4269
  identityOf;
4251
4270
  dataSourceEmpty$;
4252
- selectionModelProxy = proxify((SelectionModel));
4253
4271
  selectedItems$;
4254
4272
  leadSelection$;
4255
4273
  hasSelection$;
@@ -4268,13 +4286,16 @@ class AbstractTableModel extends GarbageCollector {
4268
4286
  return (!regex || !!columns.find(c => regex.test(c.getSearchTextFor(row))));
4269
4287
  };
4270
4288
  });
4289
+ this.selectionColumnModel = new SelectionColumnModel("selection-column", this.columnManager, () => this.getColumnTextProperties("selection-column"));
4290
+ this.addColumn(this.selectionColumnModel, { before: null }); // first column
4291
+ this.addRowClass("aup-row-selected", row => this.selectionColumnModel.isSelected(row));
4271
4292
  this.firstEditableColumn$ = chain(this.columns$).select(c => c.hasEditorPortal()).first();
4272
4293
  this.firstVisibleColumn$ = chain(this.visibleColumns$).first();
4273
4294
  this.lastVisibleColumn$ = chain(this.visibleColumns$).last();
4274
4295
  this.rowSelectionDisabledOnAllColumns$ = chain(this.columnManager.visibleColumns$).select(column => column.isRowSelectionEnabled()).count().equals(0);
4275
4296
  this.dataSourceEmpty$ = chain(this.dataSource$).isEmpty();
4276
- this.selectedItems$ = this.selectionModelProxy.selectedItems$;
4277
- this.leadSelection$ = this.selectionModelProxy.leadSelection$;
4297
+ this.selectedItems$ = this.selectionColumnModel.selectionModel.selectedItems$;
4298
+ this.leadSelection$ = this.selectionColumnModel.selectionModel.leadSelection$;
4278
4299
  this.hasSelection$ = chain(this.selectedItems$).isNotEmpty();
4279
4300
  }
4280
4301
  setDataSource(dataSource$) {
@@ -4376,21 +4397,8 @@ class AbstractTableModel extends GarbageCollector {
4376
4397
  const columnId = options?.columnId || property.toString();
4377
4398
  return this.addColumn(new ListPropertyColumnModel(columnId, this.columnManager, property, () => this.getColumnTextProperties(columnId)));
4378
4399
  }
4379
- // TODO: clean this up and assign the selection model on teh table directly.
4380
- // tableModel.useSelectionModel(model) and have the seleciton column automatically
4381
- // added. Need to look at how we're using the visibility controls as well.
4382
- // Should also lazy create the selection column model if someone accesses it.
4383
- _addSelectionColumn(selectionModel, visible) {
4384
- assert.isNil(this.selectionColumnModel);
4385
- const columnId = "selection-column";
4386
- this.selectionColumnModel = new SelectionColumnModel(columnId, this.columnManager, () => this.getColumnTextProperties(columnId), this.selectionModelProxy);
4400
+ useSelectionModel(selectionModel) {
4387
4401
  this.selectionColumnModel.useSelectionModel(selectionModel);
4388
- this.addRowClass("aup-row-selected", row => this.selectionColumnModel.isSelected(row));
4389
- const selectionColumnModel = this.addColumn(this.selectionColumnModel, { before: null }); // first column
4390
- if (!isNil(visible)) {
4391
- selectionColumnModel.visibleWhile(visible instanceof ValueModel ? visible : ValueModel.constant(visible));
4392
- }
4393
- return selectionColumnModel;
4394
4402
  }
4395
4403
  addEditControls(saveCommandFactory, formFactory) {
4396
4404
  this.saveCommandFactory = saveCommandFactory;
@@ -4462,11 +4470,10 @@ class AbstractTableModel extends GarbageCollector {
4462
4470
  return this.hasUserSelectionModelThatIsEnabled() && !this.rowSelectionDisabledOnAllColumns$.value;
4463
4471
  }
4464
4472
  hasUserSelectionModelThatIsEnabled() {
4465
- const userSelectionModel = this.selectionColumnModel?.selectionModel.getProxyTarget();
4466
- return !!userSelectionModel && userSelectionModel.enabled$.value;
4473
+ return this.selectionColumnModel.selectionModel.enabled$.value;
4467
4474
  }
4468
4475
  getSelectionModel() {
4469
- return this.selectionColumnModel?.selectionModel;
4476
+ return this.selectionColumnModel.selectionModel;
4470
4477
  }
4471
4478
  isHoverEnabled() {
4472
4479
  return this.isRowSelectionEnabled() || this.rowClickListeners.listenerCount > 0;
@@ -5128,8 +5135,13 @@ class TableModel extends AbstractTableModel {
5128
5135
  this._filteredRows$.setDelegate(filteredRows$);
5129
5136
  this._visibleRows$.setDelegate(visibleRows$);
5130
5137
  }
5131
- addSelectionColumn(selectionModel, showSelectionColumn) {
5132
- return this._addSelectionColumn(selectionModel, showSelectionColumn);
5138
+ async withTemporaryMultipleSelectionModel(process) {
5139
+ return this.selectionColumnModel.withTemporarySelectionModel(garbage => {
5140
+ return new MultipleSelectionModel(this.filteredRows$, {
5141
+ identifiedWith: this.dataSource$.identityOf,
5142
+ disposedWith: garbage
5143
+ });
5144
+ }, process);
5133
5145
  }
5134
5146
  }
5135
5147
 
@@ -5614,9 +5626,6 @@ class TreeTableModel extends AbstractTableModel {
5614
5626
  isExpanded(row) {
5615
5627
  return this.treeExpansionModel.isExpanded(row);
5616
5628
  }
5617
- addSelectionColumn(selectionModel, showSelectionColumn) {
5618
- return this._addSelectionColumn(selectionModel, showSelectionColumn);
5619
- }
5620
5629
  }
5621
5630
  // export class FlattenStrategy<T extends VisitableTree<any>> extends SelfAndDescendantsVisitor<T> {
5622
5631
  //