From 3fe0e159980fff9ea2e18d97b5e9775acb211bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure-H=C3=A9l=C3=A8ne=20Bruneton?= Date: Fri, 19 Apr 2024 15:22:06 +0200 Subject: [PATCH] wip --- .../form-field-license.component.css | 0 .../form-field-license.component.html | 9 +++ .../form-field-license.component.spec.ts | 22 +++++++ .../form-field-license.component.ts | 31 ++++++++++ .../form-field/form-field.component.html | 60 +++++++++---------- .../form-field/form-field.component.ts | 12 ++++ .../record-form/record-form.component.ts | 19 +++++- 7 files changed, 118 insertions(+), 35 deletions(-) create mode 100644 libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.css create mode 100644 libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.html create mode 100644 libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.spec.ts create mode 100644 libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.ts diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.css b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.html b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.html new file mode 100644 index 0000000000..4c614284fa --- /dev/null +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.html @@ -0,0 +1,9 @@ +

form-field-license works!

+ + diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.spec.ts b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.spec.ts new file mode 100644 index 0000000000..437084e818 --- /dev/null +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing' + +import { FormFieldLicenseComponent } from './form-field-license.component' + +describe('FormFieldLicenseComponent', () => { + let component: FormFieldLicenseComponent + let fixture: ComponentFixture + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FormFieldLicenseComponent], + }).compileComponents() + + fixture = TestBed.createComponent(FormFieldLicenseComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) + + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.ts b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.ts new file mode 100644 index 0000000000..001c7572aa --- /dev/null +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-license/form-field-license.component.ts @@ -0,0 +1,31 @@ +import { ChangeDetectionStrategy, Component, Input } from '@angular/core' +import { FormControl } from '@angular/forms' +import { marker } from '@biesbjerg/ngx-translate-extract-marker' +import { DropdownSelectorComponent } from '@geonetwork-ui/ui/inputs' + +@Component({ + selector: 'gn-ui-form-field-license', + templateUrl: './form-field-license.component.html', + styleUrls: ['./form-field-license.component.css'], + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [DropdownSelectorComponent], +}) +export class FormFieldLicenseComponent { + @Input() control!: FormControl + + choices = [ + { value: 'cc-by', label: marker('editor.record.form.license.cc-by') }, + { value: 'cc-by-sa', label: marker('editor.record.form.license.cc-by-sa') }, + { value: 'cc-zero', label: marker('editor.record.form.license.cc-zero') }, + { value: 'etalab', label: marker('editor.record.form.license.etalab') }, + { + value: 'etalab-v2', + label: marker('editor.record.form.license.etalab-v2'), + }, + { value: 'odbl', label: marker('editor.record.form.license.odbl') }, + { value: 'odc-by', label: marker('editor.record.form.license.odc-by') }, + { value: 'pddl', label: marker('editor.record.form.license.pddl') }, + { value: 'unknown', label: marker('editor.record.form.license.unknown') }, + ] +} diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html index ee898db249..752afcdf93 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html @@ -1,29 +1,18 @@
-
- - check_circle - lock - cancel + + + + -
+ + + +
+ +

+ + + + + + - - - @@ -89,4 +83,4 @@ > {{ config.invalidHintKey | translate }} - +
diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts index 36417bc8ac..e9fd20d8b7 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts @@ -4,6 +4,7 @@ import { Component, ElementRef, Input, + OnInit, Output, ViewChild, } from '@angular/core' @@ -21,6 +22,8 @@ import { FormFieldSimpleComponent } from './form-field-simple/form-field-simple. import { FormFieldSpatialExtentComponent } from './form-field-spatial-extent/form-field-spatial-extent.component' import { FormFieldTemporalExtentComponent } from './form-field-temporal-extent/form-field-temporal-extent.component' import { FormFieldConfig } from './form-field.model' +import { FormFieldLicenseComponent } from './form-field-license/form-field-license.component' +import { FormFieldWrapperComponent } from '@geonetwork-ui/ui/layout' @Component({ selector: 'gn-ui-form-field', @@ -34,6 +37,7 @@ import { FormFieldConfig } from './form-field.model' EditableLabelDirective, MatIconModule, MatTooltipModule, + FormFieldWrapperComponent, FormFieldSimpleComponent, FormFieldRichComponent, FormFieldObjectComponent, @@ -41,6 +45,7 @@ import { FormFieldConfig } from './form-field.model' FormFieldTemporalExtentComponent, FormFieldFileComponent, FormFieldArrayComponent, + FormFieldLicenseComponent, TranslateModule, ], }) @@ -118,4 +123,11 @@ export class FormFieldComponent { get isAbstract() { return this.model === 'abstract' } + get isLicense() { + return this.model === 'license' + } + + get withoutWrapper() { + return this.model === 'title' || this.model === 'abstract' + } } diff --git a/libs/feature/editor/src/lib/components/record-form/record-form.component.ts b/libs/feature/editor/src/lib/components/record-form/record-form.component.ts index 310fa77fea..b9e55fd658 100644 --- a/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +++ b/libs/feature/editor/src/lib/components/record-form/record-form.component.ts @@ -2,7 +2,9 @@ import { CommonModule } from '@angular/common' import { ChangeDetectionStrategy, Component } from '@angular/core' import { EditorFacade } from '../../+state/editor.facade' import { EditorFieldState, EditorFieldValue } from '../../models/fields.model' -import { FormFieldComponent } from './form-field' +import { FormFieldComponent, FormFieldConfigSimple } from './form-field' +import { map } from 'rxjs' +import { hi } from 'date-fns/locale' @Component({ selector: 'gn-ui-record-form', @@ -13,7 +15,20 @@ import { FormFieldComponent } from './form-field' imports: [CommonModule, FormFieldComponent], }) export class RecordFormComponent { - fields$ = this.facade.recordFields$ + mockLicenseField = { + config: { + formFieldConfig: { + type: 'list', + labelKey: 'editor.record.form.license', + } as FormFieldConfigSimple, + model: 'license', + hidden: false, + }, + value: '', + } + fields$ = this.facade.recordFields$.pipe( + map((fields) => [...fields, this.mockLicenseField]) + ) constructor(public facade: EditorFacade) {}