geonetwork-ui 2.10.0-dev.a9cc01fc7 → 2.10.0-dev.cbf02ead8

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.
Files changed (25) hide show
  1. package/fesm2022/geonetwork-ui.mjs +46 -10
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +16 -11
  4. package/index.d.ts.map +1 -1
  5. package/package.json +1 -1
  6. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-online-single-link-resource/form-field-online-single-link-resource.component.css +0 -0
  7. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-online-single-link-resource/form-field-online-single-link-resource.component.html +5 -0
  8. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-online-single-link-resource/form-field-online-single-link-resource.component.ts +89 -0
  9. package/src/libs/feature/notify-reuse/src/index.ts +1 -0
  10. package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.css +0 -0
  11. package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.html +1 -0
  12. package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.ts +21 -0
  13. package/src/libs/ui/map/src/lib/components/map-container/map-container.component.ts +2 -1
  14. package/src/libs/ui/map/src/lib/components/spatial-extent/spatial-extent.component.ts +11 -10
  15. package/src/libs/util/app-config/src/lib/app-config.ts +36 -0
  16. package/src/libs/util/app-config/src/lib/model.ts +4 -0
  17. package/src/libs/util/app-config/src/lib/parse-utils.ts +23 -1
  18. package/translations/de.json +1 -0
  19. package/translations/en.json +1 -0
  20. package/translations/es.json +1 -0
  21. package/translations/fr.json +1 -0
  22. package/translations/it.json +1 -0
  23. package/translations/nl.json +1 -0
  24. package/translations/pt.json +1 -0
  25. package/translations/sk.json +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonetwork-ui",
3
- "version": "2.10.0-dev.a9cc01fc7",
3
+ "version": "2.10.0-dev.cbf02ead8",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -0,0 +1,5 @@
1
+ <gn-ui-url-input
2
+ [value]="displayUrl"
3
+ [showValidateButton]="false"
4
+ (valueChange)="handleUrlChange($event)"
5
+ ></gn-ui-url-input>
@@ -0,0 +1,89 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ EventEmitter,
5
+ Input,
6
+ Output,
7
+ inject,
8
+ } from '@angular/core'
9
+ import { marker } from '@biesbjerg/ngx-translate-extract-marker'
10
+ import {
11
+ OnlineLinkResource,
12
+ OnlineResource,
13
+ } from '../../../../../../../../../libs/common/domain/src/lib/model/record'
14
+ import { NotificationsService } from '../../../../../../../../../libs/feature/notifications/src'
15
+ import { UrlInputComponent } from '../../../../../../../../../libs/ui/inputs/src'
16
+ import { TranslateService } from '@ngx-translate/core'
17
+
18
+ marker('editor.record.form.field.onlineLinkageResource.defaultName')
19
+
20
+ @Component({
21
+ selector: 'gn-ui-form-field-online-single-link-resource',
22
+ templateUrl: './form-field-online-single-link-resource.component.html',
23
+ styleUrls: ['./form-field-online-single-link-resource.component.css'],
24
+ changeDetection: ChangeDetectionStrategy.OnPush,
25
+ standalone: true,
26
+ imports: [UrlInputComponent],
27
+ })
28
+ export class FormFieldOnlineSingleLinkResourceComponent {
29
+ private notificationsService = inject(NotificationsService)
30
+ private translateService = inject(TranslateService)
31
+
32
+ @Input() set value(onlineResources: Array<OnlineResource>) {
33
+ this.allResources = onlineResources ?? []
34
+ const firstResource = this.allResources[0]
35
+ this.displayUrl = firstResource?.url?.toString() ?? ''
36
+ }
37
+ @Output() valueChange: EventEmitter<Array<OnlineResource>> =
38
+ new EventEmitter()
39
+
40
+ private allResources: OnlineResource[] = []
41
+ displayUrl = ''
42
+
43
+ handleUrlChange(url: string | null) {
44
+ if (!url) return
45
+
46
+ try {
47
+ const parsedUrl = new URL(url)
48
+
49
+ if (this.allResources.length === 0) {
50
+ const defaultName = this.translateService.instant(
51
+ 'editor.record.form.field.onlineLinkageResource.defaultName'
52
+ )
53
+ const newResource: OnlineLinkResource = {
54
+ type: 'link',
55
+ url: parsedUrl,
56
+ name: defaultName,
57
+ }
58
+ this.valueChange.emit([newResource])
59
+ } else {
60
+ const updatedFirst: OnlineResource = {
61
+ ...this.allResources[0],
62
+ url: parsedUrl,
63
+ }
64
+ this.valueChange.emit([updatedFirst, ...this.allResources.slice(1)])
65
+ }
66
+ } catch (error) {
67
+ this.handleError(error as Error)
68
+ }
69
+ }
70
+
71
+ private handleError(error: Error) {
72
+ this.notificationsService.showNotification(
73
+ {
74
+ type: 'error',
75
+ title: this.translateService.instant(
76
+ 'editor.record.onlineResourceError.title'
77
+ ),
78
+ text: `${this.translateService.instant(
79
+ 'editor.record.onlineResourceError.body'
80
+ )} ${error.message}`,
81
+ closeMessage: this.translateService.instant(
82
+ 'editor.record.onlineResourceError.closeMessage'
83
+ ),
84
+ },
85
+ undefined,
86
+ error
87
+ )
88
+ }
89
+ }
@@ -0,0 +1 @@
1
+ export * from './lib/notify-reuse-form/notify-reuse-form.component'
@@ -0,0 +1,21 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ EventEmitter,
5
+ Input,
6
+ Output,
7
+ } from '@angular/core'
8
+ import { ReuseRecord } from '../../../../../../libs/common/domain/src/lib/model/record'
9
+
10
+ @Component({
11
+ selector: 'gn-ui-notify-reuse-form',
12
+ standalone: true,
13
+ imports: [],
14
+ templateUrl: './notify-reuse-form.component.html',
15
+ styleUrl: './notify-reuse-form.component.css',
16
+ changeDetection: ChangeDetectionStrategy.OnPush,
17
+ })
18
+ export class NotifyReuseFormComponent {
19
+ @Input() record: ReuseRecord | null = null
20
+ @Output() recordChange = new EventEmitter<ReuseRecord>()
21
+ }
@@ -204,11 +204,12 @@ export class MapContainerComponent implements AfterViewInit, OnChanges {
204
204
 
205
205
  async ngOnChanges(changes: SimpleChanges) {
206
206
  if ('context' in changes && !changes['context'].isFirstChange()) {
207
+ const olMap = await this.openlayersMap
207
208
  const diff = computeMapContextDiff(
208
209
  this.processContext(changes['context'].currentValue),
209
210
  this.processContext(changes['context'].previousValue)
210
211
  )
211
- await applyContextDiffToMap(this.olMap, diff)
212
+ await applyContextDiffToMap(olMap, diff)
212
213
 
213
214
  if (this._resolvedExtentChange && diff.viewChanges) {
214
215
  this._resolvedExtentChange.emit(this.calculateCurrentMapExtent())
@@ -1,4 +1,4 @@
1
- import { Component, Input } from '@angular/core'
1
+ import { ChangeDetectorRef, Component, inject, Input } from '@angular/core'
2
2
  import { CommonModule } from '@angular/common'
3
3
  import { Geometry } from 'geojson'
4
4
  import { GeoJSONFeatureCollection } from 'ol/format/GeoJSON.js'
@@ -10,8 +10,8 @@ import {
10
10
  MapContextLayer,
11
11
  } from '@geospatial-sdk/core'
12
12
  import { MapContainerComponent } from '../map-container/map-container.component'
13
- import { BehaviorSubject, Observable } from 'rxjs'
14
- import { switchMap } from 'rxjs/operators'
13
+ import { BehaviorSubject, from, Observable, of } from 'rxjs'
14
+ import { map, switchMap, tap } from 'rxjs/operators'
15
15
  import { DatasetSpatialExtent } from '../../../../../../../libs/common/domain/src/lib/model/record'
16
16
 
17
17
  @Component({
@@ -22,14 +22,16 @@ import { DatasetSpatialExtent } from '../../../../../../../libs/common/domain/sr
22
22
  styleUrl: './spatial-extent.component.css',
23
23
  })
24
24
  export class SpatialExtentComponent {
25
+ private _cdr = inject(ChangeDetectorRef)
26
+
25
27
  @Input() set spatialExtents(value: DatasetSpatialExtent[]) {
26
28
  this.spatialExtents$.next(value)
27
29
  }
28
30
  spatialExtents$ = new BehaviorSubject<DatasetSpatialExtent[]>([])
29
31
  mapContext$: Observable<MapContext> = this.spatialExtents$.pipe(
30
- switchMap(async (extents) => {
32
+ switchMap((extents) => {
31
33
  if (extents.length === 0) {
32
- return null // null extent means default view
34
+ return of(null)
33
35
  }
34
36
  const featureCollection: GeoJSONFeatureCollection = {
35
37
  type: 'FeatureCollection',
@@ -61,11 +63,10 @@ export class SpatialExtentComponent {
61
63
  'fill-color': 'rgba(153, 153, 153, 0.3)',
62
64
  },
63
65
  }
64
- const view = await createViewFromLayer(layer)
65
- return {
66
- view,
67
- layers: [layer],
68
- }
66
+ return from(createViewFromLayer(layer)).pipe(
67
+ map((view) => ({ view, layers: [layer] }) as MapContext),
68
+ tap(() => this._cdr.markForCheck())
69
+ )
69
70
  })
70
71
  )
71
72
 
@@ -1,6 +1,7 @@
1
1
  import * as TOML from '@ltd/j-toml'
2
2
  import {
3
3
  checkMetadataLanguage,
4
+ checkNewRecordDefaultLanguage,
4
5
  parseConfigSection,
5
6
  parseMultiConfigSection,
6
7
  parseTranslationsConfigSection,
@@ -8,6 +9,7 @@ import {
8
9
  import {
9
10
  CustomTranslations,
10
11
  CustomTranslationsAllLanguages,
12
+ EditorConfig,
11
13
  GlobalConfig,
12
14
  LayerConfig,
13
15
  MapConfig,
@@ -51,6 +53,12 @@ export function getOptionalSearchConfig(): SearchConfig | null {
51
53
  return searchConfig
52
54
  }
53
55
 
56
+ let editorConfig: EditorConfig = null
57
+
58
+ export function getOptionalEditorConfig(): EditorConfig | null {
59
+ return editorConfig
60
+ }
61
+
54
62
  let metadataQualityConfig: MetadataQualityConfig = null
55
63
  export function getMetadataQualityConfig(): MetadataQualityConfig {
56
64
  return (
@@ -285,6 +293,33 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
285
293
  SORTABLE: parsedMetadataQualitySection.sortable,
286
294
  } as MetadataQualityConfig)
287
295
 
296
+ let parsedEditingSection = parseConfigSection(
297
+ parsed,
298
+ 'editing',
299
+ [],
300
+ ['new_record_default_language'],
301
+ warnings,
302
+ errors
303
+ )
304
+ if (
305
+ parsedEditingSection !== null &&
306
+ parsedEditingSection.new_record_default_language !== undefined
307
+ ) {
308
+ parsedEditingSection = checkNewRecordDefaultLanguage(
309
+ parsedEditingSection,
310
+ warnings
311
+ )
312
+ }
313
+ editorConfig =
314
+ parsedEditingSection === null
315
+ ? null
316
+ : ({
317
+ NEW_RECORD_DEFAULT_LANGUAGE:
318
+ parsedEditingSection.new_record_default_language as
319
+ | string
320
+ | undefined,
321
+ } as EditorConfig)
322
+
288
323
  customTranslations = parseTranslationsConfigSection(
289
324
  parsed,
290
325
  'translations'
@@ -309,6 +344,7 @@ export function isConfigLoaded() {
309
344
  export function _reset() {
310
345
  globalConfig = null
311
346
  themeConfig = null
347
+ editorConfig = null
312
348
  customTranslations = null
313
349
  }
314
350
 
@@ -69,6 +69,10 @@ export interface MetadataQualityConfig {
69
69
  ENABLED: boolean
70
70
  }
71
71
 
72
+ export interface EditorConfig {
73
+ NEW_RECORD_DEFAULT_LANGUAGE?: string
74
+ }
75
+
72
76
  export type CustomTranslations = { [translationKey: string]: string }
73
77
  export type CustomTranslationsAllLanguages = {
74
78
  [lang: string]: CustomTranslations
@@ -1,4 +1,4 @@
1
- import { toLang2 } from '../../../../../libs/util/i18n/src'
1
+ import { LANG_2_TO_3_MAPPER, toLang2 } from '../../../../../libs/util/i18n/src'
2
2
 
3
3
  const flatten = (
4
4
  base: string,
@@ -137,3 +137,25 @@ export function checkMetadataLanguage(
137
137
  }
138
138
  return parsedConfigSection
139
139
  }
140
+
141
+ export function checkNewRecordDefaultLanguage(
142
+ parsedConfigSection: any,
143
+ outWarnings: string[]
144
+ ) {
145
+ const lang2 = toLang2(
146
+ parsedConfigSection.new_record_default_language.toLowerCase()
147
+ )
148
+ if (!(lang2 in LANG_2_TO_3_MAPPER)) {
149
+ outWarnings.push(
150
+ `In the [editing] section: new_record_default_language = "${parsedConfigSection.new_record_default_language}" is not a recognized ISO 639 language code`
151
+ )
152
+ return {
153
+ ...parsedConfigSection,
154
+ new_record_default_language: undefined,
155
+ }
156
+ }
157
+ return {
158
+ ...parsedConfigSection,
159
+ new_record_default_language: lang2,
160
+ }
161
+ }
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "Rechtliche Einschränkung",
160
160
  "editor.record.form.field.license": "Lizenz",
161
161
  "editor.record.form.field.onlineLinkResources": "Beigefügte Ressourcen",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "Link",
162
163
  "editor.record.form.field.onlineResource.cancel": "Abbrechen",
163
164
  "editor.record.form.field.onlineResource.confirm": "Bestätigen",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "Vorschau des Datensatzes bearbeiten",
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "Legal constraint",
160
160
  "editor.record.form.field.license": "License",
161
161
  "editor.record.form.field.onlineLinkResources": "Attached resources",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "Link",
162
163
  "editor.record.form.field.onlineResource.cancel": "Cancel",
163
164
  "editor.record.form.field.onlineResource.confirm": "Confirm",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "Modify the dataset preview",
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "",
160
160
  "editor.record.form.field.license": "",
161
161
  "editor.record.form.field.onlineLinkResources": "",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "",
162
163
  "editor.record.form.field.onlineResource.cancel": "",
163
164
  "editor.record.form.field.onlineResource.confirm": "",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "",
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "Contrainte légale",
160
160
  "editor.record.form.field.license": "Licence",
161
161
  "editor.record.form.field.onlineLinkResources": "Ressources attachées",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "Lien",
162
163
  "editor.record.form.field.onlineResource.cancel": "Annuler",
163
164
  "editor.record.form.field.onlineResource.confirm": "Valider",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "Modifier l'aperçu du jeu de données",
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "Vincolo legale",
160
160
  "editor.record.form.field.license": "Licenza",
161
161
  "editor.record.form.field.onlineLinkResources": "Risorse allegate",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "Link",
162
163
  "editor.record.form.field.onlineResource.cancel": "Annulla",
163
164
  "editor.record.form.field.onlineResource.confirm": "Convalida",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "Modifica anteprima dataset",
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "",
160
160
  "editor.record.form.field.license": "",
161
161
  "editor.record.form.field.onlineLinkResources": "",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "",
162
163
  "editor.record.form.field.onlineResource.cancel": "",
163
164
  "editor.record.form.field.onlineResource.confirm": "",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "",
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "",
160
160
  "editor.record.form.field.license": "",
161
161
  "editor.record.form.field.onlineLinkResources": "",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "",
162
163
  "editor.record.form.field.onlineResource.cancel": "",
163
164
  "editor.record.form.field.onlineResource.confirm": "",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "",
@@ -159,6 +159,7 @@
159
159
  "editor.record.form.field.legalConstraints": "",
160
160
  "editor.record.form.field.license": "Licencia",
161
161
  "editor.record.form.field.onlineLinkResources": "",
162
+ "editor.record.form.field.onlineLinkageResource.defaultName": "",
162
163
  "editor.record.form.field.onlineResource.cancel": "",
163
164
  "editor.record.form.field.onlineResource.confirm": "",
164
165
  "editor.record.form.field.onlineResource.dialogTitle": "",