From 0287f7ce8242f376223bdd8a6bef366cccfe5462 Mon Sep 17 00:00:00 2001 From: ronitjadhav Date: Tue, 3 Dec 2024 13:47:23 +0100 Subject: [PATCH 1/2] Made resourceCreated field editable --- apps/metadata-editor-e2e/src/e2e/edit.cy.ts | 28 ++++++++++++++++++- .../src/lib/editor/editor.fixtures.ts | 10 +++++++ .../form-field/form-field.component.html | 6 ++++ .../form-field/form-field.component.spec.ts | 13 +++++++++ libs/feature/editor/src/lib/fields.config.ts | 9 ++++++ translations/de.json | 1 + translations/en.json | 1 + translations/es.json | 1 + translations/fr.json | 1 + translations/it.json | 1 + translations/nl.json | 1 + translations/pt.json | 1 + translations/sk.json | 1 + 13 files changed, 73 insertions(+), 1 deletion(-) diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts index 035cc8558..10cc21538 100644 --- a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts @@ -227,11 +227,37 @@ describe('editor form', () => { .eq(1) .as('aboutSection') }) - describe('resource updated', () => { + describe('resource created', () => { beforeEach(() => { cy.get('@aboutSection') .find('gn-ui-form-field-date-updated') .eq(0) + .as('resourceCreatedField') + }) + it('shows the resource creation date', () => { + cy.get('@resourceCreatedField') + .find('input') + .invoke('val') + .should('eq', '1/1/2005') + }) + it('edits and saves the resource creation date', () => { + cy.editor_wrapPreviousDraft() + cy.get('@resourceCreatedField') + .find('input') + .type('{selectall}{del}01/01/2019{enter}') + cy.editor_publishAndReload() + cy.get('@saveStatus').should('eq', 'record_up_to_date') + cy.get('@resourceCreatedField') + .find('input') + .invoke('val') + .should('eq', '1/1/2019') + }) + }) + describe('resource updated', () => { + beforeEach(() => { + cy.get('@aboutSection') + .find('gn-ui-form-field-date-updated') + .eq(1) .as('resourceUpdatedField') }) it('shows the resource update date', () => { diff --git a/libs/common/fixtures/src/lib/editor/editor.fixtures.ts b/libs/common/fixtures/src/lib/editor/editor.fixtures.ts index e0c619a64..8d8ac394e 100644 --- a/libs/common/fixtures/src/lib/editor/editor.fixtures.ts +++ b/libs/common/fixtures/src/lib/editor/editor.fixtures.ts @@ -25,6 +25,7 @@ export const editorSectionAboutFixture = () => ({ fields: [ editorFieldTitleFixture(), editorFieldAbstractFixture(), + editorFieldResourceCreatedFixture(), editorFieldResourceUpdatedFixture(), editorFieldRecordUpdatedFixture(), editorFieldUpdateFrequencyFixture(), @@ -71,6 +72,14 @@ export const editorFieldAbstractFixture = () => ({ }, }) +export const editorFieldResourceCreatedFixture = () => ({ + model: 'resourceCreated', + hidden: false, + formFieldConfig: { + labelKey: 'editor.record.form.field.resourceCreated', + }, +}) + export const editorFieldResourceUpdatedFixture = () => ({ model: 'resourceUpdated', hidden: false, @@ -144,6 +153,7 @@ export const editorFieldsFixture = () => [ editorFieldTitleFixture(), editorFieldAbstractFixture(), editorFieldResourceUpdatedFixture(), + editorFieldResourceCreatedFixture(), editorFieldRecordUpdatedFixture(), editorFieldUpdateFrequencyFixture(), editorFieldTemporalExtentsFixture(), 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 7612a1c2a..ee2b83644 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 @@ -65,6 +65,12 @@ (valueChange)="valueChange.emit($event)" > + + + { expect(formField).toBeTruthy() }) }) + describe('resource created field', () => { + let formField + beforeEach(() => { + component.model = 'resourceCreated' + fixture.detectChanges() + formField = fixture.debugElement.query( + By.directive(FormFieldDateUpdatedComponent) + ).componentInstance + }) + it('creates a resource created form field', () => { + expect(formField).toBeTruthy() + }) + }) describe('resource updated field', () => { let formField beforeEach(() => { diff --git a/libs/feature/editor/src/lib/fields.config.ts b/libs/feature/editor/src/lib/fields.config.ts index d64e1eb89..a36113f3b 100644 --- a/libs/feature/editor/src/lib/fields.config.ts +++ b/libs/feature/editor/src/lib/fields.config.ts @@ -66,6 +66,14 @@ export const RECORD_KEYWORDS_FIELD: EditorField = { }, } +export const RECORD_RESOURCE_CREATED_FIELD: EditorField = { + model: 'resourceCreated', + formFieldConfig: { + labelKey: marker('editor.record.form.field.resourceCreated'), + }, + gridColumnSpan: 1, +} + export const RECORD_RESOURCE_UPDATED_FIELD: EditorField = { model: 'resourceUpdated', formFieldConfig: { @@ -176,6 +184,7 @@ export const ABOUT_SECTION: EditorSection = { hidden: false, fields: [ RECORD_UNIQUE_IDENTIFIER_FIELD, + RECORD_RESOURCE_CREATED_FIELD, RECORD_RESOURCE_UPDATED_FIELD, RECORD_UPDATED_FIELD, RECORD_UPDATE_FREQUENCY_FIELD, diff --git a/translations/de.json b/translations/de.json index d7f694a98..19ca5b0a5 100644 --- a/translations/de.json +++ b/translations/de.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "Allgemeine Einschränkung", "editor.record.form.field.overviews": "", "editor.record.form.field.recordUpdated": "Datensatz zuletzt aktualisiert", + "editor.record.form.field.resourceCreated": "", "editor.record.form.field.resourceUpdated": "Letztes Aktualisierungsdatum", "editor.record.form.field.securityConstraints": "Sicherheitseinschränkung", "editor.record.form.field.spatialExtents": "", diff --git a/translations/en.json b/translations/en.json index 30ecb4b41..f3efbb7b1 100644 --- a/translations/en.json +++ b/translations/en.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "Other constraint", "editor.record.form.field.overviews": "Overviews", "editor.record.form.field.recordUpdated": "Record Updated", + "editor.record.form.field.resourceCreated": "Resource Created", "editor.record.form.field.resourceUpdated": "Resource Updated", "editor.record.form.field.securityConstraints": "Security constraint", "editor.record.form.field.spatialExtents": "Spatial extents", diff --git a/translations/es.json b/translations/es.json index fcc99e4f0..87fc0c5cc 100644 --- a/translations/es.json +++ b/translations/es.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "", "editor.record.form.field.overviews": "", "editor.record.form.field.recordUpdated": "", + "editor.record.form.field.resourceCreated": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", "editor.record.form.field.spatialExtents": "", diff --git a/translations/fr.json b/translations/fr.json index b74b97fc4..5d0949bf2 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "Contrainte générale", "editor.record.form.field.overviews": "Aperçus", "editor.record.form.field.recordUpdated": "Date de dernière révision", + "editor.record.form.field.resourceCreated": "", "editor.record.form.field.resourceUpdated": "Date de dernière révision", "editor.record.form.field.securityConstraints": "Contrainte de sécurité", "editor.record.form.field.spatialExtents": "Étendue spatiale", diff --git a/translations/it.json b/translations/it.json index 6c0d71efb..71adf1e4b 100644 --- a/translations/it.json +++ b/translations/it.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "", "editor.record.form.field.overviews": "", "editor.record.form.field.recordUpdated": "", + "editor.record.form.field.resourceCreated": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", "editor.record.form.field.spatialExtents": "", diff --git a/translations/nl.json b/translations/nl.json index 99409151a..3906dce9a 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "", "editor.record.form.field.overviews": "", "editor.record.form.field.recordUpdated": "", + "editor.record.form.field.resourceCreated": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", "editor.record.form.field.spatialExtents": "", diff --git a/translations/pt.json b/translations/pt.json index 2e15157d6..bc4aa5f06 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "", "editor.record.form.field.overviews": "", "editor.record.form.field.recordUpdated": "", + "editor.record.form.field.resourceCreated": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", "editor.record.form.field.spatialExtents": "", diff --git a/translations/sk.json b/translations/sk.json index 64d84d7f8..a3e4f1fb0 100644 --- a/translations/sk.json +++ b/translations/sk.json @@ -240,6 +240,7 @@ "editor.record.form.field.otherConstraints": "", "editor.record.form.field.overviews": "", "editor.record.form.field.recordUpdated": "", + "editor.record.form.field.resourceCreated": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", "editor.record.form.field.spatialExtents": "", From e06d5909e4e060ecbc21f278034682a3abd66e90 Mon Sep 17 00:00:00 2001 From: ronitjadhav Date: Mon, 9 Dec 2024 14:37:14 +0100 Subject: [PATCH 2/2] Renamed component gn-ui-form-field-date to gn-ui-form-field --- apps/metadata-editor-e2e/src/e2e/edit.cy.ts | 4 ++-- .../form-field-date.component.css} | 0 .../form-field-date.component.html} | 0 .../form-field-date.component.spec.ts} | 10 +++++----- .../form-field-date.component.ts} | 8 ++++---- .../form-field/form-field.component.html | 16 ++++++++-------- .../form-field/form-field.component.spec.ts | 6 +++--- .../form-field/form-field.component.ts | 4 ++-- .../components/record-form/form-field/index.ts | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) rename libs/feature/editor/src/lib/components/record-form/form-field/{form-field-date-updated/form-field-date-updated.component.css => form-field-date/form-field-date.component.css} (100%) rename libs/feature/editor/src/lib/components/record-form/form-field/{form-field-date-updated/form-field-date-updated.component.html => form-field-date/form-field-date.component.html} (100%) rename libs/feature/editor/src/lib/components/record-form/form-field/{form-field-date-updated/form-field-date-updated.component.spec.ts => form-field-date/form-field-date.component.spec.ts} (60%) rename libs/feature/editor/src/lib/components/record-form/form-field/{form-field-date-updated/form-field-date-updated.component.ts => form-field-date/form-field-date.component.ts} (64%) diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts index 6c36f077f..3fd0fd98a 100644 --- a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts @@ -255,7 +255,7 @@ describe('editor form', () => { describe('resource created', () => { beforeEach(() => { cy.get('@aboutSection') - .find('gn-ui-form-field-date-updated') + .find('gn-ui-form-field-date') .eq(0) .as('resourceCreatedField') }) @@ -281,7 +281,7 @@ describe('editor form', () => { describe('resource updated', () => { beforeEach(() => { cy.get('@aboutSection') - .find('gn-ui-form-field-date-updated') + .find('gn-ui-form-field-date') .eq(1) .as('resourceUpdatedField') }) diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.css b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.css similarity index 100% rename from libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.css rename to libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.css diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.html b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.html similarity index 100% rename from libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.html rename to libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.html diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.spec.ts b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.spec.ts similarity index 60% rename from libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.spec.ts rename to libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.spec.ts index 0f61d940d..fab46ef54 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.spec.ts +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.spec.ts @@ -1,17 +1,17 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { FormControl } from '@angular/forms' -import { FormFieldDateUpdatedComponent } from './form-field-date-updated.component' +import { FormFieldDateComponent } from './form-field-date.component' describe('FormFieldResourceUpdatedComponent', () => { - let component: FormFieldDateUpdatedComponent - let fixture: ComponentFixture + let component: FormFieldDateComponent + let fixture: ComponentFixture beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [FormFieldDateUpdatedComponent], + imports: [FormFieldDateComponent], }).compileComponents() - fixture = TestBed.createComponent(FormFieldDateUpdatedComponent) + fixture = TestBed.createComponent(FormFieldDateComponent) component = fixture.componentInstance const control = new FormControl() control.setValue(new Date()) diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.ts b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.ts similarity index 64% rename from libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.ts rename to libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.ts index 9ad67ad7d..eb974f882 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date-updated/form-field-date-updated.component.ts +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-date/form-field-date.component.ts @@ -8,14 +8,14 @@ import { import { DatePickerComponent } from '@geonetwork-ui/ui/inputs' @Component({ - selector: 'gn-ui-form-field-date-updated', - templateUrl: './form-field-date-updated.component.html', - styleUrls: ['./form-field-date-updated.component.css'], + selector: 'gn-ui-form-field-date', + templateUrl: './form-field-date.component.html', + styleUrls: ['./form-field-date.component.css'], changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [DatePickerComponent], }) -export class FormFieldDateUpdatedComponent { +export class FormFieldDateComponent { @Input() value: Date @Output() valueChange: EventEmitter = new EventEmitter() } 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 f5712383c..5f10115dd 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 @@ -66,12 +66,6 @@ (valueChange)="valueChange.emit($event)" > - - - + + + - + > { component.model = 'resourceCreated' fixture.detectChanges() formField = fixture.debugElement.query( - By.directive(FormFieldDateUpdatedComponent) + By.directive(FormFieldDateComponent) ).componentInstance }) it('creates a resource created form field', () => { @@ -82,7 +82,7 @@ describe('FormFieldComponent', () => { component.model = 'resourceUpdated' fixture.detectChanges() formField = fixture.debugElement.query( - By.directive(FormFieldDateUpdatedComponent) + By.directive(FormFieldDateComponent) ).componentInstance }) it('creates a resource updated form field', () => { 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 4cf2f5daa..35124632a 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 @@ -26,7 +26,7 @@ import { EditableLabelDirective } from '@geonetwork-ui/ui/inputs' import { FormFieldWrapperComponent } from '@geonetwork-ui/ui/layout' import { TranslateModule } from '@ngx-translate/core' import { - FormFieldDateUpdatedComponent, + FormFieldDateComponent, FormFieldLicenseComponent, FormFieldTemporalExtentsComponent, } from '.' @@ -66,7 +66,7 @@ import { TextFieldModule } from '@angular/cdk/text-field' MatTooltipModule, FormFieldWrapperComponent, FormFieldLicenseComponent, - FormFieldDateUpdatedComponent, + FormFieldDateComponent, FormFieldUpdateFrequencyComponent, FormFieldTemporalExtentsComponent, FormFieldSimpleComponent, diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/index.ts b/libs/feature/editor/src/lib/components/record-form/form-field/index.ts index 448238f46..83fc0352a 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/index.ts +++ b/libs/feature/editor/src/lib/components/record-form/form-field/index.ts @@ -1,6 +1,6 @@ export * from './form-field-keywords/form-field-keywords.component' export * from './form-field-license/form-field-license.component' -export * from './form-field-date-updated/form-field-date-updated.component' +export * from './form-field-date/form-field-date.component' export * from './form-field-temporal-extents/form-field-temporal-extents.component' export * from './form-field-simple/form-field-simple.component' export * from './form-field-file/form-field-file.component'