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

geonetwork / geonetwork-ui / 12313455218

13 Dec 2024 09:55AM UTC coverage: 85.306% (+3.5%) from 81.764%
12313455218

Pull #1064

github

web-flow
Merge 3a5b09c03 into a63d6d05e
Pull Request #1064: [Editor]: Search in the whole catalog from any dashboard

965 of 1279 branches covered (75.45%)

Branch coverage included in aggregate %.

14 of 40 new or added lines in 6 files covered. (35.0%)

46 existing lines in 3 files now uncovered.

2733 of 3056 relevant lines covered (89.43%)

7.44 hits per line

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

73.08
/apps/metadata-editor/src/app/records/my-records/my-records.component.ts
1
import {
2✔
2
  ChangeDetectorRef,
3
  Component,
4
  ElementRef,
5
  OnInit,
6
  TemplateRef,
7
  ViewChild,
8
  ViewContainerRef,
9
} from '@angular/core'
10
import { CommonModule } from '@angular/common'
2✔
11
import { TranslateModule } from '@ngx-translate/core'
2✔
12
import { RecordsListComponent } from '../records-list.component'
2✔
13
import {
2✔
14
  FeatureSearchModule,
15
  FieldsService,
16
  FILTER_SUMMARY_IGNORE_LIST,
17
  SearchFacade,
18
} from '@geonetwork-ui/feature/search'
19
import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface'
2✔
20
import { UiElementsModule } from '@geonetwork-ui/ui/elements'
2✔
21
import { Router } from '@angular/router'
2✔
22
import { Overlay, OverlayRef } from '@angular/cdk/overlay'
2✔
23
import { TemplatePortal } from '@angular/cdk/portal'
2✔
24
import { RecordsCountComponent } from '../records-count/records-count.component'
2✔
25
import { ButtonComponent } from '@geonetwork-ui/ui/inputs'
2✔
26
import { ImportRecordComponent } from '@geonetwork-ui/feature/editor'
2✔
27
import { SearchHeaderComponent } from '../../dashboard/search-header/search-header.component'
2✔
28
import { map, Observable, take } from 'rxjs'
2✔
29
import { SearchFiltersComponent } from '../../dashboard/search-filters/search-filters.component'
2✔
30
import {
2✔
31
  NgIconComponent,
32
  provideIcons,
33
  provideNgIconsConfig,
34
} from '@ng-icons/core'
35
import {
2✔
36
  iconoirNavArrowDown,
37
  iconoirNavArrowUp,
38
  iconoirPagePlus,
39
} from '@ng-icons/iconoir'
40

41
const FILTER_OWNER = 'owner'
2✔
42

43
@Component({
44
  selector: 'md-editor-my-records',
45
  templateUrl: './my-records.component.html',
46
  styleUrls: ['./my-records.component.css'],
47
  standalone: true,
48
  imports: [
49
    CommonModule,
50
    TranslateModule,
51
    RecordsListComponent,
52
    UiElementsModule,
53
    RecordsCountComponent,
54
    ButtonComponent,
55
    ImportRecordComponent,
56
    FeatureSearchModule,
57
    SearchHeaderComponent,
58
    SearchFiltersComponent,
59
    NgIconComponent,
60
  ],
61
  providers: [
62
    provideIcons({
63
      iconoirNavArrowDown,
64
      iconoirNavArrowUp,
65
      iconoirPagePlus,
66
    }),
67
    provideNgIconsConfig({
68
      size: '1.5rem',
69
    }),
70
    { provide: FILTER_SUMMARY_IGNORE_LIST, useValue: [FILTER_OWNER] },
71
  ],
72
})
73
export class MyRecordsComponent implements OnInit {
2✔
74
  @ViewChild('importRecordButton', { read: ElementRef })
75
  private importRecordButton!: ElementRef
76
  @ViewChild('template') template!: TemplateRef<any>
77
  private overlayRef!: OverlayRef
78
  searchFields = ['changeDate']
3✔
79
  searchText$: Observable<string | null>
80

81
  isImportMenuOpen = false
3✔
82

83
  constructor(
84
    private router: Router,
3!
85
    protected searchFacade: SearchFacade,
3!
86
    private platformService: PlatformServiceInterface,
3!
87
    private fieldsService: FieldsService,
3!
88
    private overlay: Overlay,
3!
89
    private viewContainerRef: ViewContainerRef,
3!
90
    private cdr: ChangeDetectorRef
3✔
91
  ) {}
92

93
  ngOnInit() {
94
    this.searchFacade.init('myRecords')
3✔
95

96
    this.platformService.getMe().subscribe((user) => {
3✔
97
      this.fieldsService
3✔
98
        .buildFiltersFromFieldValues({ [FILTER_OWNER]: user.id })
99
        .subscribe((filters) => {
100
          this.searchFacade.updateFilters(filters)
3✔
101
        })
102
    })
103

104
    this.searchText$ = this.searchFacade.searchFilters$.pipe(
3✔
105
      map((filters) => ('any' in filters ? (filters['any'] as string) : null))
4!
106
    )
107
  }
108

109
  createRecord() {
UNCOV
110
    this.router.navigate(['/create']).catch((err) => console.error(err))
×
111
  }
112

113
  duplicateExternalRecord() {
UNCOV
114
    this.isImportMenuOpen = true
×
115

UNCOV
116
    const positionStrategy = this.overlay
×
117
      .position()
118
      .flexibleConnectedTo(this.importRecordButton)
119
      .withPositions([
120
        {
121
          originX: 'end',
122
          originY: 'bottom',
123
          overlayX: 'end',
124
          overlayY: 'top',
125
        },
126
      ])
127

UNCOV
128
    this.overlayRef = this.overlay.create({
×
129
      hasBackdrop: true,
130
      backdropClass: 'cdk-overlay-transparent-backdrop',
131
      positionStrategy: positionStrategy,
132
      scrollStrategy: this.overlay.scrollStrategies.reposition(),
133
    })
134

UNCOV
135
    const portal = new TemplatePortal(this.template, this.viewContainerRef)
×
136

137
    this.overlayRef.attach(portal)
×
138

139
    this.overlayRef.backdropClick().subscribe(() => {
×
140
      this.closeImportMenu()
×
141
    })
142
  }
143

144
  closeImportMenu() {
UNCOV
145
    if (this.overlayRef) {
×
UNCOV
146
      this.isImportMenuOpen = false
×
UNCOV
147
      this.overlayRef.dispose()
×
UNCOV
148
      this.cdr.markForCheck()
×
149
    }
150
  }
151
}
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