Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Display and Edit Resource Creation date #1053

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion apps/metadata-editor-e2e/src/e2e/edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
.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', () => {
Expand Down
10 changes: 10 additions & 0 deletions libs/common/fixtures/src/lib/editor/editor.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const editorSectionAboutFixture = () => ({
fields: [
editorFieldTitleFixture(),
editorFieldAbstractFixture(),
editorFieldResourceCreatedFixture(),
editorFieldResourceUpdatedFixture(),
editorFieldRecordUpdatedFixture(),
editorFieldUpdateFrequencyFixture(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -144,6 +153,7 @@ export const editorFieldsFixture = () => [
editorFieldTitleFixture(),
editorFieldAbstractFixture(),
editorFieldResourceUpdatedFixture(),
editorFieldResourceCreatedFixture(),
editorFieldRecordUpdatedFixture(),
editorFieldUpdateFrequencyFixture(),
editorFieldTemporalExtentsFixture(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
(valueChange)="valueChange.emit($event)"
></gn-ui-form-field-overviews>
</ng-container>
<ng-container *ngSwitchCase="'resourceCreated'">
ronitjadhav marked this conversation as resolved.
Show resolved Hide resolved
<gn-ui-form-field-date-updated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not have to be changed, but I was wondering if the name of this component is too specific as it serves date updated and date created now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking of the same.
I guess I can change it to gn-ui-form-field-date

[value]="valueAsDate"
(valueChange)="valueChange.emit($event)"
></gn-ui-form-field-date-updated>
</ng-container>
<ng-container *ngSwitchCase="'resourceIdentifier'">
<gn-ui-form-field-simple
[type]="'text'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ describe('FormFieldComponent', () => {
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(() => {
Expand Down
9 changes: 9 additions & 0 deletions libs/feature/editor/src/lib/fields.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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é",
Expand Down
1 change: 1 addition & 0 deletions translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions translations/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Loading