@elderbyte/ngx-starter 16.4.4 → 16.4.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.
- package/esm2022/lib/components/forms/directives/elder-initial-value.directive.mjs +2 -24
- package/esm2022/lib/components/forms/search/domain/context/search-context.mjs +10 -16
- package/esm2022/lib/components/forms/search/domain/input/search-input.mjs +1 -1
- package/esm2022/lib/components/forms/search/elder-search-context.directive.mjs +23 -18
- package/esm2022/lib/components/forms/search/elder-search-input.directive.mjs +3 -3
- package/fesm2022/elderbyte-ngx-starter.mjs +31 -54
- package/fesm2022/elderbyte-ngx-starter.mjs.map +1 -1
- package/lib/components/forms/directives/elder-initial-value.directive.d.ts +1 -1
- package/lib/components/forms/search/domain/context/search-context.d.ts +1 -2
- package/lib/components/forms/search/domain/input/search-input.d.ts +1 -1
- package/lib/components/forms/search/elder-search-context.directive.d.ts +5 -5
- package/lib/components/forms/search/elder-search-input.directive.d.ts +1 -1
- package/package.json +1 -1
|
@@ -84,6 +84,7 @@ import { MatSidenavModule } from '@angular/material/sidenav';
|
|
|
84
84
|
import * as i6 from '@angular/material/datepicker';
|
|
85
85
|
import { MatDatepicker, MatDatepickerModule } from '@angular/material/datepicker';
|
|
86
86
|
import localeDECH from '@angular/common/locales/de-CH';
|
|
87
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
87
88
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
88
89
|
import * as i1$a from '@angular/cdk/overlay';
|
|
89
90
|
import { OverlayModule } from '@angular/cdk/overlay';
|
|
@@ -25934,12 +25935,6 @@ class SearchContext {
|
|
|
25934
25935
|
this.userFilterContext = new FilterContext();
|
|
25935
25936
|
this.forcedFilterContext = new FilterContext();
|
|
25936
25937
|
this.allFilters$ = new BehaviorSubject(undefined);
|
|
25937
|
-
/***************************************************************************
|
|
25938
|
-
* *
|
|
25939
|
-
* Public API *
|
|
25940
|
-
* *
|
|
25941
|
-
**************************************************************************/
|
|
25942
|
-
this.acceptDefaultFilters = true;
|
|
25943
25938
|
this.id = id;
|
|
25944
25939
|
this.userFilterContext.filters.pipe(combineLatestWith(this.forcedFilterContext.filters), skip(1), map(([userFilters, forcedFilters]) => FilterUtil.mergeCombine(userFilters, forcedFilters)), tap(x => this.log.debug('allFilters changed: ', x))).subscribe(merged => this.allFilters$.next(merged));
|
|
25945
25940
|
}
|
|
@@ -25949,7 +25944,7 @@ class SearchContext {
|
|
|
25949
25944
|
* *
|
|
25950
25945
|
**************************************************************************/
|
|
25951
25946
|
get allFiltersChanged() {
|
|
25952
|
-
return this.allFilters$.pipe(filter(filters => !!filters));
|
|
25947
|
+
return this.allFilters$.pipe(filter(filters => !!filters), distinctUntilChanged((a, b) => FilterUtil.equals(a, b)));
|
|
25953
25948
|
}
|
|
25954
25949
|
get userFilters() {
|
|
25955
25950
|
return this.userFilterContext.filtersSnapshot;
|
|
@@ -25960,23 +25955,23 @@ class SearchContext {
|
|
|
25960
25955
|
get forcedFilters() {
|
|
25961
25956
|
return this.forcedFilterContext.filtersSnapshot;
|
|
25962
25957
|
}
|
|
25963
|
-
|
|
25958
|
+
/***************************************************************************
|
|
25959
|
+
* *
|
|
25960
|
+
* Public API *
|
|
25961
|
+
* *
|
|
25962
|
+
**************************************************************************/
|
|
25963
|
+
updateUserFiltersSave(filters) {
|
|
25964
25964
|
// this.log.error('updateDefaultFilters, acceptDefaultFilters: ' + this.acceptDefaultFilters, filters);
|
|
25965
|
-
|
|
25966
|
-
this.userFilterContext.updateFilters(FilterUtil.strip(filters, this.forcedFilters));
|
|
25967
|
-
}
|
|
25968
|
-
return this.acceptDefaultFilters;
|
|
25965
|
+
this.userFilterContext.updateFilters(FilterUtil.strip(filters, this.forcedFilters));
|
|
25969
25966
|
}
|
|
25970
25967
|
updateUserFilters(filters) {
|
|
25971
25968
|
if (filters.length > 0) {
|
|
25972
25969
|
// this.log.error('updateUserFilters', filters);
|
|
25973
|
-
this.acceptDefaultFilters = false;
|
|
25974
25970
|
this.userFilterContext.updateFilters(filters);
|
|
25975
25971
|
}
|
|
25976
25972
|
}
|
|
25977
25973
|
replaceUserFilters(filters) {
|
|
25978
25974
|
// this.log.error('replaceUserFilters', filters);
|
|
25979
|
-
this.acceptDefaultFilters = false;
|
|
25980
25975
|
this.userFilterContext.replaceFilters(filters);
|
|
25981
25976
|
}
|
|
25982
25977
|
replaceForcedFilters(filters) {
|
|
@@ -26036,20 +26031,21 @@ class ElderSearchContextDirective {
|
|
|
26036
26031
|
* Constructor *
|
|
26037
26032
|
* *
|
|
26038
26033
|
**************************************************************************/
|
|
26039
|
-
constructor(searchContextService) {
|
|
26034
|
+
constructor(searchContextService, destroyRef) {
|
|
26035
|
+
this.destroyRef = destroyRef;
|
|
26040
26036
|
/***************************************************************************
|
|
26041
26037
|
* *
|
|
26042
26038
|
* Fields *
|
|
26043
26039
|
* *
|
|
26044
26040
|
**************************************************************************/
|
|
26045
26041
|
this.log = LoggerFactory.getLogger(this.constructor.name);
|
|
26046
|
-
this.
|
|
26042
|
+
this.filtersToApplyAtRegistration = new Map;
|
|
26047
26043
|
this._searchInputs$ = new BehaviorSubject([]);
|
|
26048
26044
|
this._searchStates$ = new BehaviorSubject([]);
|
|
26049
26045
|
this._filterContext$ = new BehaviorSubject(null);
|
|
26050
26046
|
this._searchContext$ = new BehaviorSubject(SearchContext.standalone());
|
|
26051
26047
|
this.searchContextId$ = new BehaviorSubject(null);
|
|
26052
|
-
this.searchContextId$.pipe(
|
|
26048
|
+
this.searchContextId$.pipe(takeUntilDestroyed(this.destroyRef), filter(contextId => !!contextId), map(contextId => searchContextService.context(contextId))).subscribe(ctx => this._searchContext$.next(ctx));
|
|
26053
26049
|
}
|
|
26054
26050
|
/***************************************************************************
|
|
26055
26051
|
* *
|
|
@@ -26065,10 +26061,6 @@ class ElderSearchContextDirective {
|
|
|
26065
26061
|
this.applySearchContextToInputs(searchContext);
|
|
26066
26062
|
this.syncSearchInputsToSearchContext();
|
|
26067
26063
|
}
|
|
26068
|
-
ngOnDestroy() {
|
|
26069
|
-
this.destroy$.next();
|
|
26070
|
-
this.destroy$.complete();
|
|
26071
|
-
}
|
|
26072
26064
|
/***************************************************************************
|
|
26073
26065
|
* *
|
|
26074
26066
|
* Properties *
|
|
@@ -26144,8 +26136,12 @@ class ElderSearchContextDirective {
|
|
|
26144
26136
|
* Register a new search name in this container
|
|
26145
26137
|
*/
|
|
26146
26138
|
register(searchInput) {
|
|
26147
|
-
this.log.debug('Registering search input [' + searchInput.name + ']');
|
|
26148
26139
|
const current = this._searchInputs$.getValue();
|
|
26140
|
+
const toApply = this.filtersToApplyAtRegistration.get(searchInput.name);
|
|
26141
|
+
if (toApply) {
|
|
26142
|
+
searchInput.setValue(toApply.value);
|
|
26143
|
+
}
|
|
26144
|
+
this.log.debug('Registering search input [' + searchInput.name + ']. Late registration value:' + toApply?.value);
|
|
26149
26145
|
this._searchInputs$.next([...current, searchInput]);
|
|
26150
26146
|
}
|
|
26151
26147
|
reset() {
|
|
@@ -26171,21 +26167,21 @@ class ElderSearchContextDirective {
|
|
|
26171
26167
|
}
|
|
26172
26168
|
}
|
|
26173
26169
|
applyAsDefaultsUntilUserAction(searchContext, dcFilters) {
|
|
26174
|
-
dcFilters.filters.pipe(map(filters => searchContext.
|
|
26170
|
+
dcFilters.filters.pipe(takeUntilDestroyed(this.destroyRef), map(filters => searchContext.updateUserFiltersSave(filters))).subscribe();
|
|
26175
26171
|
}
|
|
26176
26172
|
syncSearchInputsToSearchContext() {
|
|
26177
|
-
this._searchInputs$.pipe(
|
|
26173
|
+
this._searchInputs$.pipe(takeUntilDestroyed(this.destroyRef), switchMap$1(inputs => combineLatest(inputs.map(i => i.state$))), debounceTime(5)).subscribe(states => {
|
|
26178
26174
|
this._searchStates$.next(states);
|
|
26179
26175
|
});
|
|
26180
26176
|
const inputFilters$ = this._searchStates$.pipe(map(states => this.convertToFilters(states)), filter(filters => filters.length > 0));
|
|
26181
26177
|
inputFilters$
|
|
26182
|
-
.pipe(
|
|
26178
|
+
.pipe(takeUntilDestroyed(this.destroyRef), combineLatestWith(this._searchContext$))
|
|
26183
26179
|
.subscribe(([inputFilters, searchContext]) => {
|
|
26184
26180
|
searchContext.updateUserFilters(inputFilters);
|
|
26185
26181
|
});
|
|
26186
26182
|
}
|
|
26187
26183
|
syncSearchContextToBoundFilterContext() {
|
|
26188
|
-
this._searchContext$.pipe(
|
|
26184
|
+
this._searchContext$.pipe(takeUntilDestroyed(this.destroyRef), switchMap$1(context => context.allFiltersChanged)).subscribe(allFilters => this.applyToBoundFilterContext(allFilters));
|
|
26189
26185
|
}
|
|
26190
26186
|
applyToBoundFilterContext(filters) {
|
|
26191
26187
|
const filterCtx = this.filterContext;
|
|
@@ -26210,7 +26206,10 @@ class ElderSearchContextDirective {
|
|
|
26210
26206
|
filters.forEach(f => {
|
|
26211
26207
|
const input = inputsByName.get(f.key);
|
|
26212
26208
|
if (input) {
|
|
26213
|
-
input.
|
|
26209
|
+
input.setValue(f.value);
|
|
26210
|
+
}
|
|
26211
|
+
else {
|
|
26212
|
+
this.filtersToApplyAtRegistration.set(f.key, f);
|
|
26214
26213
|
}
|
|
26215
26214
|
});
|
|
26216
26215
|
}
|
|
@@ -26227,7 +26226,7 @@ class ElderSearchContextDirective {
|
|
|
26227
26226
|
.filter(s => !!s.queryKey)
|
|
26228
26227
|
.map(s => new Filter(s.queryKey, s.queryValue));
|
|
26229
26228
|
}
|
|
26230
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ElderSearchContextDirective, deps: [{ token: SearchContextService }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
26229
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ElderSearchContextDirective, deps: [{ token: SearchContextService }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
26231
26230
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ElderSearchContextDirective, selector: "[elderSearchContext]", inputs: { searchContextId: "searchContextId", filterContext: ["elderSearchContext", "filterContext"], forcedFilters: "forcedFilters" }, exportAs: ["elderSearchContext"], ngImport: i0 }); }
|
|
26232
26231
|
}
|
|
26233
26232
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ElderSearchContextDirective, decorators: [{
|
|
@@ -26236,7 +26235,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
26236
26235
|
selector: '[elderSearchContext]',
|
|
26237
26236
|
exportAs: 'elderSearchContext'
|
|
26238
26237
|
}]
|
|
26239
|
-
}], ctorParameters: function () { return [{ type: SearchContextService }]; }, propDecorators: { searchContextId: [{
|
|
26238
|
+
}], ctorParameters: function () { return [{ type: SearchContextService }, { type: i0.DestroyRef }]; }, propDecorators: { searchContextId: [{
|
|
26240
26239
|
type: Input
|
|
26241
26240
|
}], filterContext: [{
|
|
26242
26241
|
type: Input,
|
|
@@ -26362,28 +26361,6 @@ class ElderInitialValueDirective {
|
|
|
26362
26361
|
this.initialDone$.next();
|
|
26363
26362
|
this.initialDone$.complete();
|
|
26364
26363
|
});
|
|
26365
|
-
// this.ngModelValue = this.ngModel.model;
|
|
26366
|
-
// ngModel.control.valueChanges
|
|
26367
|
-
// .pipe(
|
|
26368
|
-
// takeUntil(this.initialDone$),
|
|
26369
|
-
// takeUntil(this.unsubscribe$),
|
|
26370
|
-
// combineLatestWith(this.newValue$),
|
|
26371
|
-
// debounceTime(500)
|
|
26372
|
-
// ).subscribe({
|
|
26373
|
-
// next: ([ngModelValue, newValue]) => {
|
|
26374
|
-
// if (this.initialValue === ngModelValue) {
|
|
26375
|
-
// this.initialDone$.next();
|
|
26376
|
-
// this.initialDone$.complete();
|
|
26377
|
-
// ngModel.control.setValue(newValue ? newValue : ngModelValue); // Why set ngModelValue again??
|
|
26378
|
-
// } else {
|
|
26379
|
-
// this.log.warn('Initialisation not yet done!', {
|
|
26380
|
-
// initialValue: this.initialValue,
|
|
26381
|
-
// ngModelValue: ngModelValue,
|
|
26382
|
-
// newValue: newValue
|
|
26383
|
-
// });
|
|
26384
|
-
// }
|
|
26385
|
-
// }
|
|
26386
|
-
// });
|
|
26387
26364
|
}
|
|
26388
26365
|
/***************************************************************************
|
|
26389
26366
|
* *
|
|
@@ -26399,7 +26376,7 @@ class ElderInitialValueDirective {
|
|
|
26399
26376
|
return this.ngModel.control.valueChanges
|
|
26400
26377
|
.pipe(takeUntil(this.destroy$));
|
|
26401
26378
|
}
|
|
26402
|
-
|
|
26379
|
+
setValue(value) {
|
|
26403
26380
|
if (value) {
|
|
26404
26381
|
this.ngModel.control.setValue(value);
|
|
26405
26382
|
}
|
|
@@ -26490,9 +26467,9 @@ class ElderSearchInputDirective {
|
|
|
26490
26467
|
* Public API *
|
|
26491
26468
|
* *
|
|
26492
26469
|
**************************************************************************/
|
|
26493
|
-
|
|
26470
|
+
setValue(queryString) {
|
|
26494
26471
|
const value = this.convertQueryStringToRawModelValue(queryString);
|
|
26495
|
-
this.initialValueDirective.
|
|
26472
|
+
this.initialValueDirective.setValue(value);
|
|
26496
26473
|
}
|
|
26497
26474
|
reset() {
|
|
26498
26475
|
this.ngModel.reset();
|