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
|
<template>
<ListItemIcon
:id="id"
:key="source.key"
:avatar-size="44"
:class="{'contacts-list__item--active': selectedContact === source.key}"
:display-name="source.displayName"
:is-no-user="true"
:subtitle="source.email"
:title="source.displayName"
:url="avatarUrl"
class="contacts-list__item"
tabindex="0"
@click.prevent.stop="selectContact"
@keypress.enter.prevent.stop="selectContact" />
</template>
<script>
import ListItemIcon from '@nextcloud/vue/dist/Components/ListItemIcon'
export default {
name: 'ContactsListItem',
components: {
ListItemIcon,
},
props: {
index: {
type: Number,
required: true,
},
source: {
type: Object,
required: true,
},
},
computed: {
selectedGroup() {
return this.$route.params.selectedGroup
},
selectedContact() {
return this.$route.params.selectedContact
},
// usable and valid html id for scrollTo
id() {
return window.btoa(this.source.key).slice(0, -2)
},
avatarUrl() {
if (this.source.photo) {
return `${this.source.photoUrl}`
}
if (this.source.url) {
return `${this.source.url}?photo`
}
return undefined
},
},
methods: {
/**
* Select this contact within the list
*/
selectContact() {
// change url with router
this.$router.push({ name: 'contact', params: { selectedGroup: this.selectedGroup, selectedContact: this.source.key } })
},
},
}
</script>
<style lang="scss" scoped>
.contacts-list__item {
padding: 8px;
&--active,
&:focus,
&:hover {
background-color: var(--color-background-hover);
}
&, ::v-deep * {
cursor: pointer;
}
}
</style>
|