diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts index 424db86741..3fd0fd98a8 100644 --- a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts @@ -252,11 +252,37 @@ describe('editor form', () => { .should('eq', 'Test - resource identifier') }) }) - describe('resource updated', () => { + describe('resource created', () => { beforeEach(() => { cy.get('@aboutSection') - .find('gn-ui-form-field-date-updated') + .find('gn-ui-form-field-date') .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') + .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 e0c619a646..8d8ac394ef 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-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 0f61d940d0..fab46ef54a 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 9ad67ad7d7..eb974f8822 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 93c3990f56..5f10115ddc 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 @@ -73,11 +73,17 @@ (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(FormFieldDateComponent) + ).componentInstance + }) + it('creates a resource created form field', () => { + expect(formField).toBeTruthy() + }) + }) describe('resource updated field', () => { let formField beforeEach(() => { 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 4cf2f5daab..35124632a2 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 448238f460..83fc0352a2 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' diff --git a/libs/feature/editor/src/lib/fields.config.ts b/libs/feature/editor/src/lib/fields.config.ts index 8e0d9b4df1..90f18c4003 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 RESOURCE_IDENTIFIER_FIELD: EditorField = { model: 'resourceIdentifier', formFieldConfig: { @@ -184,6 +192,7 @@ export const ABOUT_SECTION: EditorSection = { fields: [ RECORD_UNIQUE_IDENTIFIER_FIELD, RESOURCE_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 28414b901d..888fac93e9 100644 --- a/translations/de.json +++ b/translations/de.json @@ -234,6 +234,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.resourceIdentifier": "", "editor.record.form.field.resourceUpdated": "Letztes Aktualisierungsdatum", "editor.record.form.field.securityConstraints": "Sicherheitseinschränkung", diff --git a/translations/en.json b/translations/en.json index 62ea740aaa..b981c34973 100644 --- a/translations/en.json +++ b/translations/en.json @@ -234,6 +234,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.resourceIdentifier": "Identifier", "editor.record.form.field.resourceUpdated": "Resource Updated", "editor.record.form.field.securityConstraints": "Security constraint", diff --git a/translations/es.json b/translations/es.json index 5f21daf824..fb97358484 100644 --- a/translations/es.json +++ b/translations/es.json @@ -234,6 +234,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.resourceIdentifier": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", diff --git a/translations/fr.json b/translations/fr.json index 612edba300..27869ab04e 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -234,6 +234,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.resourceIdentifier": "", "editor.record.form.field.resourceUpdated": "Date de dernière révision", "editor.record.form.field.securityConstraints": "Contrainte de sécurité", diff --git a/translations/it.json b/translations/it.json index faaa3ae872..00be1b07a3 100644 --- a/translations/it.json +++ b/translations/it.json @@ -234,6 +234,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.resourceIdentifier": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", diff --git a/translations/nl.json b/translations/nl.json index ef84e7e547..6a9e3f52d7 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -234,6 +234,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.resourceIdentifier": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", diff --git a/translations/pt.json b/translations/pt.json index 1144fb5dc4..2dc58d110a 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -234,6 +234,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.resourceIdentifier": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "", diff --git a/translations/sk.json b/translations/sk.json index 3cfbb37587..bfb02bb2a4 100644 --- a/translations/sk.json +++ b/translations/sk.json @@ -234,6 +234,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.resourceIdentifier": "", "editor.record.form.field.resourceUpdated": "", "editor.record.form.field.securityConstraints": "",