geonetwork-ui 2.2.0-dev.cbcafed5 → 2.2.0-dev.da2c1f8f
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.
- package/esm2022/libs/api/metadata-converter/src/lib/gn4/atomic-operations.mjs +27 -1
- package/esm2022/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.mjs +64 -61
- package/esm2022/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.mjs +7 -4
- package/esm2022/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.mjs +1 -1
- package/esm2022/libs/api/metadata-converter/src/lib/iso19139/codelists/keyword.mapper.mjs +14 -0
- package/esm2022/libs/api/metadata-converter/src/lib/iso19139/converter.mjs +25 -17
- package/esm2022/libs/api/metadata-converter/src/lib/iso19139/read-parts.mjs +55 -23
- package/esm2022/libs/api/metadata-converter/src/lib/iso19139/write-parts.mjs +52 -32
- package/esm2022/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.mjs +2 -2
- package/esm2022/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.mjs +10 -3
- package/esm2022/libs/api/repository/src/lib/gn4/platform/gn4-platform.mapper.mjs +14 -5
- package/esm2022/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.mjs +33 -8
- package/esm2022/libs/common/domain/src/lib/model/record/metadata.model.mjs +1 -1
- package/esm2022/libs/common/domain/src/lib/model/thesaurus/thesaurus.model.mjs +1 -1
- package/esm2022/libs/common/domain/src/lib/platform.service.interface.mjs +1 -1
- package/esm2022/libs/feature/editor/src/index.mjs +6 -1
- package/esm2022/libs/feature/editor/src/lib/+state/editor.actions.mjs +8 -0
- package/esm2022/libs/feature/editor/src/lib/+state/editor.effects.mjs +26 -0
- package/esm2022/libs/feature/editor/src/lib/+state/editor.facade.mjs +30 -0
- package/esm2022/libs/feature/editor/src/lib/+state/editor.models.mjs +2 -0
- package/esm2022/libs/feature/editor/src/lib/+state/editor.reducer.mjs +42 -0
- package/esm2022/libs/feature/editor/src/lib/+state/editor.selectors.mjs +13 -0
- package/esm2022/libs/feature/editor/src/lib/expressions.mjs +13 -0
- package/esm2022/libs/feature/editor/src/lib/feature-editor.module.mjs +16 -4
- package/esm2022/libs/feature/editor/src/lib/fields.config.mjs +34 -0
- package/esm2022/libs/feature/editor/src/lib/models/fields.model.mjs +2 -0
- package/esm2022/libs/feature/editor/src/lib/record-form/record-form.component.mjs +15 -11
- package/esm2022/libs/feature/editor/src/lib/services/editor.service.mjs +22 -44
- package/esm2022/libs/feature/map/src/lib/map-context/map-context.service.mjs +9 -1
- package/esm2022/libs/feature/record/src/lib/data-view-permalink/data-view-permalink.component.mjs +13 -13
- package/esm2022/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.mjs +3 -3
- package/esm2022/libs/feature/search/src/lib/utils/service/fields.mjs +41 -26
- package/esm2022/libs/feature/search/src/lib/utils/service/fields.service.mjs +11 -9
- package/esm2022/libs/ui/catalog/src/lib/language-switcher/language-switcher.component.mjs +3 -3
- package/esm2022/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.mjs +3 -3
- package/esm2022/libs/ui/elements/src/lib/max-lines/max-lines.component.mjs +5 -3
- package/esm2022/libs/ui/elements/src/lib/metadata-contact/metadata-contact.component.mjs +3 -3
- package/esm2022/libs/ui/elements/src/lib/metadata-info/metadata-info.component.mjs +47 -22
- package/esm2022/libs/ui/elements/src/lib/metadata-quality/metadata-quality.component.mjs +3 -4
- package/esm2022/libs/ui/elements/src/lib/thumbnail/thumbnail.component.mjs +3 -3
- package/esm2022/libs/ui/elements/src/lib/ui-elements.module.mjs +4 -4
- package/esm2022/libs/ui/inputs/src/lib/button/button.component.mjs +9 -9
- package/esm2022/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.mjs +3 -3
- package/esm2022/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.mjs +3 -3
- package/esm2022/libs/ui/inputs/src/lib/form-field/form-field.component.mjs +4 -2
- package/esm2022/libs/ui/inputs/src/lib/form-field/form-field.model.mjs +1 -1
- package/esm2022/libs/ui/inputs/src/lib/navigation-button/navigation-button.component.mjs +3 -3
- package/esm2022/libs/ui/inputs/src/lib/text-area/text-area.component.mjs +3 -3
- package/esm2022/libs/ui/inputs/src/lib/ui-inputs.module.mjs +6 -6
- package/esm2022/libs/ui/layout/src/lib/carousel/carousel.component.mjs +3 -3
- package/esm2022/libs/ui/widgets/src/lib/badge/badge.component.mjs +3 -3
- package/esm2022/libs/util/i18n/src/lib/i18n.constants.mjs +18 -1
- package/esm2022/libs/util/shared/src/lib/utils/index.mjs +2 -1
- package/esm2022/libs/util/shared/src/lib/utils/temporal-extent-union.mjs +32 -0
- package/esm2022/translations/de.json +37 -27
- package/esm2022/translations/en.json +32 -22
- package/esm2022/translations/es.json +27 -17
- package/esm2022/translations/fr.json +50 -40
- package/esm2022/translations/it.json +44 -34
- package/esm2022/translations/nl.json +28 -18
- package/esm2022/translations/pt.json +27 -17
- package/fesm2022/geonetwork-ui.mjs +972 -527
- package/fesm2022/geonetwork-ui.mjs.map +1 -1
- package/libs/api/metadata-converter/src/lib/gn4/atomic-operations.d.ts +2 -0
- package/libs/api/metadata-converter/src/lib/gn4/atomic-operations.d.ts.map +1 -1
- package/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.d.ts +0 -1
- package/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.d.ts.map +1 -1
- package/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.d.ts.map +1 -1
- package/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.d.ts +4 -5
- package/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.d.ts.map +1 -1
- package/libs/api/metadata-converter/src/lib/iso19139/codelists/keyword.mapper.d.ts +3 -0
- package/libs/api/metadata-converter/src/lib/iso19139/codelists/keyword.mapper.d.ts.map +1 -0
- package/libs/api/metadata-converter/src/lib/iso19139/converter.d.ts.map +1 -1
- package/libs/api/metadata-converter/src/lib/iso19139/read-parts.d.ts +7 -6
- package/libs/api/metadata-converter/src/lib/iso19139/read-parts.d.ts.map +1 -1
- package/libs/api/metadata-converter/src/lib/iso19139/write-parts.d.ts +4 -3
- package/libs/api/metadata-converter/src/lib/iso19139/write-parts.d.ts.map +1 -1
- package/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.d.ts.map +1 -1
- package/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.d.ts.map +1 -1
- package/libs/api/repository/src/lib/gn4/platform/gn4-platform.mapper.d.ts +1 -1
- package/libs/api/repository/src/lib/gn4/platform/gn4-platform.mapper.d.ts.map +1 -1
- package/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.d.ts +9 -2
- package/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.d.ts.map +1 -1
- package/libs/common/domain/src/lib/model/record/metadata.model.d.ts +21 -12
- package/libs/common/domain/src/lib/model/record/metadata.model.d.ts.map +1 -1
- package/libs/common/domain/src/lib/model/thesaurus/thesaurus.model.d.ts +1 -0
- package/libs/common/domain/src/lib/model/thesaurus/thesaurus.model.d.ts.map +1 -1
- package/libs/common/domain/src/lib/platform.service.interface.d.ts +1 -1
- package/libs/common/domain/src/lib/platform.service.interface.d.ts.map +1 -1
- package/libs/feature/editor/src/index.d.ts +5 -0
- package/libs/feature/editor/src/index.d.ts.map +1 -1
- package/libs/feature/editor/src/lib/+state/editor.actions.d.ts +23 -0
- package/libs/feature/editor/src/lib/+state/editor.actions.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/+state/editor.effects.d.ts +15 -0
- package/libs/feature/editor/src/lib/+state/editor.effects.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/+state/editor.facade.d.ts +19 -0
- package/libs/feature/editor/src/lib/+state/editor.facade.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/+state/editor.models.d.ts +2 -0
- package/libs/feature/editor/src/lib/+state/editor.models.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/+state/editor.reducer.d.ts +18 -0
- package/libs/feature/editor/src/lib/+state/editor.reducer.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/+state/editor.selectors.d.ts +15 -0
- package/libs/feature/editor/src/lib/+state/editor.selectors.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/expressions.d.ts +4 -0
- package/libs/feature/editor/src/lib/expressions.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/feature-editor.module.d.ts +3 -1
- package/libs/feature/editor/src/lib/feature-editor.module.d.ts.map +1 -1
- package/libs/feature/editor/src/lib/fields.config.d.ts +3 -0
- package/libs/feature/editor/src/lib/fields.config.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/models/fields.model.d.ts +15 -0
- package/libs/feature/editor/src/lib/models/fields.model.d.ts.map +1 -0
- package/libs/feature/editor/src/lib/record-form/record-form.component.d.ts +10 -5
- package/libs/feature/editor/src/lib/record-form/record-form.component.d.ts.map +1 -1
- package/libs/feature/editor/src/lib/services/editor.service.d.ts +3 -13
- package/libs/feature/editor/src/lib/services/editor.service.d.ts.map +1 -1
- package/libs/feature/map/src/lib/map-context/map-context.service.d.ts +1 -0
- package/libs/feature/map/src/lib/map-context/map-context.service.d.ts.map +1 -1
- package/libs/feature/search/src/lib/utils/service/fields.d.ts +21 -8
- package/libs/feature/search/src/lib/utils/service/fields.d.ts.map +1 -1
- package/libs/feature/search/src/lib/utils/service/fields.service.d.ts.map +1 -1
- package/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.d.ts +1 -1
- package/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.d.ts.map +1 -1
- package/libs/ui/elements/src/lib/max-lines/max-lines.component.d.ts.map +1 -1
- package/libs/ui/elements/src/lib/metadata-info/metadata-info.component.d.ts +16 -6
- package/libs/ui/elements/src/lib/metadata-info/metadata-info.component.d.ts.map +1 -1
- package/libs/ui/elements/src/lib/metadata-quality/metadata-quality.component.d.ts.map +1 -1
- package/libs/ui/elements/src/lib/ui-elements.module.d.ts +13 -13
- package/libs/ui/inputs/src/lib/button/button.component.d.ts +1 -1
- package/libs/ui/inputs/src/lib/button/button.component.d.ts.map +1 -1
- package/libs/ui/inputs/src/lib/form-field/form-field.component.d.ts.map +1 -1
- package/libs/ui/inputs/src/lib/form-field/form-field.model.d.ts +0 -1
- package/libs/ui/inputs/src/lib/form-field/form-field.model.d.ts.map +1 -1
- package/libs/ui/inputs/src/lib/text-area/text-area.component.d.ts +1 -1
- package/libs/ui/inputs/src/lib/text-area/text-area.component.d.ts.map +1 -1
- package/libs/ui/inputs/src/lib/ui-inputs.module.d.ts +40 -40
- package/libs/ui/layout/src/lib/interactive-table/interactive-table-column/interactive-table-column.component.d.ts +1 -1
- package/libs/util/i18n/src/lib/i18n.constants.d.ts +17 -0
- package/libs/util/i18n/src/lib/i18n.constants.d.ts.map +1 -1
- package/libs/util/shared/src/lib/utils/index.d.ts +1 -0
- package/libs/util/shared/src/lib/utils/index.d.ts.map +1 -1
- package/libs/util/shared/src/lib/utils/temporal-extent-union.d.ts +5 -0
- package/libs/util/shared/src/lib/utils/temporal-extent-union.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/libs/api/metadata-converter/src/lib/fixtures/generic.records.ts +63 -8
- package/src/libs/api/metadata-converter/src/lib/fixtures/geo2france.records.ts +57 -9
- package/src/libs/api/metadata-converter/src/lib/fixtures/geocat-ch.records.ts +229 -24
- package/src/libs/api/metadata-converter/src/lib/gn4/atomic-operations.ts +29 -0
- package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +99 -76
- package/src/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.ts +6 -3
- package/src/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +4 -5
- package/src/libs/api/metadata-converter/src/lib/iso19139/codelists/keyword.mapper.ts +16 -0
- package/src/libs/api/metadata-converter/src/lib/iso19139/converter.ts +30 -21
- package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +120 -63
- package/src/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts +177 -97
- package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +1 -1
- package/src/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.ts +22 -2
- package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.mapper.ts +15 -4
- package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +47 -8
- package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +25 -14
- package/src/libs/common/domain/src/lib/model/thesaurus/thesaurus.model.ts +1 -0
- package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -4
- package/src/libs/common/fixtures/src/lib/elasticsearch/full-response.ts +1 -1
- package/src/libs/common/fixtures/src/lib/gn4/groups.fixtures.ts +1 -1
- package/src/libs/common/fixtures/src/lib/records.fixtures.ts +52 -10
- package/src/libs/feature/editor/src/index.ts +5 -0
- package/src/libs/feature/editor/src/lib/+state/editor.actions.ts +24 -0
- package/src/libs/feature/editor/src/lib/+state/editor.effects.ts +49 -0
- package/src/libs/feature/editor/src/lib/+state/editor.facade.ts +30 -0
- package/src/libs/feature/editor/src/lib/+state/editor.models.ts +1 -0
- package/src/libs/feature/editor/src/lib/+state/editor.reducer.ts +68 -0
- package/src/libs/feature/editor/src/lib/+state/editor.selectors.ts +39 -0
- package/src/libs/feature/editor/src/lib/expressions.ts +16 -0
- package/src/libs/feature/editor/src/lib/feature-editor.module.ts +11 -0
- package/src/libs/feature/editor/src/lib/fields.config.ts +35 -0
- package/src/libs/feature/editor/src/lib/models/fields.model.ts +29 -0
- package/src/libs/feature/editor/src/lib/record-form/record-form.component.html +9 -7
- package/src/libs/feature/editor/src/lib/record-form/record-form.component.ts +11 -5
- package/src/libs/feature/editor/src/lib/services/editor.service.ts +34 -73
- package/src/libs/feature/map/src/lib/map-context/map-context.service.ts +10 -0
- package/src/libs/feature/record/src/lib/data-view-permalink/data-view-permalink.component.ts +12 -12
- package/src/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.html +3 -4
- package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +21 -16
- package/src/libs/feature/search/src/lib/utils/service/fields.ts +43 -34
- package/src/libs/ui/catalog/src/lib/language-switcher/language-switcher.component.html +1 -1
- package/src/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.css +5 -0
- package/src/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.html +39 -0
- package/src/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.ts +58 -0
- package/src/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.css +2 -2
- package/src/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.ts +1 -0
- package/src/libs/ui/elements/src/lib/max-lines/max-lines.component.html +5 -1
- package/src/libs/ui/elements/src/lib/max-lines/max-lines.component.ts +1 -0
- package/src/libs/ui/elements/src/lib/metadata-contact/metadata-contact.component.html +1 -1
- package/src/libs/ui/elements/src/lib/metadata-info/metadata-info.component.html +169 -52
- package/src/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts +51 -15
- package/src/libs/ui/elements/src/lib/metadata-quality/metadata-quality.component.ts +2 -3
- package/src/libs/ui/elements/src/lib/thumbnail/thumbnail.component.html +2 -2
- package/src/libs/ui/elements/src/lib/ui-elements.module.ts +1 -1
- package/src/libs/ui/inputs/src/lib/button/button.component.css +0 -5
- package/src/libs/ui/inputs/src/lib/button/button.component.html +0 -1
- package/src/libs/ui/inputs/src/lib/button/button.component.ts +7 -6
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +1 -1
- package/src/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.html +3 -1
- package/src/libs/ui/inputs/src/lib/form-field/form-field.component.ts +3 -1
- package/src/libs/ui/inputs/src/lib/form-field/form-field.model.ts +0 -1
- package/src/libs/ui/inputs/src/lib/navigation-button/navigation-button.component.css +3 -0
- package/src/libs/ui/inputs/src/lib/navigation-button/navigation-button.component.html +1 -1
- package/src/libs/ui/inputs/src/lib/text-area/text-area.component.ts +1 -0
- package/src/libs/ui/inputs/src/lib/ui-inputs.module.ts +2 -2
- package/src/libs/ui/layout/src/lib/carousel/carousel.component.html +1 -0
- package/src/libs/ui/widgets/src/lib/badge/badge.component.html +3 -1
- package/src/libs/util/i18n/src/lib/i18n.constants.ts +18 -0
- package/src/libs/util/shared/src/lib/utils/index.ts +1 -0
- package/src/libs/util/shared/src/lib/utils/temporal-extent-union.ts +32 -0
- package/tailwind.base.css +44 -15
- package/translations/de.json +37 -27
- package/translations/en.json +32 -22
- package/translations/es.json +27 -17
- package/translations/fr.json +50 -40
- package/translations/it.json +44 -34
- package/translations/nl.json +28 -18
- package/translations/pt.json +27 -17
- package/translations/sk.json +118 -108
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EditorFieldsConfig } from './models/fields.model'
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_FIELDS: EditorFieldsConfig = [
|
|
4
|
+
{
|
|
5
|
+
model: 'title',
|
|
6
|
+
formFieldConfig: {
|
|
7
|
+
labelKey: 'Metadata title',
|
|
8
|
+
type: 'text',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
model: 'abstract',
|
|
13
|
+
formFieldConfig: {
|
|
14
|
+
labelKey: 'Abstract',
|
|
15
|
+
type: 'rich',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
model: 'uniqueIdentifier',
|
|
20
|
+
formFieldConfig: {
|
|
21
|
+
labelKey: 'Unique identifier',
|
|
22
|
+
type: 'text',
|
|
23
|
+
locked: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
model: 'recordUpdated',
|
|
28
|
+
formFieldConfig: {
|
|
29
|
+
labelKey: 'Record Updated',
|
|
30
|
+
type: 'text',
|
|
31
|
+
locked: true,
|
|
32
|
+
},
|
|
33
|
+
onSaveProcess: '${dateNow()}',
|
|
34
|
+
},
|
|
35
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FormFieldConfig } from '../../../../../../libs/ui/inputs/src'
|
|
2
|
+
|
|
3
|
+
// Expressions should be enclosed in `${}` to be recognized as such
|
|
4
|
+
// eg. ${dateNow()}
|
|
5
|
+
export type EditorFieldExpression = `$\{${string}}`
|
|
6
|
+
|
|
7
|
+
export interface EditorFieldConfig {
|
|
8
|
+
// configuration of the form field used as presentation; optional, nothing shown if not defined
|
|
9
|
+
formFieldConfig?: FormFieldConfig
|
|
10
|
+
|
|
11
|
+
// name of the target field in the record; will not change the record directly if not defined
|
|
12
|
+
model?: string
|
|
13
|
+
|
|
14
|
+
// a hidden field won't show but can still be used to modify the record
|
|
15
|
+
// FIXME: currently this is redundant with an absence of formFieldConfig but necessary for clarity
|
|
16
|
+
hidden?: boolean
|
|
17
|
+
|
|
18
|
+
// the result of this expression will replace the field value on save
|
|
19
|
+
onSaveProcess?: EditorFieldExpression
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type EditorFieldsConfig = EditorFieldConfig[]
|
|
23
|
+
|
|
24
|
+
export type EditorFieldValue = string | number | boolean | unknown
|
|
25
|
+
|
|
26
|
+
export interface EditorFieldState {
|
|
27
|
+
config: EditorFieldConfig
|
|
28
|
+
value: string | number | boolean | unknown
|
|
29
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
<div class="flex flex-col gap-6">
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
[config]="field.config.formFieldConfig"
|
|
6
|
+
[value]="field.value"
|
|
7
|
+
(valueChange)="handleFieldValueChange(field, $event)"
|
|
8
|
+
></gn-ui-form-field>
|
|
9
|
+
</ng-container>
|
|
8
10
|
</div>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CommonModule } from '@angular/common'
|
|
2
2
|
import { ChangeDetectionStrategy, Component } from '@angular/core'
|
|
3
|
-
import { EditorService, FormField } from '../services/editor.service'
|
|
4
3
|
import { UiInputsModule } from '../../../../../../libs/ui/inputs/src'
|
|
4
|
+
import { EditorFacade } from '../+state/editor.facade'
|
|
5
|
+
import { EditorFieldState, EditorFieldValue } from '../models/fields.model'
|
|
5
6
|
|
|
6
7
|
@Component({
|
|
7
8
|
selector: 'gn-ui-record-form',
|
|
@@ -12,13 +13,18 @@ import { UiInputsModule } from '../../../../../../libs/ui/inputs/src'
|
|
|
12
13
|
imports: [CommonModule, UiInputsModule],
|
|
13
14
|
})
|
|
14
15
|
export class RecordFormComponent {
|
|
15
|
-
|
|
16
|
+
fields$ = this.facade.recordFields$
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
constructor(public facade: EditorFacade) {}
|
|
19
|
+
|
|
20
|
+
handleFieldValueChange(field: EditorFieldState, newValue: EditorFieldValue) {
|
|
21
|
+
if (!field.config.model) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
this.facade.updateRecordField(field.config.model, newValue)
|
|
19
25
|
}
|
|
20
26
|
|
|
21
|
-
fieldTracker(index: number, field:
|
|
27
|
+
fieldTracker(index: number, field: EditorFieldState) {
|
|
22
28
|
return field.config.model
|
|
23
29
|
}
|
|
24
30
|
}
|
|
@@ -1,59 +1,27 @@
|
|
|
1
1
|
import { Inject, Injectable, Optional } from '@angular/core'
|
|
2
2
|
import { toModel, toXml } from '../../../../../../libs/api/metadata-converter/src'
|
|
3
3
|
import { Configuration } from '../../../../../../libs/data-access/gn4/src'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Observable } from 'rxjs'
|
|
5
|
+
import { map } from 'rxjs/operators'
|
|
6
6
|
import { HttpClient } from '@angular/common/http'
|
|
7
|
-
import { FormFieldConfig } from '../../../../../../libs/ui/inputs/src'
|
|
8
7
|
import { CatalogRecord } from '../../../../../../libs/common/domain/src/lib/model/record'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
config: FormFieldConfig
|
|
12
|
-
value: string | number | boolean | unknown
|
|
13
|
-
}
|
|
8
|
+
import { EditorFieldsConfig } from '../models/fields.model'
|
|
9
|
+
import { evaluate } from '../expressions'
|
|
14
10
|
|
|
15
11
|
@Injectable({
|
|
16
12
|
providedIn: 'root',
|
|
17
13
|
})
|
|
18
14
|
export class EditorService {
|
|
19
|
-
private record$ = new BehaviorSubject<CatalogRecord | null>(null)
|
|
20
|
-
private fieldsConfig: FormFieldConfig[] = [
|
|
21
|
-
{
|
|
22
|
-
model: 'title',
|
|
23
|
-
labelKey: 'Metadata title',
|
|
24
|
-
type: 'text',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
model: 'abstract',
|
|
28
|
-
labelKey: 'Abstract',
|
|
29
|
-
type: 'rich',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
model: 'uniqueIdentifier',
|
|
33
|
-
labelKey: 'Unique identifier',
|
|
34
|
-
type: 'text',
|
|
35
|
-
locked: true,
|
|
36
|
-
},
|
|
37
|
-
]
|
|
38
|
-
|
|
39
15
|
private apiUrl = `${this.apiConfiguration?.basePath || '/geonetwork/srv/api'}`
|
|
40
16
|
|
|
41
|
-
fields$: Observable<FormField[]> = this.record$.pipe(
|
|
42
|
-
map((record) =>
|
|
43
|
-
this.fieldsConfig.map((fieldConfig) => ({
|
|
44
|
-
config: fieldConfig,
|
|
45
|
-
value: record?.[fieldConfig.model] || null,
|
|
46
|
-
}))
|
|
47
|
-
)
|
|
48
|
-
)
|
|
49
|
-
saving$ = new BehaviorSubject(false)
|
|
50
|
-
|
|
51
17
|
constructor(
|
|
52
18
|
private http: HttpClient,
|
|
53
19
|
@Optional()
|
|
54
20
|
@Inject(Configuration)
|
|
55
21
|
private apiConfiguration: Configuration
|
|
56
22
|
) {}
|
|
23
|
+
|
|
24
|
+
// TODO: use the catalog repository instead
|
|
57
25
|
loadRecordByUuid(uuid: string): Observable<CatalogRecord> {
|
|
58
26
|
return this.http
|
|
59
27
|
.get(`${this.apiUrl}/records/${uuid}/formatters/xml`, {
|
|
@@ -65,43 +33,36 @@ export class EditorService {
|
|
|
65
33
|
.pipe(map((response) => toModel(response.toString())))
|
|
66
34
|
}
|
|
67
35
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.saving$.next(true)
|
|
75
|
-
}),
|
|
76
|
-
switchMap((record) =>
|
|
77
|
-
this.http.put(
|
|
78
|
-
`${this.apiUrl}/records?metadataType=METADATA&uuidProcessing=OVERWRITE&transformWith=_none_&publishToAll=on`,
|
|
79
|
-
toXml(record),
|
|
80
|
-
{
|
|
81
|
-
headers: {
|
|
82
|
-
'Content-Type': 'application/xml',
|
|
83
|
-
},
|
|
84
|
-
withCredentials: true,
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
),
|
|
88
|
-
map(() => undefined),
|
|
89
|
-
finalize(() => {
|
|
90
|
-
this.saving$.next(false)
|
|
91
|
-
})
|
|
92
|
-
)
|
|
93
|
-
}
|
|
36
|
+
// returns the record as it was when saved
|
|
37
|
+
saveRecord(
|
|
38
|
+
record: CatalogRecord,
|
|
39
|
+
fieldsConfig: EditorFieldsConfig
|
|
40
|
+
): Observable<CatalogRecord> {
|
|
41
|
+
const savedRecord = { ...record }
|
|
94
42
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
43
|
+
// run onSave processes
|
|
44
|
+
for (const field of fieldsConfig) {
|
|
45
|
+
if (field.onSaveProcess && field.model) {
|
|
46
|
+
const evaluator = evaluate(field.onSaveProcess)
|
|
47
|
+
savedRecord[field.model] = evaluator({
|
|
48
|
+
config: field,
|
|
49
|
+
value: record[field.model],
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
|
98
53
|
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
.
|
|
102
|
-
|
|
103
|
-
|
|
54
|
+
// TODO: use the catalog repository instead
|
|
55
|
+
return this.http
|
|
56
|
+
.put(
|
|
57
|
+
`${this.apiUrl}/records?metadataType=METADATA&uuidProcessing=OVERWRITE&transformWith=_none_&publishToAll=on`,
|
|
58
|
+
toXml(savedRecord),
|
|
59
|
+
{
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/xml',
|
|
62
|
+
},
|
|
63
|
+
withCredentials: true,
|
|
64
|
+
}
|
|
104
65
|
)
|
|
105
|
-
.
|
|
66
|
+
.pipe(map(() => savedRecord))
|
|
106
67
|
}
|
|
107
68
|
}
|
|
@@ -58,6 +58,8 @@ export class MapContextService {
|
|
|
58
58
|
): Map {
|
|
59
59
|
if (mapConfig) {
|
|
60
60
|
mapContext = this.mergeMapConfigWithContext(mapContext, mapConfig)
|
|
61
|
+
} else {
|
|
62
|
+
mapContext.layers = this.addDefaultBaselayerContext(mapContext.layers)
|
|
61
63
|
}
|
|
62
64
|
if (
|
|
63
65
|
!mapContext.view?.extent &&
|
|
@@ -179,6 +181,14 @@ export class MapContextService {
|
|
|
179
181
|
return view
|
|
180
182
|
}
|
|
181
183
|
|
|
184
|
+
addDefaultBaselayerContext(
|
|
185
|
+
layers: MapContextLayerModel[]
|
|
186
|
+
): MapContextLayerModel[] {
|
|
187
|
+
return layers.includes(DEFAULT_BASELAYER_CONTEXT)
|
|
188
|
+
? layers
|
|
189
|
+
: [DEFAULT_BASELAYER_CONTEXT, ...layers]
|
|
190
|
+
}
|
|
191
|
+
|
|
182
192
|
mergeMapConfigWithContext(
|
|
183
193
|
mapContext: MapContextModel,
|
|
184
194
|
mapConfig: MapConfig
|
package/src/libs/feature/record/src/lib/data-view-permalink/data-view-permalink.component.ts
CHANGED
|
@@ -29,18 +29,18 @@ export class DataViewPermalinkComponent {
|
|
|
29
29
|
if (config) {
|
|
30
30
|
const { aggregation, xProperty, yProperty, chartType } = config
|
|
31
31
|
const url = new URL(`${this.wcEmbedderBaseUrl}`, window.location.origin)
|
|
32
|
-
url.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
url.searchParams.set('v', `${this.version}`)
|
|
33
|
+
url.searchParams.append('e', `gn-dataset-view-chart`)
|
|
34
|
+
url.searchParams.append('a', `api-url=${this.config.basePath}`)
|
|
35
|
+
url.searchParams.append('a', `dataset-id=${metadata.uniqueIdentifier}`)
|
|
36
|
+
url.searchParams.append('a', `primary-color=#0f4395`)
|
|
37
|
+
url.searchParams.append('a', `secondary-color=#8bc832`)
|
|
38
|
+
url.searchParams.append('a', `main-color=#555`)
|
|
39
|
+
url.searchParams.append('a', `background-color=#fdfbff`)
|
|
40
|
+
url.searchParams.append('a', `aggregation=${aggregation}`)
|
|
41
|
+
url.searchParams.append('a', `x-property=${xProperty}`)
|
|
42
|
+
url.searchParams.append('a', `y-property=${yProperty}`)
|
|
43
|
+
url.searchParams.append('a', `chart-type=${chartType}`)
|
|
44
44
|
return url.toString()
|
|
45
45
|
}
|
|
46
46
|
return ''
|
package/src/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.html
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<div class="flex flex-row
|
|
1
|
+
<div class="flex flex-row items-center">
|
|
2
2
|
<span
|
|
3
|
-
class="align-text-top mr-1.5
|
|
3
|
+
class="align-text-top mr-1.5 favorite-count"
|
|
4
4
|
*ngIf="hasFavoriteCount && displayCount"
|
|
5
5
|
>{{ favoriteCount }}</span
|
|
6
6
|
>
|
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
[toggled]="isFavorite$ | async"
|
|
9
9
|
(newValue)="toggleFavorite($event)"
|
|
10
10
|
[disabled]="loading || (isAnonymous$ | async)"
|
|
11
|
-
class="mt-1"
|
|
12
11
|
></gn-ui-star-toggle>
|
|
13
12
|
<span
|
|
14
|
-
class="align-text-top ml-1.5 favorite-count
|
|
13
|
+
class="align-text-top ml-1.5 favorite-count"
|
|
15
14
|
*ngIf="!displayCount"
|
|
16
15
|
translate="datahub.record.addToFavorites"
|
|
17
16
|
></span>
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
FieldValue,
|
|
5
5
|
FullTextSearchField,
|
|
6
6
|
IsSpatialSearchField,
|
|
7
|
-
KeySearchField,
|
|
8
7
|
LicenseSearchField,
|
|
8
|
+
MultilingualSearchField,
|
|
9
9
|
OrganizationSearchField,
|
|
10
10
|
OwnerSearchField,
|
|
11
11
|
SimpleSearchField,
|
|
12
|
-
|
|
12
|
+
TranslatedSearchField,
|
|
13
13
|
} from './fields'
|
|
14
14
|
import { forkJoin, Observable, of } from 'rxjs'
|
|
15
15
|
import { map } from 'rxjs/operators'
|
|
@@ -21,6 +21,7 @@ export type FieldValues = Record<string, FieldValue[] | FieldValue>
|
|
|
21
21
|
|
|
22
22
|
marker('search.filters.format')
|
|
23
23
|
marker('search.filters.inspireKeyword')
|
|
24
|
+
marker('search.filters.keyword')
|
|
24
25
|
marker('search.filters.isSpatial')
|
|
25
26
|
marker('search.filters.license')
|
|
26
27
|
marker('search.filters.publicationYear')
|
|
@@ -37,29 +38,33 @@ marker('search.filters.contact')
|
|
|
37
38
|
export class FieldsService {
|
|
38
39
|
private fields = {
|
|
39
40
|
publisher: new OrganizationSearchField(this.injector),
|
|
40
|
-
format: new SimpleSearchField('format', 'asc'
|
|
41
|
-
resourceType: new
|
|
42
|
-
|
|
41
|
+
format: new SimpleSearchField('format', this.injector, 'asc'),
|
|
42
|
+
resourceType: new TranslatedSearchField(
|
|
43
|
+
'resourceType',
|
|
44
|
+
this.injector,
|
|
45
|
+
'asc'
|
|
46
|
+
),
|
|
47
|
+
representationType: new TranslatedSearchField(
|
|
43
48
|
'cl_spatialRepresentationType.key',
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
this.injector,
|
|
50
|
+
'asc'
|
|
46
51
|
),
|
|
47
52
|
publicationYear: new SimpleSearchField(
|
|
48
53
|
'publicationYearForResource',
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
this.injector,
|
|
55
|
+
'desc'
|
|
51
56
|
),
|
|
52
|
-
topic: new
|
|
53
|
-
inspireKeyword: new
|
|
57
|
+
topic: new TranslatedSearchField('cl_topic.key', this.injector, 'asc'),
|
|
58
|
+
inspireKeyword: new TranslatedSearchField(
|
|
54
59
|
'th_httpinspireeceuropaeutheme-theme.link',
|
|
55
|
-
|
|
56
|
-
'asc'
|
|
57
|
-
this.injector
|
|
60
|
+
this.injector,
|
|
61
|
+
'asc'
|
|
58
62
|
),
|
|
63
|
+
keyword: new MultilingualSearchField('tag', this.injector, 'desc', 'count'),
|
|
59
64
|
documentStandard: new SimpleSearchField(
|
|
60
65
|
'documentStandard',
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
this.injector,
|
|
67
|
+
'asc'
|
|
63
68
|
),
|
|
64
69
|
isSpatial: new IsSpatialSearchField(this.injector),
|
|
65
70
|
q: new FullTextSearchField(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { firstValueFrom, Observable, of, switchMap
|
|
2
|
-
import {
|
|
1
|
+
import { firstValueFrom, Observable, of, switchMap } from 'rxjs'
|
|
2
|
+
import { map } from 'rxjs/operators'
|
|
3
3
|
import { Injector } from '@angular/core'
|
|
4
4
|
import { TranslateService } from '@ngx-translate/core'
|
|
5
5
|
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
FieldFilters,
|
|
14
14
|
TermBucket,
|
|
15
15
|
} from '../../../../../../../libs/common/domain/src/lib/model/search'
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ElasticsearchService,
|
|
18
|
+
METADATA_LANGUAGE,
|
|
19
|
+
} from '../../../../../../../libs/api/repository/src'
|
|
17
20
|
import { LangService } from '../../../../../../../libs/util/i18n/src'
|
|
18
21
|
|
|
19
22
|
export type FieldValue = string | number
|
|
@@ -36,8 +39,9 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
36
39
|
|
|
37
40
|
constructor(
|
|
38
41
|
protected esFieldName: string,
|
|
42
|
+
protected injector: Injector,
|
|
39
43
|
protected order: 'asc' | 'desc' = 'asc',
|
|
40
|
-
protected
|
|
44
|
+
protected orderType: 'key' | 'count' = 'key'
|
|
41
45
|
) {}
|
|
42
46
|
|
|
43
47
|
protected getAggregations(): AggregationsParams {
|
|
@@ -46,13 +50,13 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
46
50
|
type: 'terms',
|
|
47
51
|
field: this.esFieldName,
|
|
48
52
|
limit: 1000,
|
|
49
|
-
sort: [this.order,
|
|
53
|
+
sort: [this.order, this.orderType],
|
|
50
54
|
},
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
protected async getBucketLabel(bucket: TermBucket): Promise<string> {
|
|
55
|
-
return bucket.term
|
|
59
|
+
return bucket.term.toString()
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
getAvailableValues(): Observable<FieldAvailableValue[]> {
|
|
@@ -88,9 +92,18 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
export class
|
|
95
|
+
export class TranslatedSearchField extends SimpleSearchField {
|
|
92
96
|
protected platformService = this.injector.get(PlatformServiceInterface)
|
|
93
97
|
|
|
98
|
+
constructor(
|
|
99
|
+
protected esFieldName: string,
|
|
100
|
+
protected injector: Injector,
|
|
101
|
+
protected order: 'asc' | 'desc' = 'asc',
|
|
102
|
+
protected orderType: 'key' | 'count' = 'key'
|
|
103
|
+
) {
|
|
104
|
+
super(esFieldName, injector, order, orderType)
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
protected async getTranslation(key: string) {
|
|
95
108
|
return firstValueFrom(this.platformService.translateKey(key))
|
|
96
109
|
}
|
|
@@ -100,6 +113,7 @@ export class KeySearchField extends SimpleSearchField {
|
|
|
100
113
|
}
|
|
101
114
|
|
|
102
115
|
getAvailableValues(): Observable<FieldAvailableValue[]> {
|
|
116
|
+
if (this.orderType === 'count') return super.getAvailableValues()
|
|
103
117
|
// sort values by alphabetical order
|
|
104
118
|
return super
|
|
105
119
|
.getAvailableValues()
|
|
@@ -111,34 +125,29 @@ export class KeySearchField extends SimpleSearchField {
|
|
|
111
125
|
}
|
|
112
126
|
}
|
|
113
127
|
|
|
114
|
-
|
|
128
|
+
/**
|
|
129
|
+
* This search field will either target the `.default` field, or a specific `.langxyz` field according
|
|
130
|
+
* to the defined METADATA_LANGUAGE token
|
|
131
|
+
* The provided ES field name should not include any prefix such as `.langeng`
|
|
132
|
+
*/
|
|
133
|
+
export class MultilingualSearchField extends SimpleSearchField {
|
|
115
134
|
private langService = this.injector.get(LangService)
|
|
116
|
-
private
|
|
117
|
-
.getThesaurusByLang(this.thesaurusName, this.langService.iso3)
|
|
118
|
-
.pipe(
|
|
119
|
-
catchError(() => {
|
|
120
|
-
console.warn('Error while loading thesaurus language package')
|
|
121
|
-
return of([])
|
|
122
|
-
}),
|
|
123
|
-
shareReplay(1)
|
|
124
|
-
)
|
|
135
|
+
private searchLanguage = this.injector.get(METADATA_LANGUAGE, null)
|
|
125
136
|
|
|
126
137
|
constructor(
|
|
127
|
-
esFieldName: string,
|
|
128
|
-
protected
|
|
129
|
-
order: 'asc' | 'desc' = 'asc',
|
|
130
|
-
|
|
138
|
+
protected esFieldName: string,
|
|
139
|
+
protected injector: Injector,
|
|
140
|
+
protected order: 'asc' | 'desc' = 'asc',
|
|
141
|
+
protected orderType: 'key' | 'count' = 'key'
|
|
131
142
|
) {
|
|
132
|
-
super(esFieldName, order,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
)
|
|
141
|
-
)
|
|
143
|
+
super(esFieldName, injector, order, orderType)
|
|
144
|
+
// note: we're excluding the metadata language "current" value because that would produce
|
|
145
|
+
// permalinks that might not work for different users
|
|
146
|
+
if (this.searchLanguage && this.searchLanguage !== 'current') {
|
|
147
|
+
this.esFieldName += `.lang${this.searchLanguage}`
|
|
148
|
+
} else {
|
|
149
|
+
this.esFieldName += '.default'
|
|
150
|
+
}
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
|
|
@@ -163,7 +172,7 @@ export class IsSpatialSearchField extends SimpleSearchField {
|
|
|
163
172
|
private translateService = this.injector.get(TranslateService)
|
|
164
173
|
|
|
165
174
|
constructor(injector: Injector) {
|
|
166
|
-
super('isSpatial', 'asc'
|
|
175
|
+
super('isSpatial', injector, 'asc')
|
|
167
176
|
this.esService.registerRuntimeField(
|
|
168
177
|
'isSpatial',
|
|
169
178
|
`String result = 'no';
|
|
@@ -223,7 +232,7 @@ export class LicenseSearchField extends SimpleSearchField {
|
|
|
223
232
|
private translateService = this.injector.get(TranslateService)
|
|
224
233
|
|
|
225
234
|
constructor(injector: Injector) {
|
|
226
|
-
super('license', 'asc'
|
|
235
|
+
super('license', injector, 'asc')
|
|
227
236
|
this.esService.registerRuntimeField(
|
|
228
237
|
'license',
|
|
229
238
|
`String raw = '';
|
|
@@ -330,7 +339,7 @@ export class OrganizationSearchField implements AbstractSearchField {
|
|
|
330
339
|
}
|
|
331
340
|
export class OwnerSearchField extends SimpleSearchField {
|
|
332
341
|
constructor(injector: Injector) {
|
|
333
|
-
super('owner', 'asc'
|
|
342
|
+
super('owner', injector, 'asc')
|
|
334
343
|
}
|
|
335
344
|
|
|
336
345
|
getAvailableValues(): Observable<FieldAvailableValue[]> {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<div class="h-full flex flex-col">
|
|
2
|
+
<div class="flex-none w-full flex flex-row items-center">
|
|
3
|
+
<p class="flex-none font-bold">{{ label }}</p>
|
|
4
|
+
<div class="flex-1 flex justify-end items-center">
|
|
5
|
+
<gn-ui-button
|
|
6
|
+
[extraClass]="getButtonExtraClass()"
|
|
7
|
+
(buttonClick)="togglePreview()"
|
|
8
|
+
>
|
|
9
|
+
<span class="material-symbols-outlined mr-1 icon-small">{{
|
|
10
|
+
preview ? 'visibility' : 'visibility_off'
|
|
11
|
+
}}</span>
|
|
12
|
+
{{ preview ? 'WYSIWYG' : 'Markdown' }}
|
|
13
|
+
</gn-ui-button>
|
|
14
|
+
<span
|
|
15
|
+
class="material-symbols-outlined m-2 icon-small"
|
|
16
|
+
[matTooltip]="tooltip"
|
|
17
|
+
matTooltipPosition="above"
|
|
18
|
+
>
|
|
19
|
+
help
|
|
20
|
+
</span>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<p class="flex-none mb-2 font-medium text-sm text-gray-900">
|
|
24
|
+
{{ helperText }}
|
|
25
|
+
</p>
|
|
26
|
+
<div class="flex-1" [hidden]="preview">
|
|
27
|
+
<gn-ui-text-area
|
|
28
|
+
[placeholder]="placeholder"
|
|
29
|
+
[value]="textContent"
|
|
30
|
+
(valueChange)="textContentChangedHandler($event)"
|
|
31
|
+
></gn-ui-text-area>
|
|
32
|
+
</div>
|
|
33
|
+
<div
|
|
34
|
+
class="flex-1 border border-gray-800 rounded overflow-y-scroll"
|
|
35
|
+
[hidden]="!preview"
|
|
36
|
+
>
|
|
37
|
+
<gn-ui-markdown-parser [textContent]="textContent"></gn-ui-markdown-parser>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common'
|
|
2
|
+
import {
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
Input,
|
|
7
|
+
Output,
|
|
8
|
+
} from '@angular/core'
|
|
9
|
+
import { FormsModule } from '@angular/forms'
|
|
10
|
+
import { MarkdownParserComponent } from '../markdown-parser/markdown-parser.component'
|
|
11
|
+
import { TranslateModule } from '@ngx-translate/core'
|
|
12
|
+
import { ButtonComponent, TextAreaComponent } from '../../../../../../libs/ui/inputs/src'
|
|
13
|
+
import { MatIconModule } from '@angular/material/icon'
|
|
14
|
+
import { MatTooltipModule } from '@angular/material/tooltip'
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'gn-ui-markdown-editor',
|
|
18
|
+
templateUrl: './markdown-editor.component.html',
|
|
19
|
+
styleUrls: ['./markdown-editor.component.css'],
|
|
20
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
21
|
+
standalone: true,
|
|
22
|
+
imports: [
|
|
23
|
+
CommonModule,
|
|
24
|
+
FormsModule,
|
|
25
|
+
MatIconModule,
|
|
26
|
+
MatTooltipModule,
|
|
27
|
+
ButtonComponent,
|
|
28
|
+
TextAreaComponent,
|
|
29
|
+
MarkdownParserComponent,
|
|
30
|
+
TranslateModule,
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
export class MarkdownEditorComponent {
|
|
34
|
+
@Input() label: string
|
|
35
|
+
@Input() tooltip?: string
|
|
36
|
+
@Input() helperText?: string
|
|
37
|
+
@Input() placeholder: string
|
|
38
|
+
@Input() textContent: string
|
|
39
|
+
@Output() textContentChanged: EventEmitter<string> =
|
|
40
|
+
new EventEmitter<string>()
|
|
41
|
+
|
|
42
|
+
preview = false
|
|
43
|
+
|
|
44
|
+
getButtonExtraClass() {
|
|
45
|
+
return `${
|
|
46
|
+
this.preview ? 'text-gray-200 bg-gray-900' : 'text-gray-900 bg-gray-200'
|
|
47
|
+
} rounded-[1.25rem] p-[0.375rem] text-xs font-medium w-24`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
togglePreview() {
|
|
51
|
+
this.preview = !this.preview
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
textContentChangedHandler(textContent: string) {
|
|
55
|
+
this.textContent = textContent
|
|
56
|
+
this.textContentChanged.emit(this.textContent)
|
|
57
|
+
}
|
|
58
|
+
}
|