@elderbyte/ngx-starter 19.1.12 → 19.1.13

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.
@@ -2633,7 +2633,7 @@ class Filter {
2633
2633
  }
2634
2634
 
2635
2635
  class FilterUtil {
2636
- static { this.logger = LoggerFactory.getLogger(FilterUtil.constructor.name); }
2636
+ static { this.log = LoggerFactory.getLogger(FilterUtil.constructor.name); }
2637
2637
  static equals(aFilters, bFilters) {
2638
2638
  if (aFilters.length !== bFilters.length) {
2639
2639
  return false;
@@ -2714,7 +2714,7 @@ class FilterUtil {
2714
2714
  return null;
2715
2715
  }
2716
2716
  static filterData(data, filters) {
2717
- FilterUtil.logger.debug('Filtering data with ' + data.length + ' items.', filters);
2717
+ FilterUtil.log.debug('Filtering data with ' + data.length + ' items.', filters);
2718
2718
  if (filters && filters.length > 0) {
2719
2719
  for (const filter of filters) {
2720
2720
  data = data.filter((e) => FilterUtil.matches(e, filter));
@@ -2726,16 +2726,7 @@ class FilterUtil {
2726
2726
  if (filter.value === null || filter.value === undefined) {
2727
2727
  return true;
2728
2728
  }
2729
- let value;
2730
- if (entity === null || entity === undefined) {
2731
- value = null;
2732
- }
2733
- else if (typeof entity === 'object') {
2734
- value = entity[filter.key];
2735
- }
2736
- else {
2737
- value = String(entity); // Support filtering primitive values
2738
- }
2729
+ const value = FilterUtil.resolveValue(entity, filter);
2739
2730
  if (Array.isArray(filter.value)) {
2740
2731
  for (const val of filter.value) {
2741
2732
  if (FilterUtil.matchesValue(value, val)) {
@@ -2748,6 +2739,37 @@ class FilterUtil {
2748
2739
  return FilterUtil.matchesValue(value, filter.value);
2749
2740
  }
2750
2741
  }
2742
+ static resolveValue(entity, filter) {
2743
+ let value;
2744
+ if (entity === null || entity === undefined) {
2745
+ value = null;
2746
+ }
2747
+ else if (typeof entity === 'object') {
2748
+ value = FilterUtil.resolveObjectValue(entity, filter);
2749
+ }
2750
+ else {
2751
+ value = String(entity); // Support filtering primitive values
2752
+ }
2753
+ return value;
2754
+ }
2755
+ static resolveObjectValue(entity, filter) {
2756
+ const hops = filter.key.split('.');
2757
+ let resolved = entity;
2758
+ for (const hop of hops) {
2759
+ if (resolved) {
2760
+ resolved = resolved[hop];
2761
+ }
2762
+ else {
2763
+ FilterUtil.log.warn('Could not resolve filter key "' +
2764
+ filter.key +
2765
+ '" as path, .' +
2766
+ hop +
2767
+ ' not found on null.', entity);
2768
+ return undefined;
2769
+ }
2770
+ }
2771
+ return resolved;
2772
+ }
2751
2773
  static matchesValue(haystack, needle) {
2752
2774
  if (haystack === needle) {
2753
2775
  return true;