geonetwork-ui 2.11.0-dev.cf22e64cf → 2.11.0-dev.d02d7f3f8

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 (72) hide show
  1. package/fesm2022/geonetwork-ui.mjs +817 -302
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +177 -46
  4. package/index.d.ts.map +1 -1
  5. package/package.json +6 -5
  6. package/src/libs/api/metadata-converter/src/lib/dcat-ap/dcat-ap.converter.ts +2 -0
  7. package/src/libs/api/metadata-converter/src/lib/fixtures/mel.records.dataset+featurecatalog.ts +395 -0
  8. package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +35 -8
  9. package/src/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +19 -0
  10. package/src/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts +17 -6
  11. package/src/libs/api/metadata-converter/src/lib/iso19115-3/read-parts.ts +110 -0
  12. package/src/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts +131 -0
  13. package/src/libs/api/metadata-converter/src/lib/iso19139/iso19139.converter.ts +9 -0
  14. package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +2 -1
  15. package/src/libs/api/repository/src/lib/gn4/elasticsearch/constant.ts +4 -0
  16. package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +57 -24
  17. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +82 -35
  18. package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
  19. package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
  20. package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
  21. package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +14 -18
  22. package/src/libs/common/domain/src/lib/model/search/aggregation.model.ts +2 -0
  23. package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
  24. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +20 -1
  25. package/src/libs/common/fixtures/src/lib/records.fixtures.ts +42 -62
  26. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +32 -19
  27. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
  28. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
  29. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.css +0 -0
  30. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
  31. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
  32. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
  33. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
  34. package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
  35. package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
  36. package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
  37. package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
  38. package/src/libs/feature/record/src/lib/state/mdview.effects.ts +3 -1
  39. package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -1
  40. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +7 -1
  41. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +18 -1
  42. package/src/libs/feature/search/src/lib/geocoding/geocoding.service.ts +41 -2
  43. package/src/libs/feature/search/src/lib/location-search/location-search.component.html +11 -1
  44. package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +77 -3
  45. package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +50 -4
  46. package/src/libs/feature/search/src/lib/utils/service/fields.ts +35 -10
  47. package/src/libs/ui/elements/src/lib/kind-badge/kind-badge.component.html +5 -1
  48. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.html +3 -3
  49. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.ts +2 -2
  50. package/src/libs/ui/elements/src/lib/thumbnail/thumbnail.component.html +1 -1
  51. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.css +0 -4
  52. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +2 -2
  53. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +3 -3
  54. package/src/libs/ui/inputs/src/lib/inline-filter/inline-filter.component.html +6 -11
  55. package/src/libs/ui/inputs/src/lib/search-feature-catalog/search-feature-catalog.component.ts +2 -1
  56. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +7 -1
  57. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +26 -3
  58. package/src/libs/ui/search/src/lib/results-hits-number/results-hits-number.component.html +1 -0
  59. package/src/libs/util/app-config/src/index.ts +1 -0
  60. package/src/libs/util/app-config/src/lib/app-config.ts +338 -270
  61. package/src/libs/util/app-config/src/lib/fixtures.ts +21 -0
  62. package/src/libs/util/app-config/src/lib/model.ts +30 -3
  63. package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
  64. package/src/libs/util/shared/src/lib/utils/geojson.ts +21 -10
  65. package/translations/de.json +10 -2
  66. package/translations/en.json +10 -2
  67. package/translations/es.json +10 -2
  68. package/translations/fr.json +11 -3
  69. package/translations/it.json +10 -2
  70. package/translations/nl.json +10 -2
  71. package/translations/pt.json +10 -2
  72. package/translations/sk.json +10 -2
@@ -8,6 +8,9 @@ import {
8
8
  parseTranslationsConfigSection,
9
9
  } from './parse-utils'
10
10
  import {
11
+ AppConfig,
12
+ ConfigIssues,
13
+ ConfigSectionName,
11
14
  CustomTranslations,
12
15
  CustomTranslationsAllLanguages,
13
16
  EditorConfig,
@@ -84,7 +87,319 @@ export function getCustomTranslations(langCode: string): CustomTranslations {
84
87
 
85
88
  let appConfigLoaded = false
86
89
 
87
- export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
90
+ function parseGlobalSection(
91
+ parsed: Record<string, unknown>,
92
+ { warnings, errors }: ConfigIssues
93
+ ): GlobalConfig | null {
94
+ let parsedGlobalSection = parseConfigSection(
95
+ parsed,
96
+ 'global',
97
+ ['geonetwork4_api_url'],
98
+ [
99
+ 'datahub_url',
100
+ 'edit_url_template',
101
+ 'proxy_path',
102
+ 'metadata_language',
103
+ 'login_url',
104
+ 'logout_url',
105
+ 'settings_url',
106
+ 'web_component_embedder_url',
107
+ 'languages',
108
+ 'contact_email',
109
+ 'reuse_form_url',
110
+ ],
111
+ warnings,
112
+ errors
113
+ )
114
+ if (parsedGlobalSection?.metadata_language) {
115
+ parsedGlobalSection = checkMetadataLanguage(parsedGlobalSection, warnings)
116
+ }
117
+ return parsedGlobalSection === null
118
+ ? null
119
+ : ({
120
+ GN4_API_URL: parsedGlobalSection.geonetwork4_api_url,
121
+ DATAHUB_URL: parsedGlobalSection.datahub_url,
122
+ EDIT_URL_TEMPLATE: parsedGlobalSection.edit_url_template,
123
+ PROXY_PATH: parsedGlobalSection.proxy_path,
124
+ METADATA_LANGUAGE: parsedGlobalSection.metadata_language
125
+ ? (parsedGlobalSection.metadata_language as string).toLowerCase()
126
+ : undefined,
127
+ LOGIN_URL: parsedGlobalSection.login_url,
128
+ LOGOUT_URL: parsedGlobalSection.logout_url,
129
+ SETTINGS_URL: parsedGlobalSection.settings_url,
130
+ WEB_COMPONENT_EMBEDDER_URL:
131
+ parsedGlobalSection.web_component_embedder_url,
132
+ LANGUAGES: parsedGlobalSection.languages,
133
+ CONTACT_EMAIL: parsedGlobalSection.contact_email,
134
+ REUSE_FORM_URL: parsedGlobalSection.reuse_form_url,
135
+ } as GlobalConfig)
136
+ }
137
+
138
+ function parseMapSection(
139
+ parsed: Record<string, unknown>,
140
+ { warnings, errors }: ConfigIssues
141
+ ): MapConfig | null {
142
+ const parsedLayersSections = parseMultiConfigSection(
143
+ parsed,
144
+ 'map_layer',
145
+ ['type'],
146
+ ['name', 'url', 'data', 'styleUrl', 'accessToken'],
147
+ warnings,
148
+ errors
149
+ )
150
+ const parsedMapSection = parseConfigSection(
151
+ parsed,
152
+ 'map',
153
+ [],
154
+ [
155
+ 'max_zoom',
156
+ 'do_not_tile_wms',
157
+ 'max_extent',
158
+ 'max_feature_count',
159
+ 'baselayer',
160
+ 'do_not_use_default_basemap',
161
+ 'external_viewer_url_template',
162
+ 'external_viewer_open_new_tab',
163
+ ],
164
+ warnings,
165
+ errors
166
+ )
167
+ return parsedMapSection === null || parsedLayersSections === null
168
+ ? null
169
+ : ({
170
+ MAX_ZOOM: parsedMapSection.max_zoom,
171
+ DO_NOT_TILE_WMS: parsedMapSection.do_not_tile_wms,
172
+ MAX_EXTENT: parsedMapSection.max_extent,
173
+ MAX_FEATURE_COUNT: parsedMapSection.max_feature_count,
174
+ EXTERNAL_VIEWER_URL_TEMPLATE:
175
+ parsedMapSection.external_viewer_url_template,
176
+ EXTERNAL_VIEWER_OPEN_NEW_TAB:
177
+ parsedMapSection.external_viewer_open_new_tab,
178
+ DO_NOT_USE_DEFAULT_BASEMAP:
179
+ !!parsedMapSection.do_not_use_default_basemap,
180
+ MAP_LAYERS: parsedLayersSections.map(
181
+ (map_layer) =>
182
+ ({
183
+ TYPE: map_layer.type,
184
+ URL: map_layer.url,
185
+ NAME: map_layer.name,
186
+ DATA: map_layer.data,
187
+ STYLE_URL: map_layer.styleUrl,
188
+ ACCESS_TOKEN: map_layer.accessToken,
189
+ }) as LayerConfig
190
+ ),
191
+ } as MapConfig)
192
+ }
193
+
194
+ function parseThemeSection(
195
+ parsed: Record<string, unknown>,
196
+ { warnings, errors }: ConfigIssues
197
+ ): ThemeConfig | null {
198
+ const parsedThemeSection = parseConfigSection(
199
+ parsed,
200
+ 'theme',
201
+ ['primary_color', 'secondary_color', 'main_color', 'background_color'],
202
+ [
203
+ 'header_foreground_color',
204
+ 'main_font',
205
+ 'title_font',
206
+ 'fonts_stylesheet_url',
207
+ 'thumbnail_placeholder',
208
+ 'header_background',
209
+ 'favicon',
210
+ ],
211
+ warnings,
212
+ errors
213
+ )
214
+ return parsedThemeSection === null
215
+ ? null
216
+ : ({
217
+ PRIMARY_COLOR: parsedThemeSection.primary_color,
218
+ SECONDARY_COLOR: parsedThemeSection.secondary_color,
219
+ MAIN_COLOR: parsedThemeSection.main_color,
220
+ BACKGROUND_COLOR: parsedThemeSection.background_color,
221
+ HEADER_FOREGROUND_COLOR: parsedThemeSection.header_foreground_color,
222
+ THUMBNAIL_PLACEHOLDER: parsedThemeSection.thumbnail_placeholder,
223
+ HEADER_BACKGROUND: parsedThemeSection.header_background,
224
+ TITLE_FONT: parsedThemeSection.title_font,
225
+ MAIN_FONT: parsedThemeSection.main_font,
226
+ FONTS_STYLESHEET_URL: parsedThemeSection.fonts_stylesheet_url,
227
+ FAVICON: parsedThemeSection.favicon,
228
+ } as ThemeConfig)
229
+ }
230
+
231
+ function parseSearchSection(
232
+ parsed: Record<string, unknown>,
233
+ { warnings, errors }: ConfigIssues
234
+ ): SearchConfig | null {
235
+ const parsedSearchSection = parseConfigSection(
236
+ parsed,
237
+ 'search',
238
+ [],
239
+ [
240
+ 'record_kind_quick_filter',
241
+ 'filter_geometry_data',
242
+ 'filter_geometry_url',
243
+ 'do_not_use_default_search_preset',
244
+ 'search_preset',
245
+ 'advanced_filters',
246
+ 'limit',
247
+ 'spatial_extent_max_file_size',
248
+ 'geocoding_provider',
249
+ 'geocoding_provider_options',
250
+ 'geocoding_provider_labels',
251
+ ],
252
+ warnings,
253
+ errors
254
+ )
255
+ const parsedSearchParams = parseMultiConfigSection(
256
+ parsed,
257
+ 'search_preset',
258
+ ['name'],
259
+ ['sort', 'filters'],
260
+ warnings,
261
+ errors
262
+ )
263
+ const parsedCustomFilters = parseMultiConfigSection(
264
+ parsed,
265
+ 'custom_filter',
266
+ ['name', 'base_filter'],
267
+ ['exclude_values', 'include_values', 'label_key'],
268
+ warnings,
269
+ errors
270
+ )
271
+ const parsedGeocodingProviderLabels =
272
+ parsedSearchSection?.geocoding_provider_labels as
273
+ | Record<string, string>
274
+ | undefined
275
+ return parsedSearchSection === null
276
+ ? null
277
+ : ({
278
+ RECORD_KIND_QUICK_FILTER: parsedSearchSection.record_kind_quick_filter,
279
+ FILTER_GEOMETRY_DATA: parsedSearchSection.filter_geometry_data,
280
+ FILTER_GEOMETRY_URL: parsedSearchSection.filter_geometry_url,
281
+ DO_NOT_USE_DEFAULT_SEARCH_PRESET:
282
+ !!parsedSearchSection.do_not_use_default_search_preset,
283
+ SEARCH_PRESET: parsedSearchParams.map((param) => ({
284
+ sort: param.sort,
285
+ name: param.name,
286
+ filters: param.filters,
287
+ })),
288
+ ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
289
+ CUSTOM_FILTERS: (parsedCustomFilters ?? []).map((customFilter) => ({
290
+ name: customFilter.name,
291
+ baseFilter: customFilter.base_filter,
292
+ excludeValues: customFilter.exclude_values,
293
+ includeValues: customFilter.include_values,
294
+ labelKey: customFilter.label_key,
295
+ })),
296
+ LIMIT: parsedSearchSection.limit,
297
+ SPATIAL_EXTENT_MAX_FILE_SIZE:
298
+ parsedSearchSection.spatial_extent_max_file_size,
299
+ GEOCODING_PROVIDER: parsedSearchSection.geocoding_provider,
300
+ GEOCODING_PROVIDER_OPTIONS:
301
+ parsedSearchSection.geocoding_provider_options,
302
+ GEOCODING_PROVIDER_LABELS: parsedGeocodingProviderLabels
303
+ ? {
304
+ MAIN: parsedGeocodingProviderLabels.main,
305
+ SECONDARY: parsedGeocodingProviderLabels.secondary,
306
+ TERTIARY: parsedGeocodingProviderLabels.tertiary,
307
+ }
308
+ : undefined,
309
+ } as SearchConfig)
310
+ }
311
+
312
+ function parseMetadataQualitySection(
313
+ parsed: Record<string, unknown>,
314
+ { warnings, errors }: ConfigIssues
315
+ ): MetadataQualityConfig | null {
316
+ const parsedMetadataQualitySection = parseConfigSection(
317
+ parsed,
318
+ 'metadata-quality',
319
+ [],
320
+ ['enabled'],
321
+ warnings,
322
+ errors
323
+ )
324
+ return parsedMetadataQualitySection === null
325
+ ? null
326
+ : ({
327
+ ENABLED: parsedMetadataQualitySection.enabled,
328
+ SORTABLE: parsedMetadataQualitySection.sortable,
329
+ } as MetadataQualityConfig)
330
+ }
331
+
332
+ function parseEditingSection(
333
+ parsed: Record<string, unknown>,
334
+ { warnings, errors }: ConfigIssues
335
+ ): EditorConfig | null {
336
+ let parsedEditingSection = parseConfigSection(
337
+ parsed,
338
+ 'editing',
339
+ [],
340
+ ['new_record_default_language', 'new_record_standard'],
341
+ warnings,
342
+ errors
343
+ )
344
+ if (
345
+ parsedEditingSection !== null &&
346
+ parsedEditingSection.new_record_default_language !== undefined
347
+ ) {
348
+ parsedEditingSection = checkNewRecordDefaultLanguage(
349
+ parsedEditingSection,
350
+ warnings
351
+ )
352
+ }
353
+ if (
354
+ parsedEditingSection !== null &&
355
+ parsedEditingSection.new_record_standard !== undefined
356
+ ) {
357
+ parsedEditingSection = checkNewRecordStandard(
358
+ parsedEditingSection,
359
+ warnings
360
+ )
361
+ }
362
+ return parsedEditingSection === null
363
+ ? null
364
+ : ({
365
+ NEW_RECORD_DEFAULT_LANGUAGE:
366
+ parsedEditingSection.new_record_default_language as
367
+ | string
368
+ | undefined,
369
+ NEW_RECORD_STANDARD: parsedEditingSection.new_record_standard as
370
+ | EditorConfig['NEW_RECORD_STANDARD']
371
+ | undefined,
372
+ } as EditorConfig)
373
+ }
374
+
375
+ const SECTION_PARSERS: {
376
+ [name in ConfigSectionName]: (
377
+ parsed: Record<string, unknown>,
378
+ issues: ConfigIssues
379
+ ) => AppConfig[name]
380
+ } = {
381
+ global: parseGlobalSection,
382
+ map: parseMapSection,
383
+ theme: parseThemeSection,
384
+ search: parseSearchSection,
385
+ metadataQuality: parseMetadataQualitySection,
386
+ editor: parseEditingSection,
387
+ translations: (parsed) =>
388
+ parseTranslationsConfigSection(
389
+ parsed,
390
+ 'translations'
391
+ ) as CustomTranslationsAllLanguages,
392
+ }
393
+
394
+ /**
395
+ * Loads the configuration file and stores the given sections (all by default);
396
+ * omitted sections are reset (their getters will throw or return null);
397
+ * resolves with the parsed configuration file, e.g. to read sections with a custom parser
398
+ */
399
+ export function loadAppConfig(
400
+ configUrl = 'assets/configuration/default.toml',
401
+ sections = Object.keys(SECTION_PARSERS) as ConfigSectionName[]
402
+ ): Promise<Record<string, unknown>> {
88
403
  console.log(
89
404
  `[geonetwork-ui] Loading application configuration from ${configUrl}`
90
405
  )
@@ -94,287 +409,36 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
94
409
  return resp.text()
95
410
  })
96
411
  .then((conf) => {
97
- let parsed
412
+ let parsed: Record<string, unknown>
98
413
  try {
99
- parsed = TOML.parse(conf, { joiner: '\n', bigint: false }) as any
414
+ parsed = TOML.parse(conf, { joiner: '\n', bigint: false })
100
415
  } catch (e: any) {
101
416
  throw new Error(
102
417
  `An error occurred when parsing the configuration file: ${e.message}`
103
418
  )
104
419
  }
105
- const errors = []
106
- const warnings = []
107
-
108
- let parsedGlobalSection = parseConfigSection(
109
- parsed,
110
- 'global',
111
- ['geonetwork4_api_url'],
112
- [
113
- 'datahub_url',
114
- 'edit_url_template',
115
- 'proxy_path',
116
- 'metadata_language',
117
- 'login_url',
118
- 'logout_url',
119
- 'settings_url',
120
- 'web_component_embedder_url',
121
- 'languages',
122
- 'contact_email',
123
- 'reuse_form_url',
124
- ],
125
- warnings,
126
- errors
127
- )
128
- if (parsedGlobalSection?.metadata_language) {
129
- parsedGlobalSection = checkMetadataLanguage(
130
- parsedGlobalSection,
131
- warnings
132
- )
133
- }
134
- globalConfig =
135
- parsedGlobalSection === null
136
- ? null
137
- : ({
138
- GN4_API_URL: parsedGlobalSection.geonetwork4_api_url,
139
- DATAHUB_URL: parsedGlobalSection.datahub_url,
140
- EDIT_URL_TEMPLATE: parsedGlobalSection.edit_url_template,
141
- PROXY_PATH: parsedGlobalSection.proxy_path,
142
- METADATA_LANGUAGE: parsedGlobalSection.metadata_language
143
- ? (
144
- parsedGlobalSection.metadata_language as string
145
- ).toLowerCase()
146
- : undefined,
147
- LOGIN_URL: parsedGlobalSection.login_url,
148
- LOGOUT_URL: parsedGlobalSection.logout_url,
149
- SETTINGS_URL: parsedGlobalSection.settings_url,
150
- WEB_COMPONENT_EMBEDDER_URL:
151
- parsedGlobalSection.web_component_embedder_url,
152
- LANGUAGES: parsedGlobalSection.languages,
153
- CONTACT_EMAIL: parsedGlobalSection.contact_email,
154
- REUSE_FORM_URL: parsedGlobalSection.reuse_form_url,
155
- } as GlobalConfig)
156
-
157
- const parsedLayersSections = parseMultiConfigSection(
158
- parsed,
159
- 'map_layer',
160
- ['type'],
161
- ['name', 'url', 'data', 'styleUrl', 'accessToken'],
162
- warnings,
163
- errors
164
- )
165
- const parsedMapSection = parseConfigSection(
166
- parsed,
167
- 'map',
168
- [],
169
- [
170
- 'max_zoom',
171
- 'do_not_tile_wms',
172
- 'max_extent',
173
- 'max_feature_count',
174
- 'baselayer',
175
- 'do_not_use_default_basemap',
176
- 'external_viewer_url_template',
177
- 'external_viewer_open_new_tab',
178
- ],
179
- warnings,
180
- errors
181
- )
182
- mapConfig =
183
- parsedMapSection === null || parsedLayersSections === null
184
- ? null
185
- : ({
186
- MAX_ZOOM: parsedMapSection.max_zoom,
187
- DO_NOT_TILE_WMS: parsedMapSection.do_not_tile_wms,
188
- MAX_EXTENT: parsedMapSection.max_extent,
189
- MAX_FEATURE_COUNT: parsedMapSection.max_feature_count,
190
- EXTERNAL_VIEWER_URL_TEMPLATE:
191
- parsedMapSection.external_viewer_url_template,
192
- EXTERNAL_VIEWER_OPEN_NEW_TAB:
193
- parsedMapSection.external_viewer_open_new_tab,
194
- DO_NOT_USE_DEFAULT_BASEMAP:
195
- !!parsedMapSection.do_not_use_default_basemap,
196
- MAP_LAYERS: parsedLayersSections.map(
197
- (map_layer) =>
198
- ({
199
- TYPE: map_layer.type,
200
- URL: map_layer.url,
201
- NAME: map_layer.name,
202
- DATA: map_layer.data,
203
- STYLE_URL: map_layer.styleUrl,
204
- ACCESS_TOKEN: map_layer.accessToken,
205
- }) as LayerConfig
206
- ),
207
- } as MapConfig)
208
-
209
- const parsedThemeSection = parseConfigSection(
210
- parsed,
211
- 'theme',
212
- ['primary_color', 'secondary_color', 'main_color', 'background_color'],
213
- [
214
- 'header_foreground_color',
215
- 'main_font',
216
- 'title_font',
217
- 'fonts_stylesheet_url',
218
- 'thumbnail_placeholder',
219
- 'header_background',
220
- 'favicon',
221
- ],
222
- warnings,
223
- errors
224
- )
225
- themeConfig =
226
- parsedThemeSection === null
227
- ? null
228
- : ({
229
- PRIMARY_COLOR: parsedThemeSection.primary_color,
230
- SECONDARY_COLOR: parsedThemeSection.secondary_color,
231
- MAIN_COLOR: parsedThemeSection.main_color,
232
- BACKGROUND_COLOR: parsedThemeSection.background_color,
233
- HEADER_FOREGROUND_COLOR:
234
- parsedThemeSection.header_foreground_color,
235
- THUMBNAIL_PLACEHOLDER: parsedThemeSection.thumbnail_placeholder,
236
- HEADER_BACKGROUND: parsedThemeSection.header_background,
237
- TITLE_FONT: parsedThemeSection.title_font,
238
- MAIN_FONT: parsedThemeSection.main_font,
239
- FONTS_STYLESHEET_URL: parsedThemeSection.fonts_stylesheet_url,
240
- FAVICON: parsedThemeSection.favicon,
241
- } as ThemeConfig)
242
-
243
- const parsedSearchSection = parseConfigSection(
244
- parsed,
245
- 'search',
246
- [],
247
- [
248
- 'record_kind_quick_filter',
249
- 'filter_geometry_data',
250
- 'filter_geometry_url',
251
- 'do_not_use_default_search_preset',
252
- 'search_preset',
253
- 'advanced_filters',
254
- 'limit',
255
- 'spatial_extent_max_file_size',
256
- 'geocoding_provider',
257
- 'geocoding_provider_options',
258
- ],
259
- warnings,
260
- errors
261
- )
262
- const parsedSearchParams = parseMultiConfigSection(
263
- parsed,
264
- 'search_preset',
265
- ['name'],
266
- ['sort', 'filters'],
267
- warnings,
268
- errors
269
- )
270
- const parsedCustomFilters = parseMultiConfigSection(
271
- parsed,
272
- 'custom_filter',
273
- ['name', 'base_filter'],
274
- ['exclude_values', 'include_values', 'label_key'],
275
- warnings,
276
- errors
277
- )
278
- searchConfig =
279
- parsedSearchSection === null
280
- ? null
281
- : ({
282
- RECORD_KIND_QUICK_FILTER:
283
- parsedSearchSection.record_kind_quick_filter,
284
- FILTER_GEOMETRY_DATA: parsedSearchSection.filter_geometry_data,
285
- FILTER_GEOMETRY_URL: parsedSearchSection.filter_geometry_url,
286
- DO_NOT_USE_DEFAULT_SEARCH_PRESET:
287
- !!parsedSearchSection.do_not_use_default_search_preset,
288
- SEARCH_PRESET: parsedSearchParams.map((param) => ({
289
- sort: param.sort,
290
- name: param.name,
291
- filters: param.filters,
292
- })),
293
- ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
294
- CUSTOM_FILTERS: parsedCustomFilters.map((customFilter) => ({
295
- name: customFilter.name,
296
- baseFilter: customFilter.base_filter,
297
- excludeValues: customFilter.exclude_values,
298
- includeValues: customFilter.include_values,
299
- labelKey: customFilter.label_key,
300
- })),
301
- LIMIT: parsedSearchSection.limit,
302
- SPATIAL_EXTENT_MAX_FILE_SIZE:
303
- parsedSearchSection.spatial_extent_max_file_size,
304
- GEOCODING_PROVIDER: parsedSearchSection.geocoding_provider,
305
- GEOCODING_PROVIDER_OPTIONS:
306
- parsedSearchSection.geocoding_provider_options,
307
- } as SearchConfig)
308
-
309
- const parsedMetadataQualitySection = parseConfigSection(
310
- parsed,
311
- 'metadata-quality',
312
- [],
313
- ['enabled'],
314
- warnings,
315
- errors
316
- )
317
- metadataQualityConfig =
318
- parsedMetadataQualitySection === null
319
- ? null
320
- : ({
321
- ENABLED: parsedMetadataQualitySection.enabled,
322
- SORTABLE: parsedMetadataQualitySection.sortable,
323
- } as MetadataQualityConfig)
324
-
325
- let parsedEditingSection = parseConfigSection(
326
- parsed,
327
- 'editing',
328
- [],
329
- ['new_record_default_language', 'new_record_standard'],
330
- warnings,
331
- errors
332
- )
333
- if (
334
- parsedEditingSection !== null &&
335
- parsedEditingSection.new_record_default_language !== undefined
336
- ) {
337
- parsedEditingSection = checkNewRecordDefaultLanguage(
338
- parsedEditingSection,
339
- warnings
340
- )
341
- }
342
- if (
343
- parsedEditingSection !== null &&
344
- parsedEditingSection.new_record_standard !== undefined
345
- ) {
346
- parsedEditingSection = checkNewRecordStandard(
347
- parsedEditingSection,
348
- warnings
349
- )
350
- }
351
- editorConfig =
352
- parsedEditingSection === null
353
- ? null
354
- : ({
355
- NEW_RECORD_DEFAULT_LANGUAGE:
356
- parsedEditingSection.new_record_default_language as
357
- | string
358
- | undefined,
359
- NEW_RECORD_STANDARD: parsedEditingSection.new_record_standard as
360
- | EditorConfig['NEW_RECORD_STANDARD']
361
- | undefined,
362
- } as EditorConfig)
363
-
364
- customTranslations = parseTranslationsConfigSection(
365
- parsed,
366
- 'translations'
367
- ) as CustomTranslationsAllLanguages
420
+ const issues: ConfigIssues = { warnings: [], errors: [] }
421
+ const config = Object.fromEntries(
422
+ sections.map((name) => [name, SECTION_PARSERS[name](parsed, issues)])
423
+ ) as Partial<AppConfig>
368
424
 
369
- if (errors.length) {
425
+ if (issues.errors.length) {
370
426
  throw new Error(`One or more mandatory settings were missing from the configuration file.
371
- ${errors.join('\n')}`)
372
- } else if (warnings.length) {
427
+ ${issues.errors.join('\n')}`)
428
+ } else if (issues.warnings.length) {
373
429
  console.warn(`One or more unexpected settings were encountered in the configuration file.
374
- ${warnings.join('\n')}`)
430
+ ${issues.warnings.join('\n')}`)
375
431
  }
376
432
 
433
+ globalConfig = config.global ?? null
434
+ themeConfig = config.theme ?? null
435
+ mapConfig = config.map ?? null
436
+ searchConfig = config.search ?? null
437
+ metadataQualityConfig = config.metadataQuality ?? null
438
+ editorConfig = config.editor ?? null
439
+ customTranslations = config.translations ?? {}
377
440
  appConfigLoaded = true
441
+ return parsed
378
442
  })
379
443
  }
380
444
 
@@ -385,8 +449,12 @@ export function isConfigLoaded() {
385
449
  export function _reset() {
386
450
  globalConfig = null
387
451
  themeConfig = null
452
+ mapConfig = null
453
+ searchConfig = null
454
+ metadataQualityConfig = null
388
455
  editorConfig = null
389
456
  customTranslations = null
457
+ appConfigLoaded = false
390
458
  }
391
459
 
392
460
  export const TRANSLATE_WITH_OVERRIDES_CONFIG: TranslateModuleConfig = {
@@ -42,8 +42,12 @@ record_kind_quick_filter = false
42
42
  filter_geometry_url = 'https://my.domain.org/geom.json'
43
43
  do_not_use_default_search_preset = false
44
44
  geocoding_provider = "geoplateforme"
45
+ geocoding_provider_options.index = "poi"
45
46
  geocoding_provider_options.category = "administratif"
46
47
  geocoding_provider_options.limit = 5
48
+ geocoding_provider_labels.main = '/properties/name/0'
49
+ geocoding_provider_labels.secondary = '/properties/citycode/0'
50
+ geocoding_provider_labels.tertiary = '/properties/category/1'
47
51
  advanced_filters = ['publicationYear', 'documentStandard', 'inspireKeyword', 'topic', 'license', 'myOrg:firstCustomFilter', 'myOrg:secondCustomFilter']
48
52
 
49
53
  [[custom_filter]]
@@ -96,6 +100,23 @@ main_color = "#212029" # All-purpose text color
96
100
  background_color = "#fdfbff"
97
101
  `
98
102
 
103
+ export const customFilterMissingMandatoryConfigFixture = () => `
104
+ [global]
105
+ geonetwork4_api_url = "/geonetwork/srv/api"
106
+
107
+ [theme]
108
+ primary_color = "#093564"
109
+ secondary_color = "#c2e9dc"
110
+ main_color = "#212029" # All-purpose text color
111
+ background_color = "#fdfbff"
112
+
113
+ [search]
114
+ advanced_filters = ['myOrg:firstCustomFilter']
115
+
116
+ [[custom_filter]]
117
+ name = 'myOrg:firstCustomFilter'
118
+ `
119
+
99
120
  export const mapConfigFixture = (): MapConfig => ({
100
121
  MAX_ZOOM: 10,
101
122
  MAX_EXTENT: [-418263.418776, 5251529.591305, 961272.067714, 6706890.609855],