-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #902 from geonetwork/me-fix-new-record-editor
Metadata Editor: implement record creation
- Loading branch information
Showing
21 changed files
with
516 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { TestBed } from '@angular/core/testing' | ||
import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' | ||
import { NewRecordResolver } from './new-record.resolver' | ||
|
||
describe('NewRecordResolver', () => { | ||
let resolver: NewRecordResolver | ||
let resolvedData: [CatalogRecord, string, boolean] | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}) | ||
resolver = TestBed.inject(NewRecordResolver) | ||
}) | ||
|
||
it('should be created', () => { | ||
expect(resolver).toBeTruthy() | ||
}) | ||
|
||
describe('new record', () => { | ||
beforeEach(() => { | ||
resolvedData = undefined | ||
resolver.resolve().subscribe((r) => (resolvedData = r)) | ||
}) | ||
it('creates a new empty record with a pregenerated id', () => { | ||
expect(resolvedData).toMatchObject([ | ||
{ | ||
abstract: '', | ||
kind: 'dataset', | ||
recordUpdated: expect.any(Date), | ||
status: 'ongoing', | ||
temporalExtents: [], | ||
title: expect.stringMatching(/^My new record/), | ||
uniqueIdentifier: expect.stringMatching(/^TEMP-ID-/), | ||
}, | ||
null, | ||
false, | ||
]) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Injectable } from '@angular/core' | ||
import { Observable, of } from 'rxjs' | ||
import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class NewRecordResolver { | ||
resolve(): Observable<[CatalogRecord, string, boolean]> { | ||
return of([ | ||
{ | ||
uniqueIdentifier: `TEMP-ID-${Date.now()}`, | ||
title: `My new record (${new Date().toISOString()})`, | ||
abstract: '', | ||
ownerOrganization: {}, | ||
contacts: [], | ||
recordUpdated: new Date(), | ||
updateFrequency: 'unknown', | ||
languages: [], | ||
topics: [], | ||
keywords: [], | ||
licenses: [], | ||
legalConstraints: [], | ||
securityConstraints: [], | ||
otherConstraints: [], | ||
overviews: [], | ||
contactsForResource: [], | ||
kind: 'dataset', | ||
status: 'ongoing', | ||
lineage: '', | ||
distributions: [], | ||
spatialExtents: [], | ||
temporalExtents: [], | ||
} as CatalogRecord, | ||
null, | ||
false, | ||
]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.