@coolon/angular-ui-powerups 14.23.0 → 14.24.1

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 } from 'tslib';
44
44
  import * as i1 from '@angular/platform-browser';
45
45
  import escapeStringRegexp from 'escape-string-regexp';
@@ -1790,7 +1790,7 @@ class AbstractListInputComponent extends AbstractInputComponent {
1790
1790
  this.setValueIsInProgress$ = new Guard();
1791
1791
  this.valueChange = new EventEmitter();
1792
1792
  const { when, valueOf, chain } = Dsl.disposeWith(this);
1793
- const binding = new Binding.Identity(this.formValue$, this.componentList$).writeRight();
1793
+ const binding = this.registerDisposable(new Binding.Identity(this.formValue$, this.componentList$).writeRight());
1794
1794
  const inExternalChange = valueOf.any(this.setValueIsInProgress$, chain(binding.direction).equals(Binding.Direction.RIGHT)).areTruthy();
1795
1795
  when(this.componentList$).changes((is, was) => {
1796
1796
  this.valueChange.emit(is);
@@ -1861,7 +1861,7 @@ class AbstractValueInputComponent extends AbstractInputComponent {
1861
1861
  this.componentValue$ = new MutableValueModel();
1862
1862
  this.valueChange = new EventEmitter();
1863
1863
  const { when, chain, valueOf } = Dsl.disposeWith(this);
1864
- const binding = new Binding.Identity(this.formValue$, this.componentValue$).writeRight();
1864
+ const binding = this.registerDisposable(new Binding.Identity(this.formValue$, this.componentValue$).writeRight());
1865
1865
  const inExternalChange = valueOf.any(this.setValueInProgress$, chain(binding.direction).equals(Binding.Direction.RIGHT)).areTruthy();
1866
1866
  when(this.componentValue$).changes((is, was) => {
1867
1867
  this.valueChange.emit(is);
@@ -2891,6 +2891,9 @@ class AbstractTableComponent extends DisposableComponent {
2891
2891
  ngOnInit() {
2892
2892
  const { chain } = Dsl.disposeWith(this);
2893
2893
  const model = this.getModel();
2894
+ if (!model) {
2895
+ lang$1.illegalState("aup-table tableModel is nil");
2896
+ }
2894
2897
  this.columnsById = chain(model.columns).indexBy('columnId');
2895
2898
  this._dataSource$.setDelegate(model.dataSource$);
2896
2899
  model.initialise(this.injector, (row) => this.identityOf(row));
@@ -3367,9 +3370,9 @@ class PropertyColumnModel extends ColumnModel {
3367
3370
  class SelectionColumnModel extends ColumnModel {
3368
3371
  constructor(columnId, defaults, selectionModel) {
3369
3372
  super(columnId, defaults);
3373
+ this.selectionModel = selectionModel;
3370
3374
  this._enableHeaderControls = true;
3371
3375
  this._color = "accent";
3372
- this.selectionModel = DelegatingSelectionModel.createDelegate();
3373
3376
  const { chain } = Dsl.disposeWith(this);
3374
3377
  this._selectRowOnClick(false);
3375
3378
  this.cellHeaderRenderer(SelectionHeaderCellComponent, (component) => {
@@ -3382,11 +3385,10 @@ class SelectionColumnModel extends ColumnModel {
3382
3385
  component.selectionModel = this.selectionModel;
3383
3386
  component.color = this._color;
3384
3387
  }));
3385
- this.setSelectionModel(selectionModel);
3386
3388
  this.setMasterVisibility(this.selectionModel.enabled$);
3387
3389
  this.setDefaultVisibility(chain(this.selectionModel.mode$).equals(SelectionModel.Mode.MULTIPLE));
3388
3390
  }
3389
- setSelectionModel(selectionModel) {
3391
+ useSelectionModel(selectionModel) {
3390
3392
  this.selectionModel.setDelegate(selectionModel);
3391
3393
  }
3392
3394
  getDefaultHeaderText() {
@@ -3431,6 +3433,7 @@ class AbstractTableModel extends GarbageCollector {
3431
3433
  this.rowClassNamePredicates = [];
3432
3434
  this.rowClickListeners = new EventListenerList();
3433
3435
  this._createForm = (row) => new DirtyTrackingForm();
3436
+ this.delegatingSelectionModel = DelegatingSelectionModel.createDelegate();
3434
3437
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
3435
3438
  this._rowsBeingEdited$ = new MutableListModel([], {
3436
3439
  identifiedWith: row => this.identityOf(row)
@@ -3447,6 +3450,9 @@ class AbstractTableModel extends GarbageCollector {
3447
3450
  this.lastVisibleColumn$ = chain(this._columnList).last();
3448
3451
  this.rowSelectionDisabledOnAllColumns$ = chain(this._columnList).select(column => column.isRowSelectionEnabled()).count().equals(0);
3449
3452
  this.dataSourceEmpty$ = chain(this.dataSource$).isEmpty();
3453
+ this.selectedItems$ = this.delegatingSelectionModel.selectedItems$;
3454
+ this.leadSelection$ = this.delegatingSelectionModel.leadSelection$;
3455
+ this.hasSelection$ = chain(this.selectedItems$).isNotEmpty();
3450
3456
  }
3451
3457
  setDataSource(dataSource$) {
3452
3458
  this._dataSource$.setDelegate(dataSource$);
@@ -3533,10 +3539,15 @@ class AbstractTableModel extends GarbageCollector {
3533
3539
  const columnId = options?.columnId || property.toString();
3534
3540
  return this.addColumn(new ListPropertyColumnModel(columnId, property, () => this.getColumnTextProperties(columnId)));
3535
3541
  }
3542
+ // TODO: clean this up and assign the selection model on teh table directly.
3543
+ // tableModel.useSelectionModel(model) and have the seleciton column automatically
3544
+ // added. Need to look at how we're using the visibility controls as well.
3545
+ // Should also lazy create the selection column model if someone accesses it.
3536
3546
  _addSelectionColumn(selectionModel, visible) {
3537
3547
  assert.isNil(this.selectionColumnModel);
3538
3548
  const columnId = "selection-column";
3539
- this.selectionColumnModel = new SelectionColumnModel(columnId, () => this.getColumnTextProperties(columnId), selectionModel);
3549
+ this.selectionColumnModel = new SelectionColumnModel(columnId, () => this.getColumnTextProperties(columnId), this.delegatingSelectionModel);
3550
+ this.selectionColumnModel.useSelectionModel(selectionModel);
3540
3551
  this.addRowClass("aup-row-selected", row => this.selectionColumnModel.isSelected(row));
3541
3552
  const selectionColumnModel = this.addColumn(this.selectionColumnModel, 0);
3542
3553
  if (!isNil$1(visible)) {