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

geonetwork / geonetwork-ui / 12471273633

23 Dec 2024 06:26PM UTC coverage: 84.204% (-0.4%) from 84.621%
12471273633

Pull #1051

github

web-flow
Merge 183a90b40 into 8c98ae01e
Pull Request #1051: [Editor]: Warn user if draft has been updated

3248 of 4338 branches covered (74.87%)

Branch coverage included in aggregate %.

69 of 73 new or added lines in 10 files covered. (94.52%)

11 existing lines in 2 files now uncovered.

9253 of 10508 relevant lines covered (88.06%)

199.09 hits per line

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

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

36
@Component({
37
  selector: 'md-editor-all-records',
38
  templateUrl: './all-records.component.html',
39
  styleUrls: ['./all-records.component.css'],
40
  standalone: true,
41
  imports: [
42
    CommonModule,
43
    TranslateModule,
44
    RecordsCountComponent,
45
    UiElementsModule,
46
    UiInputsModule,
47
    ImportRecordComponent,
48
    CdkOverlayOrigin,
49
    RecordsListComponent,
50
    SearchFiltersComponent,
51
    NgIconComponent,
52
  ],
53
  providers: [
54
    provideIcons({
55
      iconoirNavArrowDown,
56
      iconoirNavArrowUp,
57
      iconoirPagePlus,
58
    }),
59
    provideNgIconsConfig({
60
      size: '1.5rem',
61
    }),
62
  ],
63
})
64
export class AllRecordsComponent implements OnInit, OnDestroy {
2✔
65
  @ViewChild('importRecordButton', { read: ElementRef })
66
  importRecordButton!: ElementRef
67
  @ViewChild('template') template!: TemplateRef<any>
68
  private overlayRef!: OverlayRef
69
  searchFields = ['user', 'changeDate']
10✔
70
  searchText$: Observable<string | null>
71
  subscription: Subscription
72

73
  isImportMenuOpen = false
10✔
74

75
  constructor(
76
    private router: Router,
10!
77
    public searchFacade: SearchFacade,
10!
78
    public searchService: SearchService,
10!
79
    private overlay: Overlay,
10!
80
    private viewContainerRef: ViewContainerRef,
10!
81
    private cdr: ChangeDetectorRef
10✔
82
  ) {}
83

84
  ngOnInit() {
85
    this.subscription = this.searchFacade.searchFilters$
10✔
86
      .pipe(
87
        map((filters) => {
88
          if ('owner' in filters) {
10✔
89
            const { owner, ...rest } = filters
10✔
90
            return rest
10✔
91
          }
UNCOV
92
          return filters
×
93
        }),
94
        take(1)
95
      )
96
      .subscribe((filters) => {
97
        this.searchService.setFilters(filters)
10✔
98
      })
99
    this.searchText$ = this.searchFacade.searchFilters$.pipe(
10✔
100
      map((filters) => ('any' in filters ? (filters['any'] as string) : null))
16!
101
    )
102
  }
103

104
  ngOnDestroy() {
105
    this.searchFacade.updateFilters({ any: '' })
11✔
106
    this.subscription.unsubscribe()
11✔
107
  }
108

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

113
  duplicateExternalRecord() {
114
    this.isImportMenuOpen = true
1✔
115

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

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

135
    const portal = new TemplatePortal(this.template, this.viewContainerRef)
1✔
136

137
    this.overlayRef.attach(portal)
1✔
138

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

144
  closeImportMenu() {
145
    if (this.overlayRef) {
2✔
146
      this.isImportMenuOpen = false
2✔
147
      this.overlayRef.dispose()
2✔
148
      this.cdr.markForCheck()
2✔
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

© 2026 Coveralls, Inc