geonetwork-ui 2.4.0-dev.71a43b38 → 2.4.0-dev.78565730

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 (126) hide show
  1. package/esm2022/libs/api/metadata-converter/src/index.mjs +2 -1
  2. package/esm2022/libs/api/metadata-converter/src/lib/gn4/atomic-operations.mjs +2 -1
  3. package/esm2022/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.mjs +1 -1
  4. package/esm2022/libs/api/repository/src/lib/gn4/gn4-repository.mjs +12 -1
  5. package/esm2022/libs/common/domain/src/lib/repository/records-repository.interface.mjs +1 -1
  6. package/esm2022/libs/data-access/gn4/src/openapi/api/records.api.service.mjs +2 -6
  7. package/esm2022/libs/feature/editor/src/lib/+state/editor.actions.mjs +2 -1
  8. package/esm2022/libs/feature/editor/src/lib/+state/editor.effects.mjs +3 -3
  9. package/esm2022/libs/feature/editor/src/lib/+state/editor.facade.mjs +7 -2
  10. package/esm2022/libs/feature/editor/src/lib/+state/editor.models.mjs +1 -1
  11. package/esm2022/libs/feature/editor/src/lib/+state/editor.reducer.mjs +7 -3
  12. package/esm2022/libs/feature/editor/src/lib/+state/editor.selectors.mjs +16 -6
  13. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.mjs +3 -3
  14. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/index.mjs +1 -2
  15. package/esm2022/libs/feature/editor/src/lib/components/record-form/record-form.component.mjs +11 -7
  16. package/esm2022/libs/feature/editor/src/lib/expressions.mjs +1 -1
  17. package/esm2022/libs/feature/editor/src/lib/fields.config.mjs +143 -60
  18. package/esm2022/libs/feature/editor/src/lib/models/editor-config.model.mjs +2 -0
  19. package/esm2022/libs/feature/editor/src/lib/models/index.mjs +2 -1
  20. package/esm2022/libs/feature/editor/src/lib/services/editor.service.mjs +4 -3
  21. package/esm2022/libs/feature/search/src/lib/results-table/results-table-container.component.mjs +9 -3
  22. package/esm2022/libs/ui/elements/src/lib/user-preview/user-preview.component.mjs +3 -3
  23. package/esm2022/libs/ui/search/src/lib/results-table/action-menu/action-menu.component.mjs +29 -0
  24. package/esm2022/libs/ui/search/src/lib/results-table/results-table.component.mjs +15 -7
  25. package/esm2022/translations/de.json +30 -0
  26. package/esm2022/translations/en.json +30 -0
  27. package/esm2022/translations/es.json +30 -0
  28. package/esm2022/translations/fr.json +30 -0
  29. package/esm2022/translations/it.json +30 -0
  30. package/esm2022/translations/nl.json +30 -0
  31. package/esm2022/translations/pt.json +30 -0
  32. package/fesm2022/geonetwork-ui.mjs +453 -94
  33. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  34. package/libs/api/metadata-converter/src/index.d.ts +1 -0
  35. package/libs/api/metadata-converter/src/index.d.ts.map +1 -1
  36. package/libs/api/metadata-converter/src/lib/gn4/atomic-operations.d.ts.map +1 -1
  37. package/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.d.ts +1 -0
  38. package/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.d.ts.map +1 -1
  39. package/libs/api/repository/src/lib/gn4/gn4-repository.d.ts +1 -0
  40. package/libs/api/repository/src/lib/gn4/gn4-repository.d.ts.map +1 -1
  41. package/libs/common/domain/src/lib/repository/records-repository.interface.d.ts +9 -0
  42. package/libs/common/domain/src/lib/repository/records-repository.interface.d.ts.map +1 -1
  43. package/libs/data-access/gn4/src/openapi/api/records.api.service.d.ts.map +1 -1
  44. package/libs/feature/editor/src/lib/+state/editor.actions.d.ts +5 -0
  45. package/libs/feature/editor/src/lib/+state/editor.actions.d.ts.map +1 -1
  46. package/libs/feature/editor/src/lib/+state/editor.facade.d.ts +4 -4
  47. package/libs/feature/editor/src/lib/+state/editor.facade.d.ts.map +1 -1
  48. package/libs/feature/editor/src/lib/+state/editor.models.d.ts +8 -0
  49. package/libs/feature/editor/src/lib/+state/editor.models.d.ts.map +1 -1
  50. package/libs/feature/editor/src/lib/+state/editor.reducer.d.ts +4 -3
  51. package/libs/feature/editor/src/lib/+state/editor.reducer.d.ts.map +1 -1
  52. package/libs/feature/editor/src/lib/+state/editor.selectors.d.ts +4 -8
  53. package/libs/feature/editor/src/lib/+state/editor.selectors.d.ts.map +1 -1
  54. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.d.ts +1 -1
  55. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.d.ts.map +1 -1
  56. package/libs/feature/editor/src/lib/components/record-form/form-field/index.d.ts +0 -1
  57. package/libs/feature/editor/src/lib/components/record-form/form-field/index.d.ts.map +1 -1
  58. package/libs/feature/editor/src/lib/components/record-form/record-form.component.d.ts +5 -7
  59. package/libs/feature/editor/src/lib/components/record-form/record-form.component.d.ts.map +1 -1
  60. package/libs/feature/editor/src/lib/expressions.d.ts +1 -1
  61. package/libs/feature/editor/src/lib/expressions.d.ts.map +1 -1
  62. package/libs/feature/editor/src/lib/fields.config.d.ts +38 -2
  63. package/libs/feature/editor/src/lib/fields.config.d.ts.map +1 -1
  64. package/libs/feature/editor/src/lib/models/editor-config.model.d.ts +36 -0
  65. package/libs/feature/editor/src/lib/models/editor-config.model.d.ts.map +1 -0
  66. package/libs/feature/editor/src/lib/models/index.d.ts +1 -0
  67. package/libs/feature/editor/src/lib/models/index.d.ts.map +1 -1
  68. package/libs/feature/editor/src/lib/services/editor.service.d.ts +2 -2
  69. package/libs/feature/editor/src/lib/services/editor.service.d.ts.map +1 -1
  70. package/libs/feature/search/src/lib/results-table/results-table-container.component.d.ts +3 -1
  71. package/libs/feature/search/src/lib/results-table/results-table-container.component.d.ts.map +1 -1
  72. package/libs/ui/search/src/lib/results-table/action-menu/action-menu.component.d.ts +11 -0
  73. package/libs/ui/search/src/lib/results-table/action-menu/action-menu.component.d.ts.map +1 -0
  74. package/libs/ui/search/src/lib/results-table/results-table.component.d.ts +4 -2
  75. package/libs/ui/search/src/lib/results-table/results-table.component.d.ts.map +1 -1
  76. package/package.json +1 -1
  77. package/src/libs/api/metadata-converter/src/index.ts +1 -0
  78. package/src/libs/api/metadata-converter/src/lib/gn4/atomic-operations.ts +1 -0
  79. package/src/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +1 -0
  80. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +20 -0
  81. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +12 -0
  82. package/src/libs/common/fixtures/src/index.ts +2 -0
  83. package/src/libs/common/fixtures/src/lib/editor/editor.fixtures.ts +156 -0
  84. package/src/libs/common/fixtures/src/lib/editor/index.ts +1 -0
  85. package/src/libs/data-access/gn4/src/openapi/api/records.api.service.ts +1 -5
  86. package/src/libs/data-access/gn4/src/spec.yaml +0 -8
  87. package/src/libs/feature/editor/src/lib/+state/editor.actions.ts +5 -0
  88. package/src/libs/feature/editor/src/lib/+state/editor.effects.ts +2 -2
  89. package/src/libs/feature/editor/src/lib/+state/editor.facade.ts +9 -1
  90. package/src/libs/feature/editor/src/lib/+state/editor.models.ts +11 -0
  91. package/src/libs/feature/editor/src/lib/+state/editor.reducer.ts +11 -5
  92. package/src/libs/feature/editor/src/lib/+state/editor.selectors.ts +22 -8
  93. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +9 -9
  94. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +2 -1
  95. package/src/libs/feature/editor/src/lib/components/record-form/form-field/index.ts +0 -1
  96. package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.html +51 -11
  97. package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +15 -8
  98. package/src/libs/feature/editor/src/lib/expressions.ts +1 -1
  99. package/src/libs/feature/editor/src/lib/fields.config.ts +175 -61
  100. package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +53 -0
  101. package/src/libs/feature/editor/src/lib/models/index.ts +1 -0
  102. package/src/libs/feature/editor/src/lib/services/editor.service.ts +8 -4
  103. package/src/libs/feature/search/src/lib/results-table/results-table-container.component.html +1 -0
  104. package/src/libs/feature/search/src/lib/results-table/results-table-container.component.ts +5 -0
  105. package/src/libs/ui/elements/src/lib/user-preview/user-preview.component.html +1 -1
  106. package/src/libs/ui/search/src/lib/results-table/action-menu/action-menu.component.css +0 -0
  107. package/src/libs/ui/search/src/lib/results-table/action-menu/action-menu.component.html +17 -0
  108. package/src/libs/ui/search/src/lib/results-table/action-menu/action-menu.component.ts +22 -0
  109. package/src/libs/ui/search/src/lib/results-table/results-table.component.html +9 -0
  110. package/src/libs/ui/search/src/lib/results-table/results-table.component.ts +26 -12
  111. package/translations/de.json +30 -0
  112. package/translations/en.json +30 -0
  113. package/translations/es.json +30 -0
  114. package/translations/fr.json +30 -0
  115. package/translations/it.json +30 -0
  116. package/translations/nl.json +30 -0
  117. package/translations/pt.json +30 -0
  118. package/translations/sk.json +30 -0
  119. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field.model.mjs +0 -2
  120. package/esm2022/libs/feature/editor/src/lib/models/fields.model.mjs +0 -2
  121. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field.model.d.ts +0 -26
  122. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field.model.d.ts.map +0 -1
  123. package/libs/feature/editor/src/lib/models/fields.model.d.ts +0 -15
  124. package/libs/feature/editor/src/lib/models/fields.model.d.ts.map +0 -1
  125. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.model.ts +0 -43
  126. package/src/libs/feature/editor/src/lib/models/fields.model.ts +0 -29
@@ -6,9 +6,9 @@ import * as EditorActions from './editor.actions'
6
6
  import { EditorService } from '../services/editor.service'
7
7
  import { Store } from '@ngrx/store'
8
8
  import {
9
+ selectEditorConfig,
9
10
  selectRecord,
10
11
  selectRecordAlreadySavedOnce,
11
- selectRecordFieldsConfig,
12
12
  } from './editor.selectors'
13
13
  import { RecordsRepositoryInterface } from '../../../../../../libs/common/domain/src/lib/repository/records-repository.interface'
14
14
 
@@ -24,7 +24,7 @@ export class EditorEffects {
24
24
  ofType(EditorActions.saveRecord),
25
25
  withLatestFrom(
26
26
  this.store.select(selectRecord),
27
- this.store.select(selectRecordFieldsConfig),
27
+ this.store.select(selectEditorConfig),
28
28
  this.store.select(selectRecordAlreadySavedOnce)
29
29
  ),
30
30
  switchMap(([, record, fieldsConfig, alreadySavedOnce]) =>
@@ -25,8 +25,12 @@ export class EditorFacade {
25
25
  changedSinceSave$ = this.store.pipe(
26
26
  select(EditorSelectors.selectRecordChangedSinceSave)
27
27
  )
28
- recordFields$ = this.store.pipe(select(EditorSelectors.selectRecordFields))
28
+ currentSections$ = this.store.pipe(
29
+ select(EditorSelectors.selectRecordSections)
30
+ )
29
31
  draftSaveSuccess$ = this.actions$.pipe(ofType(EditorActions.draftSaveSuccess))
32
+ currentPage$ = this.store.pipe(select(EditorSelectors.selectCurrentPage))
33
+ editorConfig$ = this.store.pipe(select(EditorSelectors.selectEditorConfig))
30
34
 
31
35
  openRecord(
32
36
  record: CatalogRecord,
@@ -45,4 +49,8 @@ export class EditorFacade {
45
49
  updateRecordField(field: string, value: unknown) {
46
50
  this.store.dispatch(EditorActions.updateRecordField({ field, value }))
47
51
  }
52
+
53
+ setCurrentPage(page: number) {
54
+ this.store.dispatch(EditorActions.setCurrentPage({ page }))
55
+ }
48
56
  }
@@ -1 +1,12 @@
1
+ import { EditorField, EditorFieldValue, EditorSection } from '../models'
2
+
1
3
  export type SaveRecordError = string
4
+
5
+ export interface EditorFieldWithValue {
6
+ config: EditorField
7
+ value: EditorFieldValue
8
+ }
9
+
10
+ export type EditorSectionWithValues = EditorSection & {
11
+ fieldsWithValues: EditorFieldWithValue[]
12
+ }
@@ -2,8 +2,8 @@ import { Action, createReducer, on } from '@ngrx/store'
2
2
  import * as EditorActions from './editor.actions'
3
3
  import { CatalogRecord } from '../../../../../../libs/common/domain/src/lib/model/record'
4
4
  import { SaveRecordError } from './editor.models'
5
- import { EditorFieldsConfig } from '../models/fields.model'
6
- import { DEFAULT_FIELDS } from '../fields.config'
5
+ import { EditorConfig } from '../models'
6
+ import { DEFAULT_CONFIGURATION } from '../fields.config'
7
7
 
8
8
  export const EDITOR_FEATURE_KEY = 'editor'
9
9
 
@@ -13,7 +13,7 @@ export const EDITOR_FEATURE_KEY = 'editor'
13
13
  * @property saving
14
14
  * @property saveError
15
15
  * @property changedSinceSave
16
- * @property fieldsConfig Configuration for the fields in the editor
16
+ * @property editorConfig Configuration for the fields in the editor
17
17
  */
18
18
  export interface EditorState {
19
19
  record: CatalogRecord | null
@@ -22,7 +22,8 @@ export interface EditorState {
22
22
  saving: boolean
23
23
  saveError: SaveRecordError | null
24
24
  changedSinceSave: boolean
25
- fieldsConfig: EditorFieldsConfig
25
+ editorConfig: EditorConfig
26
+ currentPage: number
26
27
  }
27
28
 
28
29
  export interface EditorPartialState {
@@ -36,7 +37,8 @@ export const initialEditorState: EditorState = {
36
37
  saving: false,
37
38
  saveError: null,
38
39
  changedSinceSave: false,
39
- fieldsConfig: DEFAULT_FIELDS,
40
+ editorConfig: DEFAULT_CONFIGURATION,
41
+ currentPage: 0,
40
42
  }
41
43
 
42
44
  const reducer = createReducer(
@@ -77,6 +79,10 @@ const reducer = createReducer(
77
79
  on(EditorActions.markRecordAsChanged, (state) => ({
78
80
  ...state,
79
81
  changedSinceSave: true,
82
+ })),
83
+ on(EditorActions.setCurrentPage, (state, { page }) => ({
84
+ ...state,
85
+ currentPage: page,
80
86
  }))
81
87
  )
82
88
 
@@ -1,5 +1,6 @@
1
1
  import { createFeatureSelector, createSelector } from '@ngrx/store'
2
2
  import { EDITOR_FEATURE_KEY, EditorState } from './editor.reducer'
3
+ import { EditorSectionWithValues } from './editor.models'
3
4
 
4
5
  export const selectEditorState =
5
6
  createFeatureSelector<EditorState>(EDITOR_FEATURE_KEY)
@@ -34,16 +35,29 @@ export const selectRecordAlreadySavedOnce = createSelector(
34
35
  (state: EditorState) => state.alreadySavedOnce
35
36
  )
36
37
 
37
- export const selectRecordFieldsConfig = createSelector(
38
+ export const selectEditorConfig = createSelector(
38
39
  selectEditorState,
39
- (state: EditorState) => state.fieldsConfig
40
+ (state: EditorState) => state.editorConfig
40
41
  )
41
42
 
42
- export const selectRecordFields = createSelector(
43
+ export const selectCurrentPage = createSelector(
43
44
  selectEditorState,
44
- (state: EditorState) =>
45
- state.fieldsConfig.map((fieldConfig) => ({
46
- config: fieldConfig,
47
- value: state.record?.[fieldConfig.model] ?? null,
48
- }))
45
+ (state: EditorState) => state.currentPage
46
+ )
47
+
48
+ export const selectRecordSections = createSelector(
49
+ selectEditorState,
50
+ (state: EditorState) => {
51
+ const currentPage = state.editorConfig.pages[state.currentPage]
52
+ if (!currentPage) {
53
+ return [] as EditorSectionWithValues[]
54
+ }
55
+ return currentPage.sections.map((section) => ({
56
+ ...section,
57
+ fieldsWithValues: section.fields.map((fieldConfig) => ({
58
+ config: fieldConfig,
59
+ value: state.record?.[fieldConfig.model] ?? null,
60
+ })),
61
+ })) as EditorSectionWithValues[]
62
+ }
49
63
  )
@@ -4,8 +4,8 @@
4
4
  </ng-container>
5
5
  <ng-template #withGenericWrapper>
6
6
  <gn-ui-form-field-wrapper
7
- [label]="config.labelKey | translate"
8
- [hint]="config.hintKey | translate"
7
+ [label]="config.labelKey! | translate"
8
+ [hint]="config.hintKey! | translate"
9
9
  >
10
10
  <ng-container *ngTemplateOutlet="fieldContent"></ng-container>
11
11
  </gn-ui-form-field-wrapper>
@@ -15,14 +15,14 @@
15
15
  <ng-template #fieldContent>
16
16
  <ng-container *ngIf="isTitle">
17
17
  <div class="flex justify-between items-center gap-3">
18
- <h2
18
+ <span
19
19
  #titleInput
20
- class="grow text-3xl font-normal"
20
+ class="grow font-title text-3xl font-normal"
21
21
  [gnUiEditableLabel]="true"
22
22
  (editableLabelChanged)="formControl.setValue($event)"
23
23
  >
24
24
  {{ formControl.value }}
25
- </h2>
25
+ </span>
26
26
  <span
27
27
  class="material-symbols-outlined gn-ui-icon-small m-2 cursor-pointer"
28
28
  (click)="focusTitleInput()"
@@ -30,7 +30,7 @@
30
30
  >
31
31
  <span
32
32
  class="material-symbols-outlined gn-ui-icon-small m-2"
33
- [matTooltip]="config.hintKey | translate"
33
+ [matTooltip]="config.hintKey! | translate"
34
34
  matTooltipPosition="above"
35
35
  >
36
36
  help
@@ -41,14 +41,14 @@
41
41
  <gn-ui-form-field-rich
42
42
  class="h-[8rem]"
43
43
  [control]="formControl"
44
- [label]="config.labelKey | translate"
45
- [hint]="config.hintKey | translate"
44
+ [label]="config.labelKey! | translate"
45
+ [hint]="config.hintKey! | translate"
46
46
  ></gn-ui-form-field-rich>
47
47
  </ng-container>
48
48
  <ng-container *ngIf="isLicenses">
49
49
  <gn-ui-form-field-license
50
50
  [control]="formControl"
51
- [label]="config.labelKey | translate"
51
+ [label]="config.labelKey! | translate"
52
52
  ></gn-ui-form-field-license>
53
53
  </ng-container>
54
54
  <ng-container *ngIf="isResourceUpdated">
@@ -25,10 +25,10 @@ import { FormFieldObjectComponent } from './form-field-object/form-field-object.
25
25
  import { FormFieldRichComponent } from './form-field-rich/form-field-rich.component'
26
26
  import { FormFieldSimpleComponent } from './form-field-simple/form-field-simple.component'
27
27
  import { FormFieldSpatialExtentComponent } from './form-field-spatial-extent/form-field-spatial-extent.component'
28
- import { FormFieldConfig } from './form-field.model'
29
28
  import { FormFieldUpdateFrequencyComponent } from './form-field-update-frequency/form-field-update-frequency.component'
30
29
  import { CatalogRecordKeys } from '../../../../../../../../libs/common/domain/src/lib/model/record'
31
30
  import { FormFieldKeywordsComponent } from './form-field-keywords/form-field-keywords.component'
31
+ import { FormFieldConfig } from '../../../models'
32
32
 
33
33
  @Component({
34
34
  selector: 'gn-ui-form-field',
@@ -65,6 +65,7 @@ export class FormFieldComponent {
65
65
  emitEvent: false,
66
66
  })
67
67
  }
68
+
68
69
  @Output() valueChange: Observable<unknown>
69
70
 
70
71
  @ViewChild('titleInput') titleInput: ElementRef
@@ -9,4 +9,3 @@ export * from './form-field-object/form-field-object.component'
9
9
  export * from './form-field-array/form-field-array.component'
10
10
  export * from './form-field-spatial-extent/form-field-spatial-extent.component'
11
11
  export * from './form-field.component'
12
- export * from './form-field.model'
@@ -1,11 +1,51 @@
1
- <div class="flex flex-col gap-6 p-6">
2
- <ng-container *ngFor="let field of fields$ | async; trackBy: fieldTracker">
3
- <gn-ui-form-field
4
- *ngIf="field.config.formFieldConfig && !field.config.hidden"
5
- [model]="field.config.model"
6
- [config]="field.config.formFieldConfig"
7
- [value]="field.value"
8
- (valueChange)="handleFieldValueChange(field, $event)"
9
- ></gn-ui-form-field>
10
- </ng-container>
11
- </div>
1
+ <ng-container>
2
+ <div class="flex flex-col gap-6 p-8">
3
+ <ng-container
4
+ *ngFor="
5
+ let section of facade.currentSections$ | async;
6
+ trackBy: sectionTracker
7
+ "
8
+ >
9
+ <ng-container *ngIf="!section.hidden">
10
+ <div class="flex flex-col gap-8 border p-8 rounded-[8px] shadow">
11
+ <div
12
+ class="flex flex-col gap-2"
13
+ [ngClass]="section.labelKey ? 'mb-4' : 'hidden'"
14
+ >
15
+ <div
16
+ *ngIf="section.labelKey"
17
+ class="text-2xl font-petrona text-secondary"
18
+ translate
19
+ >
20
+ {{ section.labelKey }}
21
+ </div>
22
+ <div
23
+ *ngIf="section.descriptionKey"
24
+ class="text-secondary-lightest"
25
+ translate
26
+ >
27
+ {{ section.descriptionKey }}
28
+ </div>
29
+ </div>
30
+ <ng-container
31
+ *ngFor="
32
+ let field of section.fieldsWithValues;
33
+ trackBy: fieldTracker
34
+ "
35
+ >
36
+ <ng-container *ngIf="!field.config.hidden">
37
+ <gn-ui-form-field
38
+ [model]="field.config.model!"
39
+ [config]="field.config.formFieldConfig"
40
+ [value]="field.value"
41
+ (valueChange)="
42
+ handleFieldValueChange(field.config.model!, $event)
43
+ "
44
+ ></gn-ui-form-field>
45
+ </ng-container>
46
+ </ng-container>
47
+ </div>
48
+ </ng-container>
49
+ </ng-container>
50
+ </div>
51
+ </ng-container>
@@ -1,8 +1,13 @@
1
1
  import { CommonModule } from '@angular/common'
2
2
  import { ChangeDetectionStrategy, Component } from '@angular/core'
3
3
  import { EditorFacade } from '../../+state/editor.facade'
4
- import { EditorFieldState, EditorFieldValue } from '../../models/fields.model'
4
+ import { EditorFieldValue } from '../../models'
5
5
  import { FormFieldComponent } from './form-field'
6
+ import { TranslateModule } from '@ngx-translate/core'
7
+ import {
8
+ EditorFieldWithValue,
9
+ EditorSectionWithValues,
10
+ } from '../../+state/editor.models'
6
11
 
7
12
  @Component({
8
13
  selector: 'gn-ui-record-form',
@@ -10,21 +15,23 @@ import { FormFieldComponent } from './form-field'
10
15
  styleUrls: ['./record-form.component.css'],
11
16
  changeDetection: ChangeDetectionStrategy.OnPush,
12
17
  standalone: true,
13
- imports: [CommonModule, FormFieldComponent],
18
+ imports: [CommonModule, FormFieldComponent, TranslateModule],
14
19
  })
15
20
  export class RecordFormComponent {
16
- fields$ = this.facade.recordFields$
17
-
18
21
  constructor(public facade: EditorFacade) {}
19
22
 
20
- handleFieldValueChange(field: EditorFieldState, newValue: EditorFieldValue) {
21
- if (!field.config.model) {
23
+ handleFieldValueChange(model: string, newValue: EditorFieldValue) {
24
+ if (!model) {
22
25
  return
23
26
  }
24
- this.facade.updateRecordField(field.config.model, newValue)
27
+ this.facade.updateRecordField(model, newValue)
25
28
  }
26
29
 
27
- fieldTracker(index: number, field: EditorFieldState) {
30
+ fieldTracker(index: number, field: EditorFieldWithValue): any {
28
31
  return field.config.model
29
32
  }
33
+
34
+ sectionTracker(index: number, section: EditorSectionWithValues): any {
35
+ return section.labelKey
36
+ }
30
37
  }
@@ -1,4 +1,4 @@
1
- import { EditorFieldState, EditorFieldValue } from './models/fields.model'
1
+ import { EditorFieldState, EditorFieldValue } from './models/'
2
2
 
3
3
  export type ExpressionEvaluator = (field: EditorFieldState) => EditorFieldValue
4
4
 
@@ -1,71 +1,185 @@
1
1
  import { marker } from '@biesbjerg/ngx-translate-extract-marker'
2
- import { EditorFieldsConfig } from './models/fields.model'
3
-
4
- export const DEFAULT_FIELDS: EditorFieldsConfig = [
5
- {
6
- model: 'title',
7
- formFieldConfig: {
8
- labelKey: marker('editor.record.form.metadata.title'),
9
- type: 'text',
10
- },
2
+ import {
3
+ EditorConfig,
4
+ EditorField,
5
+ EditorSection,
6
+ } from './models/editor-config.model'
7
+
8
+ /**
9
+ * This file contains the configuration of the fields that will be displayed in the editor.
10
+ * To add a new field, you need to create a new EditorField object in the fields part of this file.
11
+ * Then add it to the corresponding section in the sections part of this file.
12
+ * Finally, add the section to the corresponding page in the pages part of this file.
13
+ */
14
+
15
+ /************************************************************
16
+ *************** FIELDS *****************
17
+ ************************************************************
18
+ */
19
+
20
+ export const RECORD_LICENSE_FIELD: EditorField = {
21
+ model: 'licenses',
22
+ formFieldConfig: {
23
+ labelKey: marker('editor.record.form.field.license'),
11
24
  },
12
- {
13
- model: 'abstract',
14
- formFieldConfig: {
15
- labelKey: marker('editor.record.form.abstract'),
16
- type: 'rich',
17
- },
25
+ }
26
+
27
+ export const RECORD_KEYWORDS_FIELD: EditorField = {
28
+ model: 'keywords',
29
+ formFieldConfig: {
30
+ labelKey: marker('editor.record.form.field.keywords'),
18
31
  },
19
- {
20
- model: 'uniqueIdentifier',
21
- formFieldConfig: {
22
- labelKey: marker('editor.record.form.unique.identifier'),
23
- type: 'text',
24
- locked: true,
25
- },
32
+ }
33
+
34
+ export const RECORD_UNIQUE_IDENTIFIER_FIELD: EditorField = {
35
+ model: 'uniqueIdentifier',
36
+ formFieldConfig: {
37
+ labelKey: marker('editor.record.form.field.uniqueIdentifier'),
38
+ locked: true,
26
39
  },
27
- {
28
- model: 'recordUpdated',
29
- formFieldConfig: {
30
- labelKey: marker('editor.record.form.record.updated'),
31
- type: 'text',
32
- locked: true,
33
- },
34
- onSaveProcess: '${dateNow()}',
40
+ }
41
+
42
+ export const RECORD_RESOURCE_UPDATED_FIELD: EditorField = {
43
+ model: 'resourceUpdated',
44
+ formFieldConfig: {
45
+ labelKey: marker('editor.record.form.field.resourceUpdated'),
35
46
  },
36
- {
37
- model: 'licenses',
38
- formFieldConfig: {
39
- labelKey: marker('editor.record.form.license'),
40
- type: 'list',
41
- },
47
+ }
48
+
49
+ export const RECORD_UPDATED_FIELD: EditorField = {
50
+ model: 'recordUpdated',
51
+ formFieldConfig: {
52
+ labelKey: marker('editor.record.form.field.recordUpdated'),
53
+ locked: true,
42
54
  },
43
- {
44
- model: 'resourceUpdated',
45
- formFieldConfig: {
46
- labelKey: marker('editor.record.form.resourceUpdated'),
47
- type: 'date',
48
- },
55
+ onSaveProcess: '${dateNow()}',
56
+ }
57
+
58
+ export const RECORD_UPDATE_FREQUENCY_FIELD: EditorField = {
59
+ model: 'updateFrequency',
60
+ formFieldConfig: {
61
+ labelKey: marker('editor.record.form.field.updateFrequency'),
49
62
  },
50
- {
51
- model: 'updateFrequency',
52
- formFieldConfig: {
53
- labelKey: marker('editor.record.form.updateFrequency'),
54
- type: 'text',
55
- },
63
+ }
64
+
65
+ export const RECORD_TEMPORAL_EXTENTS_FIELD: EditorField = {
66
+ model: 'temporalExtents',
67
+ formFieldConfig: {
68
+ labelKey: marker('editor.record.form.field.temporalExtents'),
56
69
  },
57
- {
58
- model: 'temporalExtents',
59
- formFieldConfig: {
60
- labelKey: marker('editor.record.form.temporalExtents'),
61
- type: 'list',
62
- },
70
+ }
71
+
72
+ export const RECORD_TITLE_FIELD: EditorField = {
73
+ model: 'title',
74
+ formFieldConfig: {
75
+ labelKey: marker('editor.record.form.field.title'),
63
76
  },
64
- {
65
- model: 'keywords',
66
- formFieldConfig: {
67
- labelKey: marker('editor.record.form.keywords'),
68
- type: 'list',
69
- },
77
+ }
78
+
79
+ export const RECORD_ABSTRACT_FIELD: EditorField = {
80
+ model: 'abstract',
81
+ formFieldConfig: {
82
+ labelKey: marker('editor.record.form.field.abstract'),
70
83
  },
71
- ]
84
+ }
85
+
86
+ /************************************************************
87
+ *************** SECTIONS *****************
88
+ ************************************************************
89
+ */
90
+
91
+ export const TITLE_SECTION: EditorSection = {
92
+ hidden: false,
93
+ fields: [RECORD_TITLE_FIELD, RECORD_ABSTRACT_FIELD],
94
+ }
95
+
96
+ export const ABOUT_SECTION: EditorSection = {
97
+ labelKey: marker('editor.record.form.section.about.label'),
98
+ descriptionKey: marker('editor.record.form.section.about.description'),
99
+ hidden: false,
100
+ fields: [
101
+ RECORD_UNIQUE_IDENTIFIER_FIELD,
102
+ RECORD_RESOURCE_UPDATED_FIELD,
103
+ RECORD_UPDATED_FIELD,
104
+ RECORD_UPDATE_FREQUENCY_FIELD,
105
+ RECORD_TEMPORAL_EXTENTS_FIELD,
106
+ ],
107
+ }
108
+
109
+ export const GEOGRAPHICAL_COVERAGE_SECTION: EditorSection = {
110
+ labelKey: marker('editor.record.form.section.geographicalCoverage.label'),
111
+ hidden: false,
112
+ fields: [],
113
+ }
114
+
115
+ export const ASSOCIATED_RESOURCES_SECTION: EditorSection = {
116
+ labelKey: marker('editor.record.form.section.associatedResources.label'),
117
+ descriptionKey: marker(
118
+ 'editor.record.form.section.associatedResources.description'
119
+ ),
120
+ hidden: false,
121
+ fields: [],
122
+ }
123
+
124
+ export const ANNEXES_SECTION: EditorSection = {
125
+ labelKey: marker('editor.record.form.section.annexes.label'),
126
+ hidden: false,
127
+ fields: [],
128
+ }
129
+
130
+ export const CLASSIFICATION_SECTION: EditorSection = {
131
+ labelKey: marker('editor.record.form.section.classification.label'),
132
+ descriptionKey: marker(
133
+ 'editor.record.form.section.classification.description'
134
+ ),
135
+ hidden: false,
136
+ fields: [RECORD_KEYWORDS_FIELD],
137
+ }
138
+
139
+ export const USE_AND_ACCESS_CONDITIONS_SECTION: EditorSection = {
140
+ labelKey: marker('editor.record.form.section.useAndAccessConditions.label'),
141
+ hidden: false,
142
+ fields: [RECORD_LICENSE_FIELD],
143
+ }
144
+
145
+ export const DATA_MANAGERS_SECTION: EditorSection = {
146
+ labelKey: marker('editor.record.form.section.dataManagers.label'),
147
+ descriptionKey: marker('editor.record.form.section.dataManagers.description'),
148
+ hidden: false,
149
+ fields: [],
150
+ }
151
+
152
+ export const DATA_POINT_OF_CONTACT_SECTION: EditorSection = {
153
+ labelKey: marker('editor.record.form.section.dataPointOfContact.label'),
154
+ descriptionKey: marker(
155
+ 'editor.record.form.section.dataPointOfContact.description'
156
+ ),
157
+ hidden: false,
158
+ fields: [],
159
+ }
160
+
161
+ /************************************************************
162
+ *************** PAGES *****************
163
+ ************************************************************
164
+ */
165
+ export const DEFAULT_CONFIGURATION: EditorConfig = {
166
+ pages: [
167
+ {
168
+ labelKey: marker('editor.record.form.page.description'),
169
+ sections: [TITLE_SECTION, ABOUT_SECTION, GEOGRAPHICAL_COVERAGE_SECTION],
170
+ },
171
+ {
172
+ labelKey: marker('editor.record.form.page.ressources'),
173
+ sections: [ASSOCIATED_RESOURCES_SECTION, ANNEXES_SECTION],
174
+ },
175
+ {
176
+ labelKey: marker('editor.record.form.page.accessAndContact'),
177
+ sections: [
178
+ CLASSIFICATION_SECTION,
179
+ USE_AND_ACCESS_CONDITIONS_SECTION,
180
+ DATA_MANAGERS_SECTION,
181
+ DATA_POINT_OF_CONTACT_SECTION,
182
+ ],
183
+ },
184
+ ],
185
+ }
@@ -0,0 +1,53 @@
1
+ import { CatalogRecordKeys } from '../../../../../../libs/common/domain/src/lib/model/record'
2
+
3
+ // Expressions should be enclosed in `${}` to be recognized as such
4
+ // eg. ${dateNow()}
5
+ export type EditorFieldExpression = `$\{${string}}`
6
+
7
+ export type EditorFieldValue = string | number | boolean | unknown
8
+
9
+ export interface FormFieldConfig {
10
+ labelKey?: string
11
+ hintKey?: string
12
+ tooltipKey?: string
13
+ required?: boolean
14
+ locked?: boolean
15
+ invalid?: boolean
16
+ invalidHintKey?: string
17
+ }
18
+
19
+ export interface EditorField {
20
+ // configuration of the form field used as presentation
21
+ formFieldConfig: FormFieldConfig
22
+
23
+ // name of the target field in the record; will not change the record directly if not defined
24
+ model?: CatalogRecordKeys
25
+
26
+ // a hidden field won't show but can still be used to modify the record
27
+ // FIXME: currently this is redundant with an absence of formFieldConfig but necessary for clarity
28
+ hidden?: boolean
29
+
30
+ // the result of this expression will replace the field value on save
31
+ onSaveProcess?: EditorFieldExpression
32
+ }
33
+
34
+ export interface EditorSection {
35
+ labelKey?: string
36
+ descriptionKey?: string
37
+ hidden: boolean
38
+ fields: EditorField[]
39
+ }
40
+
41
+ export interface EditorFieldPage {
42
+ labelKey?: string
43
+ sections: EditorSection[]
44
+ }
45
+
46
+ export interface EditorConfig {
47
+ pages: EditorFieldPage[]
48
+ }
49
+
50
+ export interface EditorFieldState {
51
+ model: string
52
+ value: EditorFieldValue
53
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './wizard-field.model'
2
2
  export * from './wizard-field.type'
3
+ export * from './editor-config.model'