@elderbyte/ngx-starter 15.6.2 → 15.6.4
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.
- package/esm2020/lib/common/data/data-context/data-context-auto-starter.mjs +6 -4
- package/esm2020/lib/common/data/data-context/data-context-base.mjs +2 -2
- package/esm2020/lib/common/data/data-context/data-context.mjs +1 -1
- package/esm2020/lib/common/data/data-context/indexed-entities.mjs +2 -3
- package/fesm2015/elderbyte-ngx-starter.mjs +81 -79
- package/fesm2015/elderbyte-ngx-starter.mjs.map +1 -1
- package/fesm2020/elderbyte-ngx-starter.mjs +81 -79
- package/fesm2020/elderbyte-ngx-starter.mjs.map +1 -1
- package/lib/common/data/data-context/data-context.d.ts +1 -1
- package/lib/common/data/data-context/indexed-entities.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import * as i1 from '@angular/platform-browser';
|
|
|
6
6
|
import { Duration, Period, TemporalQueries, LocalTime, Instant, LocalDate, nativeJs, ZoneId, ZonedDateTime, Temporal } from '@js-joda/core';
|
|
7
7
|
import { LoggerFactory } from '@elderbyte/ts-logger';
|
|
8
8
|
import { BehaviorSubject, Subject, EMPTY, combineLatest, merge, of, forkJoin, throwError, mergeWith, switchMap as switchMap$1, Observable, ReplaySubject, fromEvent, NEVER } from 'rxjs';
|
|
9
|
-
import { distinctUntilChanged, map, filter, takeUntil, debounceTime, catchError, first, take, switchMap, mergeMap,
|
|
9
|
+
import { distinctUntilChanged, map, filter, takeUntil, debounceTime, catchError, first, take, switchMap, mergeMap, tap, takeWhile, expand, reduce, startWith, skip, delay, share, throttleTime, combineLatestWith, timeout, skipWhile } from 'rxjs/operators';
|
|
10
10
|
import * as i1$2 from '@angular/common/http';
|
|
11
11
|
import { HttpParams, HttpEventType, HttpRequest, HttpClient, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
12
12
|
import { DataSource } from '@angular/cdk/collections';
|
|
@@ -3002,87 +3002,13 @@ class TokenChunkRequest {
|
|
|
3002
3002
|
}
|
|
3003
3003
|
}
|
|
3004
3004
|
|
|
3005
|
-
class SortContext {
|
|
3006
|
-
constructor() {
|
|
3007
|
-
/***************************************************************************
|
|
3008
|
-
* *
|
|
3009
|
-
* Fields *
|
|
3010
|
-
* *
|
|
3011
|
-
**************************************************************************/
|
|
3012
|
-
this._sorts = new BehaviorSubject([]);
|
|
3013
|
-
/***************************************************************************
|
|
3014
|
-
* *
|
|
3015
|
-
* Private methods *
|
|
3016
|
-
* *
|
|
3017
|
-
**************************************************************************/
|
|
3018
|
-
}
|
|
3019
|
-
/***************************************************************************
|
|
3020
|
-
* *
|
|
3021
|
-
* Read API *
|
|
3022
|
-
* *
|
|
3023
|
-
**************************************************************************/
|
|
3024
|
-
get sorts() {
|
|
3025
|
-
return this._sorts.asObservable();
|
|
3026
|
-
}
|
|
3027
|
-
get sortsSnapshot() {
|
|
3028
|
-
return this._sorts.getValue();
|
|
3029
|
-
}
|
|
3030
|
-
findSortDirection(prop) {
|
|
3031
|
-
const f = this.findSort(prop);
|
|
3032
|
-
return f ? f.dir : undefined;
|
|
3033
|
-
}
|
|
3034
|
-
findSort(prop) {
|
|
3035
|
-
return this.sortsSnapshot
|
|
3036
|
-
.filter(f => f.prop === prop)
|
|
3037
|
-
.find(first => true);
|
|
3038
|
-
}
|
|
3039
|
-
/***************************************************************************
|
|
3040
|
-
* *
|
|
3041
|
-
* Public API *
|
|
3042
|
-
* *
|
|
3043
|
-
**************************************************************************/
|
|
3044
|
-
/**
|
|
3045
|
-
* This method updatees / adds the given sort, leaving
|
|
3046
|
-
* existing ones untouched.
|
|
3047
|
-
* @param updatedSort
|
|
3048
|
-
*/
|
|
3049
|
-
updateSort(updatedSort) {
|
|
3050
|
-
if (updatedSort) {
|
|
3051
|
-
this.updateSorts([updatedSort]);
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
/**
|
|
3055
|
-
* This method updates / adds the given filters, leaving
|
|
3056
|
-
* existing ones untouched.
|
|
3057
|
-
* @param updatedSorts
|
|
3058
|
-
*/
|
|
3059
|
-
updateSorts(updatedSorts) {
|
|
3060
|
-
if (updatedSorts && updatedSorts.length > 0) {
|
|
3061
|
-
const sortMap = new Map();
|
|
3062
|
-
this.sortsSnapshot.forEach(s => sortMap.set(s.prop, s));
|
|
3063
|
-
updatedSorts.forEach(s => sortMap.set(s.prop, s));
|
|
3064
|
-
this.replaceSorts(Array.from(updatedSorts.values()));
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
/**
|
|
3068
|
-
* Replace all existing filters with the given new ones.
|
|
3069
|
-
* @param newSorts
|
|
3070
|
-
*/
|
|
3071
|
-
replaceSorts(newSorts) {
|
|
3072
|
-
this._sorts.next(newSorts || []);
|
|
3073
|
-
}
|
|
3074
|
-
clear() {
|
|
3075
|
-
this.replaceSorts([]);
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3079
3005
|
class IndexedEntities {
|
|
3080
3006
|
/***************************************************************************
|
|
3081
3007
|
* *
|
|
3082
3008
|
* Constructor *
|
|
3083
3009
|
* *
|
|
3084
3010
|
**************************************************************************/
|
|
3085
|
-
constructor(idFn, localSortFn, sortContext
|
|
3011
|
+
constructor(idFn, localSortFn, sortContext) {
|
|
3086
3012
|
this.idFn = idFn;
|
|
3087
3013
|
this.localSortFn = localSortFn;
|
|
3088
3014
|
this.sortContext = sortContext;
|
|
@@ -3292,6 +3218,80 @@ function isActivePagedDataContext(object) {
|
|
|
3292
3218
|
return object.setActivePage !== undefined;
|
|
3293
3219
|
}
|
|
3294
3220
|
|
|
3221
|
+
class SortContext {
|
|
3222
|
+
constructor() {
|
|
3223
|
+
/***************************************************************************
|
|
3224
|
+
* *
|
|
3225
|
+
* Fields *
|
|
3226
|
+
* *
|
|
3227
|
+
**************************************************************************/
|
|
3228
|
+
this._sorts = new BehaviorSubject([]);
|
|
3229
|
+
/***************************************************************************
|
|
3230
|
+
* *
|
|
3231
|
+
* Private methods *
|
|
3232
|
+
* *
|
|
3233
|
+
**************************************************************************/
|
|
3234
|
+
}
|
|
3235
|
+
/***************************************************************************
|
|
3236
|
+
* *
|
|
3237
|
+
* Read API *
|
|
3238
|
+
* *
|
|
3239
|
+
**************************************************************************/
|
|
3240
|
+
get sorts() {
|
|
3241
|
+
return this._sorts.asObservable();
|
|
3242
|
+
}
|
|
3243
|
+
get sortsSnapshot() {
|
|
3244
|
+
return this._sorts.getValue();
|
|
3245
|
+
}
|
|
3246
|
+
findSortDirection(prop) {
|
|
3247
|
+
const f = this.findSort(prop);
|
|
3248
|
+
return f ? f.dir : undefined;
|
|
3249
|
+
}
|
|
3250
|
+
findSort(prop) {
|
|
3251
|
+
return this.sortsSnapshot
|
|
3252
|
+
.filter(f => f.prop === prop)
|
|
3253
|
+
.find(first => true);
|
|
3254
|
+
}
|
|
3255
|
+
/***************************************************************************
|
|
3256
|
+
* *
|
|
3257
|
+
* Public API *
|
|
3258
|
+
* *
|
|
3259
|
+
**************************************************************************/
|
|
3260
|
+
/**
|
|
3261
|
+
* This method updatees / adds the given sort, leaving
|
|
3262
|
+
* existing ones untouched.
|
|
3263
|
+
* @param updatedSort
|
|
3264
|
+
*/
|
|
3265
|
+
updateSort(updatedSort) {
|
|
3266
|
+
if (updatedSort) {
|
|
3267
|
+
this.updateSorts([updatedSort]);
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
/**
|
|
3271
|
+
* This method updates / adds the given filters, leaving
|
|
3272
|
+
* existing ones untouched.
|
|
3273
|
+
* @param updatedSorts
|
|
3274
|
+
*/
|
|
3275
|
+
updateSorts(updatedSorts) {
|
|
3276
|
+
if (updatedSorts && updatedSorts.length > 0) {
|
|
3277
|
+
const sortMap = new Map();
|
|
3278
|
+
this.sortsSnapshot.forEach(s => sortMap.set(s.prop, s));
|
|
3279
|
+
updatedSorts.forEach(s => sortMap.set(s.prop, s));
|
|
3280
|
+
this.replaceSorts(Array.from(updatedSorts.values()));
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
/**
|
|
3284
|
+
* Replace all existing filters with the given new ones.
|
|
3285
|
+
* @param newSorts
|
|
3286
|
+
*/
|
|
3287
|
+
replaceSorts(newSorts) {
|
|
3288
|
+
this._sorts.next(newSorts || []);
|
|
3289
|
+
}
|
|
3290
|
+
clear() {
|
|
3291
|
+
this.replaceSorts([]);
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
3295
|
class DataContextBase extends DataSource {
|
|
3296
3296
|
/***************************************************************************
|
|
3297
3297
|
* *
|
|
@@ -3319,7 +3319,7 @@ class DataContextBase extends DataSource {
|
|
|
3319
3319
|
this._reloadQueue = new Subject();
|
|
3320
3320
|
this.unsubscribe$ = new Subject();
|
|
3321
3321
|
this._dataSource = dataSource;
|
|
3322
|
-
this._data = new IndexedEntities(e => dataSource.getId(e), _localSort);
|
|
3322
|
+
this._data = new IndexedEntities(e => dataSource.getId(e), _localSort, this._sort);
|
|
3323
3323
|
this._loading = this._status.pipe(map(status => status.loading));
|
|
3324
3324
|
this._filter.filters.pipe(filter(() => this.started), takeUntil(this.unsubscribe$)).subscribe(filters => this.onFiltersChanged(filters));
|
|
3325
3325
|
this._sort.sorts.pipe(filter(() => this.started), takeUntil(this.unsubscribe$)).subscribe(sorts => this.onSortsChanged(sorts));
|
|
@@ -4385,8 +4385,10 @@ class DataContextAutoStarter extends DataContextLifeCycleBinding {
|
|
|
4385
4385
|
* *
|
|
4386
4386
|
**************************************************************************/
|
|
4387
4387
|
subscribe() {
|
|
4388
|
-
|
|
4389
|
-
|
|
4388
|
+
const hasRequiredFilters = !!this._autoStartConditionFulfilled$;
|
|
4389
|
+
if (hasRequiredFilters) {
|
|
4390
|
+
const startedTrue$ = this._dataContext.isStarted$.pipe(filter(t => t));
|
|
4391
|
+
this._subscription = this._autoStartConditionFulfilled$.pipe(takeUntil(startedTrue$), tap(fulfilled => this.logger.debug(`Got fulfilled event: ${fulfilled}`)), filter(fulfilled => !!fulfilled)).subscribe(() => this.startDataContext());
|
|
4390
4392
|
}
|
|
4391
4393
|
}
|
|
4392
4394
|
/***************************************************************************
|