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

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,37 @@ 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;
4099
+ }
4100
+ get isUsingTemporarySelectionModel$() {
4101
+ return this._isUsingTemporarySelection$.readonly$;
4095
4102
  }
4096
4103
  useSelectionModel(selectionModel) {
4097
- this.selectionModel.setProxyTarget(selectionModel);
4104
+ this._userSelectionModel = selectionModel;
4105
+ this._selectionModelProxy.setProxyTarget(selectionModel);
4098
4106
  }
4099
4107
  getDefaultHeaderText() {
4100
4108
  return '';
@@ -4110,10 +4118,24 @@ class SelectionColumnModel extends ColumnModel {
4110
4118
  this._color = color;
4111
4119
  }
4112
4120
  selectRow(row) {
4113
- this.selectionModel.selectCommand.execute(row);
4121
+ this._selectionModelProxy.selectCommand.execute(row);
4114
4122
  }
4115
4123
  isSelected(row) {
4116
- return this.selectionModel.isSelected(row);
4124
+ return this._selectionModelProxy.isSelected(row);
4125
+ }
4126
+ async withTemporarySelectionModel(createSelectionModel, process) {
4127
+ const garbage = new GarbageCollector();
4128
+ this._isUsingTemporarySelection$.value = true;
4129
+ const selectionModel = createSelectionModel(garbage);
4130
+ this._selectionModelProxy.setProxyTarget(selectionModel);
4131
+ try {
4132
+ await process(selectionModel);
4133
+ }
4134
+ finally {
4135
+ this._selectionModelProxy.setProxyTarget(this._userSelectionModel);
4136
+ garbage.dispose();
4137
+ this._isUsingTemporarySelection$.value = false;
4138
+ }
4117
4139
  }
4118
4140
  }
4119
4141
 
@@ -4249,7 +4271,6 @@ class AbstractTableModel extends GarbageCollector {
4249
4271
  textSearchPredicate$;
4250
4272
  identityOf;
4251
4273
  dataSourceEmpty$;
4252
- selectionModelProxy = proxify((SelectionModel));
4253
4274
  selectedItems$;
4254
4275
  leadSelection$;
4255
4276
  hasSelection$;
@@ -4268,13 +4289,16 @@ class AbstractTableModel extends GarbageCollector {
4268
4289
  return (!regex || !!columns.find(c => regex.test(c.getSearchTextFor(row))));
4269
4290
  };
4270
4291
  });
4292
+ this.selectionColumnModel = new SelectionColumnModel("selection-column", this.columnManager, () => this.getColumnTextProperties("selection-column"));
4293
+ this.addColumn(this.selectionColumnModel, { before: null }); // first column
4294
+ this.addRowClass("aup-row-selected", row => this.selectionColumnModel.isSelected(row));
4271
4295
  this.firstEditableColumn$ = chain(this.columns$).select(c => c.hasEditorPortal()).first();
4272
4296
  this.firstVisibleColumn$ = chain(this.visibleColumns$).first();
4273
4297
  this.lastVisibleColumn$ = chain(this.visibleColumns$).last();
4274
4298
  this.rowSelectionDisabledOnAllColumns$ = chain(this.columnManager.visibleColumns$).select(column => column.isRowSelectionEnabled()).count().equals(0);
4275
4299
  this.dataSourceEmpty$ = chain(this.dataSource$).isEmpty();
4276
- this.selectedItems$ = this.selectionModelProxy.selectedItems$;
4277
- this.leadSelection$ = this.selectionModelProxy.leadSelection$;
4300
+ this.selectedItems$ = this.selectionColumnModel.selectionModel.selectedItems$;
4301
+ this.leadSelection$ = this.selectionColumnModel.selectionModel.leadSelection$;
4278
4302
  this.hasSelection$ = chain(this.selectedItems$).isNotEmpty();
4279
4303
  }
4280
4304
  setDataSource(dataSource$) {
@@ -4376,21 +4400,8 @@ class AbstractTableModel extends GarbageCollector {
4376
4400
  const columnId = options?.columnId || property.toString();
4377
4401
  return this.addColumn(new ListPropertyColumnModel(columnId, this.columnManager, property, () => this.getColumnTextProperties(columnId)));
4378
4402
  }
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);
4403
+ useSelectionModel(selectionModel) {
4387
4404
  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
4405
  }
4395
4406
  addEditControls(saveCommandFactory, formFactory) {
4396
4407
  this.saveCommandFactory = saveCommandFactory;
@@ -4462,11 +4473,10 @@ class AbstractTableModel extends GarbageCollector {
4462
4473
  return this.hasUserSelectionModelThatIsEnabled() && !this.rowSelectionDisabledOnAllColumns$.value;
4463
4474
  }
4464
4475
  hasUserSelectionModelThatIsEnabled() {
4465
- const userSelectionModel = this.selectionColumnModel?.selectionModel.getProxyTarget();
4466
- return !!userSelectionModel && userSelectionModel.enabled$.value;
4476
+ return this.selectionColumnModel.selectionModel.enabled$.value;
4467
4477
  }
4468
4478
  getSelectionModel() {
4469
- return this.selectionColumnModel?.selectionModel;
4479
+ return this.selectionColumnModel.selectionModel;
4470
4480
  }
4471
4481
  isHoverEnabled() {
4472
4482
  return this.isRowSelectionEnabled() || this.rowClickListeners.listenerCount > 0;
@@ -5128,8 +5138,16 @@ class TableModel extends AbstractTableModel {
5128
5138
  this._filteredRows$.setDelegate(filteredRows$);
5129
5139
  this._visibleRows$.setDelegate(visibleRows$);
5130
5140
  }
5131
- addSelectionColumn(selectionModel, showSelectionColumn) {
5132
- return this._addSelectionColumn(selectionModel, showSelectionColumn);
5141
+ get isUsingTemporarySelectionModel$() {
5142
+ return this.selectionColumnModel.isUsingTemporarySelectionModel$;
5143
+ }
5144
+ async withTemporaryMultipleSelectionModel(process) {
5145
+ return this.selectionColumnModel.withTemporarySelectionModel(garbage => {
5146
+ return new MultipleSelectionModel(this.filteredRows$, {
5147
+ identifiedWith: this.dataSource$.identityOf,
5148
+ disposedWith: garbage
5149
+ });
5150
+ }, process);
5133
5151
  }
5134
5152
  }
5135
5153
 
@@ -5614,9 +5632,6 @@ class TreeTableModel extends AbstractTableModel {
5614
5632
  isExpanded(row) {
5615
5633
  return this.treeExpansionModel.isExpanded(row);
5616
5634
  }
5617
- addSelectionColumn(selectionModel, showSelectionColumn) {
5618
- return this._addSelectionColumn(selectionModel, showSelectionColumn);
5619
- }
5620
5635
  }
5621
5636
  // export class FlattenStrategy<T extends VisitableTree<any>> extends SelfAndDescendantsVisitor<T> {
5622
5637
  //