@elderbyte/ngx-starter 19.14.1 → 19.15.0
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/fesm2022/elderbyte-ngx-starter.mjs +128 -77
- package/fesm2022/elderbyte-ngx-starter.mjs.map +1 -1
- package/lib/common/data/datasource/curated/curated-data-source.d.ts +3 -1
- package/lib/common/data/datasource/curated/curated-list-data-source.d.ts +4 -1
- package/lib/common/data/datasource/curated/curated-paged-data-source.d.ts +4 -1
- package/lib/common/utils/{filter-util.d.ts → filter/filter-util.d.ts} +1 -1
- package/lib/common/utils/{local-data-filter.d.ts → filter/local-data-filter.d.ts} +1 -4
- package/lib/common/utils/filter/object-field-matcher.d.ts +35 -0
- package/lib/common/utils/public_api.d.ts +2 -2
- package/package.json +1 -1
- /package/lib/common/utils/{object-path-resolver.d.ts → filter/object-path-resolver.d.ts} +0 -0
|
@@ -2601,14 +2601,6 @@ class Filter {
|
|
|
2601
2601
|
}
|
|
2602
2602
|
}
|
|
2603
2603
|
|
|
2604
|
-
class UnreachableCaseError extends Error {
|
|
2605
|
-
constructor(value) {
|
|
2606
|
-
super('Unreachable case unhandled value: ' + value);
|
|
2607
|
-
this.value = value;
|
|
2608
|
-
Object.setPrototypeOf(this, UnreachableCaseError.prototype);
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2612
2604
|
class ObjectPathResolver {
|
|
2613
2605
|
static { this.log = LoggerFactory.getLogger(ObjectPathResolver.constructor.name); }
|
|
2614
2606
|
/***************************************************************************
|
|
@@ -2654,6 +2646,124 @@ class ObjectPathResolver {
|
|
|
2654
2646
|
}
|
|
2655
2647
|
}
|
|
2656
2648
|
|
|
2649
|
+
class UnreachableCaseError extends Error {
|
|
2650
|
+
constructor(value) {
|
|
2651
|
+
super('Unreachable case unhandled value: ' + value);
|
|
2652
|
+
this.value = value;
|
|
2653
|
+
Object.setPrototypeOf(this, UnreachableCaseError.prototype);
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
class ObjectFieldMatcher {
|
|
2658
|
+
static of(entity) {
|
|
2659
|
+
return new ObjectFieldMatcher(entity);
|
|
2660
|
+
}
|
|
2661
|
+
/***************************************************************************
|
|
2662
|
+
* *
|
|
2663
|
+
* Constructor *
|
|
2664
|
+
* *
|
|
2665
|
+
**************************************************************************/
|
|
2666
|
+
constructor(entity) {
|
|
2667
|
+
this.entity = entity;
|
|
2668
|
+
}
|
|
2669
|
+
/***************************************************************************
|
|
2670
|
+
* *
|
|
2671
|
+
* Public API *
|
|
2672
|
+
* *
|
|
2673
|
+
**************************************************************************/
|
|
2674
|
+
matchesAll(fieldPaths, spec) {
|
|
2675
|
+
if (fieldPaths.length === 0)
|
|
2676
|
+
return false;
|
|
2677
|
+
for (const fieldPath of fieldPaths) {
|
|
2678
|
+
if (!this.matches(fieldPath, spec)) {
|
|
2679
|
+
return false;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
return true;
|
|
2683
|
+
}
|
|
2684
|
+
matchesAny(fieldPaths, spec) {
|
|
2685
|
+
for (const fieldPath of fieldPaths) {
|
|
2686
|
+
if (this.matches(fieldPath, spec)) {
|
|
2687
|
+
return true;
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
return false;
|
|
2691
|
+
}
|
|
2692
|
+
matches(fieldPath, spec) {
|
|
2693
|
+
const resolvedValue = ObjectPathResolver.resolveValue(this.entity, fieldPath);
|
|
2694
|
+
if (!spec.options.exclude) {
|
|
2695
|
+
return this.matchesGenericInclude(spec, resolvedValue);
|
|
2696
|
+
}
|
|
2697
|
+
else {
|
|
2698
|
+
return this.matchesGenericExclude(spec, resolvedValue);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
/***************************************************************************
|
|
2702
|
+
* *
|
|
2703
|
+
* Private methods *
|
|
2704
|
+
* *
|
|
2705
|
+
**************************************************************************/
|
|
2706
|
+
matchesGenericExclude(spec, resolvedValue) {
|
|
2707
|
+
let exclusions;
|
|
2708
|
+
if (Array.isArray(spec.needle)) {
|
|
2709
|
+
exclusions = spec.needle;
|
|
2710
|
+
}
|
|
2711
|
+
else {
|
|
2712
|
+
exclusions = [spec.needle];
|
|
2713
|
+
}
|
|
2714
|
+
if (exclusions.length > 0) {
|
|
2715
|
+
return !exclusions.some((excluded) => {
|
|
2716
|
+
if (Array.isArray(resolvedValue)) {
|
|
2717
|
+
return resolvedValue.some((v) => v === excluded); // TODO use matchesSingleValue
|
|
2718
|
+
}
|
|
2719
|
+
else {
|
|
2720
|
+
return resolvedValue === excluded; // TODO use matchesSingleValue
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
else {
|
|
2725
|
+
return true;
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
matchesGenericInclude(spec, resolvedValue) {
|
|
2729
|
+
if (Array.isArray(spec.needle)) {
|
|
2730
|
+
for (const val of spec.needle) {
|
|
2731
|
+
if (this.matchesSingleValue(resolvedValue, val, spec.options)) {
|
|
2732
|
+
return true;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
return false;
|
|
2736
|
+
}
|
|
2737
|
+
else {
|
|
2738
|
+
return this.matchesSingleValue(resolvedValue, spec.needle, spec.options);
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
matchesSingleValue(resolvedValue, filterValue, options) {
|
|
2742
|
+
if (resolvedValue === filterValue) {
|
|
2743
|
+
return true;
|
|
2744
|
+
}
|
|
2745
|
+
if (resolvedValue === null || resolvedValue === undefined) {
|
|
2746
|
+
return false;
|
|
2747
|
+
}
|
|
2748
|
+
let resolvedValueStr = String(resolvedValue);
|
|
2749
|
+
let filterValueStr = filterValue;
|
|
2750
|
+
if (!options.caseSensitive) {
|
|
2751
|
+
resolvedValueStr = resolvedValueStr.toLowerCase();
|
|
2752
|
+
filterValueStr = filterValueStr.toLowerCase();
|
|
2753
|
+
}
|
|
2754
|
+
switch (options.mode) {
|
|
2755
|
+
case 'start':
|
|
2756
|
+
return resolvedValueStr.startsWith(filterValueStr);
|
|
2757
|
+
case 'full':
|
|
2758
|
+
return resolvedValueStr === filterValueStr;
|
|
2759
|
+
case 'anywhere':
|
|
2760
|
+
return resolvedValueStr.indexOf(filterValueStr) >= 0;
|
|
2761
|
+
default:
|
|
2762
|
+
throw new UnreachableCaseError(options.mode);
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2657
2767
|
class TargetValue {
|
|
2658
2768
|
constructor(entity, resolvedValue) {
|
|
2659
2769
|
this.entity = entity;
|
|
@@ -2781,73 +2891,14 @@ class LocalDataFilter {
|
|
|
2781
2891
|
}
|
|
2782
2892
|
}
|
|
2783
2893
|
matchesResolvedValueGeneric(filter, target) {
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
const resolvedValue = target.resolvedValue;
|
|
2793
|
-
if (Array.isArray(filter.value)) {
|
|
2794
|
-
for (const val of filter.value) {
|
|
2795
|
-
if (this.matchesSingleValue(resolvedValue, val)) {
|
|
2796
|
-
return true;
|
|
2797
|
-
}
|
|
2798
|
-
}
|
|
2799
|
-
return false;
|
|
2800
|
-
}
|
|
2801
|
-
else {
|
|
2802
|
-
return this.matchesSingleValue(resolvedValue, filter.value);
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
matchesGenericExclude(filter, target) {
|
|
2806
|
-
const resolvedValue = target.resolvedValue;
|
|
2807
|
-
let exclusions;
|
|
2808
|
-
if (Array.isArray(filter.value)) {
|
|
2809
|
-
exclusions = filter.value;
|
|
2810
|
-
}
|
|
2811
|
-
else {
|
|
2812
|
-
exclusions = [filter.value];
|
|
2813
|
-
}
|
|
2814
|
-
if (exclusions.length > 0) {
|
|
2815
|
-
return !exclusions.some((excluded) => {
|
|
2816
|
-
if (Array.isArray(resolvedValue)) {
|
|
2817
|
-
return resolvedValue.some((v) => v === excluded);
|
|
2818
|
-
}
|
|
2819
|
-
else {
|
|
2820
|
-
return resolvedValue === excluded;
|
|
2821
|
-
}
|
|
2822
|
-
});
|
|
2823
|
-
}
|
|
2824
|
-
else {
|
|
2825
|
-
return true;
|
|
2826
|
-
}
|
|
2827
|
-
}
|
|
2828
|
-
matchesSingleValue(resolvedValue, filterValue) {
|
|
2829
|
-
if (resolvedValue === filterValue) {
|
|
2830
|
-
return true;
|
|
2831
|
-
}
|
|
2832
|
-
if (resolvedValue === null || resolvedValue === undefined) {
|
|
2833
|
-
return false;
|
|
2834
|
-
}
|
|
2835
|
-
let resolvedValueStr = String(resolvedValue);
|
|
2836
|
-
let filterValueStr = filterValue;
|
|
2837
|
-
if (!this.genericOptions.caseSensitive) {
|
|
2838
|
-
resolvedValueStr = resolvedValueStr.toLowerCase();
|
|
2839
|
-
filterValueStr = filterValueStr.toLowerCase();
|
|
2840
|
-
}
|
|
2841
|
-
switch (this.genericOptions.mode) {
|
|
2842
|
-
case 'start':
|
|
2843
|
-
return resolvedValueStr.startsWith(filterValueStr);
|
|
2844
|
-
case 'full':
|
|
2845
|
-
return resolvedValueStr === filterValueStr;
|
|
2846
|
-
case 'anywhere':
|
|
2847
|
-
return resolvedValueStr.indexOf(filterValueStr) >= 0;
|
|
2848
|
-
default:
|
|
2849
|
-
throw new UnreachableCaseError(this.genericOptions.mode);
|
|
2850
|
-
}
|
|
2894
|
+
return ObjectFieldMatcher.of(target.entity).matches(this.resolveObjectPath(filter), {
|
|
2895
|
+
options: {
|
|
2896
|
+
caseSensitive: this.genericOptions.caseSensitive,
|
|
2897
|
+
mode: this.genericOptions.mode,
|
|
2898
|
+
exclude: this.isExclude(filter),
|
|
2899
|
+
},
|
|
2900
|
+
needle: filter.value,
|
|
2901
|
+
});
|
|
2851
2902
|
}
|
|
2852
2903
|
}
|
|
2853
2904
|
|
|
@@ -23644,7 +23695,7 @@ class ElderSelectComponent extends ElderSelectBase {
|
|
|
23644
23695
|
this.entityS.set(newEntity);
|
|
23645
23696
|
}
|
|
23646
23697
|
else {
|
|
23647
|
-
this.logger.
|
|
23698
|
+
this.logger.debug('Ignored written entity as it is already set to entity$.');
|
|
23648
23699
|
}
|
|
23649
23700
|
}
|
|
23650
23701
|
super.writeToControl(value);
|
|
@@ -27235,7 +27286,7 @@ class ElderSearchContextDirective {
|
|
|
27235
27286
|
this.saveInitialFilters(filters);
|
|
27236
27287
|
if (filters.length > 0) {
|
|
27237
27288
|
const inputsByKey = this.searchInputsByQueryKey();
|
|
27238
|
-
this.log.
|
|
27289
|
+
this.log.debug('applyFiltersToInputs [' + Array.from(inputsByKey.keys()) + ']', {
|
|
27239
27290
|
filters: filters,
|
|
27240
27291
|
inputsByQueryKey: inputsByKey,
|
|
27241
27292
|
});
|