-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathPerson.js
46 lines (44 loc) · 991 Bytes
/
Person.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { DocumentNode, STRING, ONE, MANY, CHILDREN, BOOLEAN } from 'substance'
import { extractInitials } from './modelHelpers'
export default class Person extends DocumentNode {
// not used
// toString () {
// return this.render().join('')
// }
render (options = {}) {
let { prefix, suffix, givenNames, surname } = this
if (options.short) {
givenNames = extractInitials(givenNames)
}
let result = []
if (prefix) {
result.push(prefix, ' ')
}
result.push(
givenNames,
' ',
surname
)
if (suffix) {
result.push(' (', suffix, ')')
}
return result
}
}
Person.schema = {
type: 'person',
surname: STRING,
givenNames: STRING,
alias: STRING,
prefix: STRING,
suffix: STRING,
email: STRING,
orcid: STRING,
group: ONE('group'),
affiliations: MANY('affiliation'),
funders: MANY('funder'),
bio: CHILDREN('paragraph'),
equalContrib: BOOLEAN,
corresp: BOOLEAN,
deceased: BOOLEAN
}