• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geonetwork / geonetwork-ui / 14537820791

18 Apr 2025 03:53PM UTC coverage: 84.358% (+1.3%) from 83.067%
14537820791

Pull #1203

github

web-flow
Merge 2e5955f5b into 3e7617888
Pull Request #1203: New truncate text component

1725 of 2323 branches covered (74.26%)

Branch coverage included in aggregate %.

30 of 31 new or added lines in 4 files covered. (96.77%)

10 existing lines in 2 files now uncovered.

5572 of 6327 relevant lines covered (88.07%)

10.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.14
/apps/datahub/src/app/home/search/search-filters/search-filters.component.ts
1
import {
1✔
2
  ChangeDetectionStrategy,
3
  Component,
4
  Input,
5
  OnInit,
6
  QueryList,
7
  ViewChildren,
8
} from '@angular/core'
9
import {
1✔
10
  FieldsService,
11
  FilterDropdownComponent,
12
  SearchFacade,
13
  SearchService,
14
} from '@geonetwork-ui/feature/search'
15
import { getOptionalSearchConfig } from '@geonetwork-ui/util/app-config'
1✔
16
import { Observable, switchMap } from 'rxjs'
1✔
17
import { map } from 'rxjs/operators'
1✔
18
import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface'
1✔
19

20
@Component({
21
  selector: 'datahub-search-filters',
22
  templateUrl: './search-filters.component.html',
23
  styleUrls: ['./search-filters.component.css'],
24
  changeDetection: ChangeDetectionStrategy.OnPush,
25
})
26
export class SearchFiltersComponent implements OnInit {
1✔
27
  @ViewChildren(FilterDropdownComponent)
28
  filters: QueryList<FilterDropdownComponent>
29
  searchConfig: { fieldName: string; title: string }[]
30
  isOpen = false
16✔
31
  @Input() isQualitySortable = false
16✔
32
  userId: string
33
  myRecordsFilterEnabled$: Observable<boolean> =
16✔
34
    this.searchFacade.searchFilters$.pipe(
35
      switchMap((filters) => {
36
        return this.fieldsService.readFieldValuesFromFilters(filters)
10✔
37
      }),
38
      map((fieldValues) =>
39
        fieldValues['owner'] && Array.isArray(fieldValues['owner'])
×
40
          ? fieldValues['owner'].length > 0
41
          : !!fieldValues['owner']
42
      )
43
    )
44

45
  constructor(
46
    public searchFacade: SearchFacade,
16!
47
    private searchService: SearchService,
16!
48
    private fieldsService: FieldsService,
16!
49
    private platformService: PlatformServiceInterface
16✔
50
  ) {}
51

52
  ngOnInit(): void {
53
    this.platformService.getMe().subscribe((user) => (this.userId = user?.id))
16✔
54
    this.searchConfig = (
16✔
55
      getOptionalSearchConfig().ADVANCED_FILTERS || [
16!
56
        'organization',
57
        'format',
58
        'publicationYear',
59
        'topic',
60
        'isSpatial',
61
        'license',
62
      ]
63
    )
64
      .filter((adv_filter) => {
65
        if (adv_filter === 'resourceType') {
128!
UNCOV
66
          console.warn(
×
67
            `WARNING: The resourceType filter is now deprecated, please use recordKind instead.`
68
          )
UNCOV
69
          console.warn(
×
70
            `WARNING: The resourceType filter does not return featureCatalog records anymore.`
71
          )
UNCOV
72
          return true
×
73
        } else if (this.fieldsService.supportedFields?.includes(adv_filter)) {
128!
74
          return true
128✔
75
        } else {
UNCOV
76
          console.warn(
×
77
            `WARNING: the configuration file contains an unsupported filter field: '${adv_filter}'. This field will be ignored.`
78
          )
UNCOV
79
          return false
×
80
        }
81
      })
82
      .map((filter) => ({
128✔
83
        fieldName: filter,
84
        title: `search.filters.${filter}`,
85
      }))
86
  }
87

88
  open() {
UNCOV
89
    this.isOpen = true
×
90
  }
91

92
  close() {
93
    this.isOpen = false
×
94
  }
95

96
  toggleSpatialFilter(enabled: boolean) {
97
    this.searchFacade.setSpatialFilterEnabled(enabled)
1✔
98
  }
99

100
  toggleMyRecordsFilter(enabled: boolean) {
UNCOV
101
    this.fieldsService
×
102
      .buildFiltersFromFieldValues({ owner: enabled ? this.userId : [] })
×
UNCOV
103
      .subscribe((filters) => this.searchService.updateFilters(filters))
×
104
  }
105

106
  clearFilters() {
107
    const fieldNames = this.filters.map((component) => component.fieldName)
8✔
108
    const fieldValues = fieldNames.reduce(
1✔
109
      (prev, curr) => ({ ...prev, [curr]: [] }),
8✔
110
      {}
111
    )
112
    this.fieldsService
1✔
113
      .buildFiltersFromFieldValues(fieldValues)
114
      .subscribe((filters) => {
115
        this.searchService.updateFilters(filters)
1✔
116
      })
117
  }
118

119
  getClassForFilter(index: number) {
120
    return (
256✔
121
      (this.isOpen ? 'block' : 'hidden') + ' ' + (index < 2 ? 'sm:block' : '')
512✔
122
    )
123
  }
124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc