-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathPersonViewer.vue
More file actions
121 lines (112 loc) · 3.95 KB
/
PersonViewer.vue
File metadata and controls
121 lines (112 loc) · 3.95 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<template>
<span itemprop="creator" itemscope itemtype="https://schema.org/Person">
<FontAwesomeIcon ref="button" :icon="faUser" />
<BPopover triggers="click blur" :target="$refs['button'] || 'works-lazily'" title="Person">
<GTable :items="items" :fields="fields" />
</BPopover>
<span v-if="name">
<meta v-if="person.name" itemprop="name" :content="person.name" />
<meta v-if="person.givenName" itemprop="givenName" :content="person.givenName" />
<meta v-if="person.familyName" itemprop="familyName" :content="person.familyName" />
{{ name }}
<span v-if="email">
(
<span itemprop="email" :content="person.email">{{ email }}</span>
)
</span>
</span>
<span v-else itemprop="email" :content="person.email">
{{ email }}
</span>
<GLink
v-if="orcidLink"
v-g-tooltip.hover
tooltip
title="View orcid.org profile"
:href="orcidLink"
target="_blank">
<link itemprop="identifier" :href="orcidLink" />
<FontAwesomeIcon :icon="faOrcid" />
</GLink>
<GLink v-if="url" v-g-tooltip.hover tooltip title="URL" :href="url" target="_blank">
<link itemprop="url" :href="url" />
<FontAwesomeIcon :icon="faExternalLinkAlt" />
</GLink>
<meta
v-for="attribute in explicitMetaAttributes"
:key="attribute.attribute"
:itemprop="attribute.attribute"
:content="attribute.value" />
<slot name="buttons" />
</span>
</template>
<script>
import { faOrcid } from "@fortawesome/free-brands-svg-icons";
import { faExternalLinkAlt, faUser } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BPopover } from "bootstrap-vue";
import ThingViewerMixin from "./ThingViewerMixin";
import GLink from "@/components/BaseComponents/GLink.vue";
import GTable from "@/components/Common/GTable.vue";
export default {
components: {
BPopover,
FontAwesomeIcon,
GLink,
GTable,
},
mixins: [ThingViewerMixin],
props: {
person: {
type: Object,
},
},
data() {
return {
faOrcid,
faUser,
faExternalLinkAlt,
implicitMicrodataProperties: ["name", "givenName", "email", "familyName", "url", "identifier"],
thing: this.person,
fields: [
{ key: "attribute", label: "Attribute" },
{ key: "value", label: "Value" },
],
};
},
computed: {
name() {
let name = this.person.name;
const familyName = this.person.familyName;
const givenName = this.person.givenName;
if (name == null && (familyName || givenName)) {
const honorificPrefix = this.person.honorificPrefix;
const honorificSuffix = this.person.honorificSuffix;
if (givenName && familyName) {
name = givenName + " " + familyName;
} else if (givenName) {
name = givenName;
} else {
name = familyName;
}
if (honorificPrefix) {
name = honorificPrefix + " " + name;
}
if (honorificSuffix) {
name = name + " " + honorificSuffix;
}
}
return name;
},
orcidLink() {
const identifier = this.person.identifier;
// Maybe interpret any XXXX-XXXX-XXXX-XXXX as orcid ID?
if (identifier && identifier.indexOf("orcid.org/") >= 0) {
return identifier;
} else {
return null;
}
},
},
};
</script>