-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathDocumentView.vue
192 lines (185 loc) · 4.47 KB
/
DocumentView.vue
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<template>
<div class="space-y-1">
<div class="flex flex-row justify-between space-x-10">
<button
class="font-semibold text-lg text-primary-800"
@click="displayDocumentDetails"
>
<UIcon
v-if="typeIcon"
:name="typeIcon"
class="mr-1"
:title="typeDescription"
/>
<span>{{ document.title }}</span>
</button>
<!-- TOOD: Add citation display
<a
class="text-sm whitespace-nowrap mt-1"
href="/paper/id/citedby"
>
2 citations
</a>
-->
</div>
<div
v-if="'authors' in document && document.authors"
class="space-x-3"
>
<span
v-for="author in document.authors"
:key="author.id"
>{{
author.__typename === 'Organization'
? author.name
: author.__typename === 'Person'
? author.family
: ''
}}</span
>
</div>
<div class="space-x-1 text-sm">
<span class="font-semibold">2019</span>
<a
v-if="
'in' in document &&
document.in &&
'journal' in document.in &&
document.in.journal
"
:href="'journal/' + document.in.journal.id"
>{{ document.in.journal.name }}</a
>
<a
v-if="'institution' in document && document.institution"
:href="'institution/' + document.institution.id"
>{{ document.institution.name }}</a
>
<span v-if="'in' in document && document.in && 'title' in document.in">
{{ document.in.title }}
</span>
</div>
<div
v-if="document.keywords.length > 0"
class="flex flex-row space-x-2 text-sm"
>
<t-tag
v-for="keyword in document.keywords"
:key="keyword"
variant="badge"
class="border border-gray-400"
>
<!-- TODO: Add icon of group <UIcon name="dragon" class="mr-2" /> -->
{{ keyword }}
</t-tag>
<!-- TODO: Add overflow
<UButton variant="linkplain" class="text-sm my-auto">
<span>View More (8+)</span>
<UIcon name="ri:arrow-down-s-line" />
</UButton>
-->
</div>
<div v-if="'abstract' in document && document.abstract">
<span
class="grow"
:class="{ 'line-clamp-2': !viewFullAbstract }"
>
{{ document.abstract }}
</span>
<UButton
text
class="text-sm my-auto"
@click="viewFullAbstract = !viewFullAbstract"
>
<template v-if="viewFullAbstract">
<span>View less</span>
<UIcon name="ri:arrow-up-s-line" />
</template>
<template v-else>
<span>View full abstract</span>
<UIcon name="ri:arrow-down-s-line" />
</template>
</UButton>
</div>
</div>
</template>
<script lang="ts" setup>
import type { PropType } from 'vue'
import { gql, useFragment, type FragmentType } from '~/apollo'
import { useUiStore } from '~/store'
const DocumentForView = gql(/* GraphQL */ `
fragment DocumentForView on Document {
id
title
keywords
abstract
authors {
... on Person {
id
family
}
... on Organization {
id
name
}
}
... on JournalArticle {
in {
id
journal {
id
name
}
}
}
... on ProceedingsArticle {
in {
id
title
}
}
... on Thesis {
institution {
id
name
}
}
}
`)
const props = defineProps({
source: {
type: Object as PropType<FragmentType<typeof DocumentForView>>,
required: true,
},
})
const document = computed(() => useFragment(DocumentForView, props.source))
const viewFullAbstract = ref(false)
const typeIcon = computed(() => {
switch (document.value.__typename) {
case 'JournalArticle':
return 'ri:newspaper-line'
case 'ProceedingsArticle':
return 'ri:presentation-line'
case 'Thesis':
return 'ri:graduation-cap-line'
default:
return 'ri:file-list-2-line'
}
})
const typeDescription = computed(() => {
switch (document.value.__typename) {
case 'JournalArticle':
return 'Journal Paper'
case 'ProceedingsArticle':
return 'Conference Paper'
case 'Thesis':
return 'PhD Thesis'
default:
return document.value.__typename
}
})
const ui = useUiStore()
function displayDocumentDetails() {
ui.displayDocumentDetails(document.value.id)
}
</script>