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

geonetwork / geonetwork-ui / 12417033329

19 Dec 2024 04:44PM UTC coverage: 84.621% (-1.2%) from 85.834%
12417033329

Pull #1069

github

web-flow
Merge 692832e0a into 23c6e8257
Pull Request #1069: [Datahub] Added dynamic legend generation based on map context

3401 of 4499 branches covered (75.59%)

Branch coverage included in aggregate %.

19 of 21 new or added lines in 3 files covered. (90.48%)

8 existing lines in 2 files now uncovered.

9640 of 10912 relevant lines covered (88.34%)

283.13 hits per line

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

76.83
/apps/metadata-editor/src/app/edit/edit-page.component.ts
1
import { CommonModule } from '@angular/common'
3✔
2
import {
3✔
3
  Component,
4
  ElementRef,
5
  OnDestroy,
6
  OnInit,
7
  ViewChild,
8
} from '@angular/core'
9
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'
3✔
10
import { ActivatedRoute, Router } from '@angular/router'
3✔
11
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
3✔
12
import { PublicationVersionError } from '@geonetwork-ui/common/domain/model/error'
3✔
13
import {
3✔
14
  EditorFacade,
15
  RecordFormComponent,
16
} from '@geonetwork-ui/feature/editor'
17
import {
3✔
18
  NotificationsContainerComponent,
19
  NotificationsService,
20
} from '@geonetwork-ui/feature/notifications'
21
import { ButtonComponent } from '@geonetwork-ui/ui/inputs'
3✔
22
import { TranslateModule, TranslateService } from '@ngx-translate/core'
3✔
23
import { combineLatest, filter, firstValueFrom, Subscription, take } from 'rxjs'
3✔
24
import { map } from 'rxjs/operators'
3✔
25
import { SidebarComponent } from '../dashboard/sidebar/sidebar.component'
3✔
26
import { PageSelectorComponent } from './components/page-selector/page-selector.component'
3✔
27
import { TopToolbarComponent } from './components/top-toolbar/top-toolbar.component'
3✔
28

29
marker('editor.record.form.bottomButtons.comeBackLater')
3✔
30
marker('editor.record.form.bottomButtons.previous')
3✔
31
marker('editor.record.form.bottomButtons.next')
3✔
32

33
@Component({
34
  selector: 'md-editor-edit',
35
  templateUrl: './edit-page.component.html',
36
  styleUrls: ['./edit-page.component.css'],
37
  standalone: true,
38
  imports: [
39
    RecordFormComponent,
40
    CommonModule,
41
    ButtonComponent,
42
    MatProgressSpinnerModule,
43
    TopToolbarComponent,
44
    NotificationsContainerComponent,
45
    PageSelectorComponent,
46
    TranslateModule,
47
    SidebarComponent,
48
  ],
49
})
50
export class EditPageComponent implements OnInit, OnDestroy {
3✔
51
  subscription = new Subscription()
12✔
52

53
  currentPage$ = this.facade.currentPage$
12✔
54
  pagesLength$ = this.facade.editorConfig$.pipe(
12✔
55
    map((config) => config.pages.length)
10✔
56
  )
57
  isLastPage$ = combineLatest([this.currentPage$, this.pagesLength$]).pipe(
12✔
58
    map(([currentPage, pagesCount]) => currentPage >= pagesCount - 1)
10✔
59
  )
60

61
  @ViewChild('scrollContainer') scrollContainer: ElementRef<HTMLElement>
62

63
  constructor(
64
    private route: ActivatedRoute,
12!
65
    private facade: EditorFacade,
12!
66
    private notificationsService: NotificationsService,
12!
67
    private translateService: TranslateService,
12!
68
    private router: Router
12✔
69
  ) {}
70

71
  ngOnInit(): void {
72
    const [currentRecord, currentRecordSource, currentRecordAlreadySaved] =
73
      this.route.snapshot.data['record']
10✔
74

75
    this.facade.openRecord(
10✔
76
      currentRecord,
77
      currentRecordSource,
78
      currentRecordAlreadySaved
79
    )
80

81
    this.subscription.add(
10✔
82
      this.facade.saveError$.subscribe((error) => {
83
        if (error instanceof PublicationVersionError) {
2✔
84
          this.notificationsService.showNotification(
1✔
85
            {
86
              type: 'error',
87
              title: this.translateService.instant(
88
                'editor.record.publishVersionError.title'
89
              ),
90
              text: this.translateService.instant(
91
                'editor.record.publishVersionError.body',
92
                { currentVersion: error.detectedApiVersion }
93
              ),
94
              closeMessage: this.translateService.instant(
95
                'editor.record.publishVersionError.closeMessage'
96
              ),
97
            },
98
            undefined,
99
            error
100
          )
101
        } else {
102
          this.notificationsService.showNotification(
1✔
103
            {
104
              type: 'error',
105
              title: this.translateService.instant(
106
                'editor.record.publishError.title'
107
              ),
108
              text: `${this.translateService.instant(
109
                'editor.record.publishError.body'
110
              )} ${error.message}`,
111
              closeMessage: this.translateService.instant(
112
                'editor.record.publishError.closeMessage'
113
              ),
114
            },
115
            undefined,
116
            error
117
          )
118
        }
119
      })
120
    )
121

122
    this.subscription.add(
10✔
123
      this.facade.saveSuccess$.subscribe(() => {
124
        this.notificationsService.showNotification(
1✔
125
          {
126
            type: 'success',
127
            title: this.translateService.instant(
128
              'editor.record.publishSuccess.title'
129
            ),
130
            text: `${this.translateService.instant(
131
              'editor.record.publishSuccess.body'
132
            )}`,
133
          },
134
          2500
135
        )
136
      })
137
    )
138

139
    // if we're on the /create route, go to /edit/{uuid} on first change
140
    if (this.route.snapshot.routeConfig?.path.includes('create')) {
10✔
141
      this.subscription.add(
3✔
142
        this.facade.draftSaveSuccess$.pipe(take(1)).subscribe(() => {
143
          this.router.navigate(['edit', currentRecord.uniqueIdentifier], {
1✔
144
            replaceUrl: true,
145
          })
146
        })
147
      )
148
    }
149

150
    // if the record unique identifier changes, navigate to /edit/newUuid
151
    this.subscription.add(
10✔
152
      this.facade.record$
153
        .pipe(
154
          filter(
155
            (record) =>
156
              record?.uniqueIdentifier !== currentRecord.uniqueIdentifier
11✔
157
          ),
158
          take(1)
159
        )
160
        .subscribe((savedRecord) => {
161
          this.router.navigate(['edit', savedRecord.uniqueIdentifier])
1✔
162
        })
163
    )
164
  }
165

166
  ngOnDestroy() {
167
    this.subscription.unsubscribe()
12✔
168
  }
169

170
  async previousPageButtonHandler() {
171
    const currentPage = await firstValueFrom(this.currentPage$)
×
172
    if (currentPage === 0) {
×
173
      this.router.navigate(['catalog', 'search'])
×
174
    } else {
175
      this.facade.setCurrentPage(currentPage - 1)
×
UNCOV
176
      this.scrollToTop()
×
177
    }
178
  }
179

180
  async nextPageButtonHandler() {
UNCOV
181
    const currentPage = await firstValueFrom(this.currentPage$)
×
UNCOV
182
    const pagesCount = await firstValueFrom(this.pagesLength$)
×
UNCOV
183
    if (currentPage < pagesCount - 1) {
×
UNCOV
184
      this.facade.setCurrentPage(currentPage + 1)
×
UNCOV
185
      this.scrollToTop()
×
186
    }
187
  }
188

189
  private scrollToTop() {
UNCOV
190
    this.scrollContainer.nativeElement.scroll({
×
191
      behavior: 'instant',
192
      top: 0,
193
    })
194
  }
195
}
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