@elderbyte/ngx-starter 13.7.5 → 13.7.6

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.
@@ -2156,7 +2156,7 @@ class CollectionUtil {
2156
2156
  return false;
2157
2157
  }
2158
2158
  /**
2159
- * Moves the given item up in the given array - if not already at the bottom
2159
+ * Moves the given item up in the given array - if not already at the top
2160
2160
  * @param items
2161
2161
  * @param toMove
2162
2162
  */
@@ -3822,7 +3822,7 @@ class MatTableDataContextBinding {
3822
3822
  }
3823
3823
  }
3824
3824
  bindDataContextToMatSortsUntil(matSorts$, destroy$) {
3825
- const dcSorts$ = this._dataContext$.pipe(switchMap(dc => dc.sort.sorts));
3825
+ const dcSorts$ = this._dataContext$.pipe(filter(dc => !!dc), switchMap(dc => dc.sort.sorts));
3826
3826
  combineLatest([dcSorts$, matSorts$]).pipe(takeUntil(destroy$)).subscribe(([dcSorts, matSorts]) => {
3827
3827
  if (dcSorts.length >= 1) {
3828
3828
  // At least one sort active
@@ -3859,19 +3859,23 @@ class MatTableDataContextBinding {
3859
3859
  return new Sort(matSort.active, this.fromMatDirection(matSort.direction));
3860
3860
  }));
3861
3861
  combineLatest([this._dataContext$, sortChanges$]).pipe(takeUntil(destroy$)).subscribe(([dc, sortRequest]) => {
3862
- dc.sort.updateSort(sortRequest);
3862
+ if (dc) {
3863
+ dc.sort.updateSort(sortRequest);
3864
+ }
3863
3865
  });
3864
3866
  }
3865
3867
  bindPaginatorUntil(paginator$, destroy$) {
3866
3868
  const pageRequest$ = paginator$.pipe(filter(paginator => !!paginator), switchMap(paginator => paginator.page), map(pageEvent => new PageRequest(pageEvent.pageIndex, pageEvent.pageSize)));
3867
3869
  combineLatest([this._dataContext$, pageRequest$]).pipe(takeUntil(destroy$)).subscribe(([dc, pageRequest]) => {
3868
- if (isActivePagedDataContext(dc)) {
3869
- const pagedDc = dc;
3870
- pagedDc.setActivePage(pageRequest);
3871
- }
3872
- else {
3873
- this.logger.warn('Can not bind the given paginator to the given data-context,' +
3874
- ' as the datacontext does not support pagination!', dc);
3870
+ if (dc) {
3871
+ if (isActivePagedDataContext(dc)) {
3872
+ const pagedDc = dc;
3873
+ pagedDc.setActivePage(pageRequest);
3874
+ }
3875
+ else {
3876
+ this.logger.warn('Can not bind the given paginator to the given data-context,' +
3877
+ ' as the datacontext does not support pagination!', dc);
3878
+ }
3875
3879
  }
3876
3880
  });
3877
3881
  }
@@ -20244,6 +20248,7 @@ class ElderSelectBase extends FormFieldBaseComponent {
20244
20248
  **************************************************************************/
20245
20249
  this._logger = LoggerFactory.getLogger(this.constructor.name);
20246
20250
  this._filterContext = new FilterContext();
20251
+ this.timeoutAfterMs = 5000;
20247
20252
  /**
20248
20253
  * Define if elder-select should clean up the
20249
20254
  * data-context resources for you.
@@ -20901,7 +20906,10 @@ class ElderSelectComponent extends ElderSelectBase {
20901
20906
  this.entityChange = this._entity$.pipe(skip(1) // Skip the initial or current value
20902
20907
  );
20903
20908
  this.entityIdUpdated = this.valueUpdated.pipe(map(value => this.entityIdFromValue(value)));
20904
- this.entityUpdated = combineLatest([this.entityIdUpdated, this._entity$]).pipe(filter(([updatedId, entity]) => this.getEntityId(entity) === updatedId), map(([updatedId, entity]) => entity));
20909
+ this.entityUpdated = this.entityIdUpdated.pipe(switchMap(entityId => this.awaitEntityWithId(entityId, this.timeoutAfterMs)), catchError(err => {
20910
+ this.logger.warn(`awaitEntityWithId -> timed out after: ${this.timeoutAfterMs}`, err);
20911
+ return EMPTY;
20912
+ }));
20905
20913
  this.entityWrapped$ = combineLatest([
20906
20914
  this._entity$,
20907
20915
  this.displayPropertyResolver$,
@@ -21092,6 +21100,9 @@ class ElderSelectComponent extends ElderSelectBase {
21092
21100
  valuesEquals(a, b) {
21093
21101
  return this.entityIdFromValue(a) === this.entityIdFromValue(b);
21094
21102
  }
21103
+ awaitEntityWithId(entityId, timeoutMs) {
21104
+ return this.entity$.pipe(filter(entity => this.getEntityId(entity) === entityId), take(1), timeout(timeoutMs));
21105
+ }
21095
21106
  isEntitySelected(entity) {
21096
21107
  return this.getEntityId(entity) === this.entityId;
21097
21108
  }
@@ -21303,7 +21314,13 @@ class ElderMultiSelectBase extends ElderSelectBase {
21303
21314
  this.entities$ = new BehaviorSubject([]);
21304
21315
  this.entityIdsChange = this.valueChange.pipe(map(values => this.entityIdsFromValues(values)));
21305
21316
  this.entityIdsUpdated = this.valueUpdated.pipe(map(values => this.entityIdsFromValues(values)));
21306
- this.entitiesUpdated = combineLatest([this.entityIdsUpdated, this.entities$]).pipe(filter(([updatedIds, entities]) => this.equalIds(this.getEntityIds(entities), updatedIds)), map(([updatedIds, entities]) => entities));
21317
+ this.entitiesUpdated = this.entityIdsUpdated.pipe(switchMap(entityId => this.awaitEntitiesWithId(entityId, this.timeoutAfterMs)), catchError(err => {
21318
+ this.logger.warn(`awaitEntitiesWithId -> timed out after: ${this.timeoutAfterMs}`, err);
21319
+ return EMPTY;
21320
+ }));
21321
+ }
21322
+ awaitEntitiesWithId(entityIds, timeoutMs) {
21323
+ return this.entities$.pipe(filter(entities => this.equalIds(this.getEntityIds(entities), entityIds)), take(1), timeout(timeoutMs));
21307
21324
  }
21308
21325
  /***************************************************************************
21309
21326
  * *