-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathMailboxInlinePicker.vue
113 lines (110 loc) · 2.44 KB
/
MailboxInlinePicker.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
<!--
- SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<Treeselect ref="Treeselect"
v-model="selected"
:options="mailboxes"
:multiple="false"
:clearable="false"
:disabled="disabled" />
</template>
<script>
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { mailboxHasRights } from '../util/acl.js'
import { mapStores } from 'pinia'
import useMainStore from '../store/mainStore.js'
export default {
name: 'MailboxInlinePicker',
components: {
Treeselect,
},
props: {
account: {
type: Object,
required: true,
},
disabled: {
type: Boolean,
default: false,
},
value: {
type: Number,
default: undefined,
},
},
data() {
return {
selected: this.value,
}
},
computed: {
...mapStores(useMainStore),
mailboxes() {
return this.getMailboxes()
},
},
watch: {
selected(val) {
if (val !== this.value) {
this.$emit('input', val)
this.selected = val
}
},
},
methods: {
getMailboxes(mailboxId) {
let mailboxes = []
if (!mailboxId) {
mailboxes = this.mainStore.getMailboxes(this.account.accountId)
} else {
mailboxes = this.mainStore.getSubMailboxes(mailboxId)
}
mailboxes = mailboxes.filter(mailbox => mailboxHasRights(mailbox, 'i'))
return mailboxes.map((mailbox) => {
return {
id: mailbox.databaseId,
label: mailbox.displayName,
children: mailbox.mailboxes.length > 0 ? this.getMailboxes(mailbox.databaseId) : '',
}
})
},
},
}
</script>
<style>
.vue-treeselect__control {
padding: 0;
border: 0;
width: 250px;
}
.vue-treeselect__control-arrow-container {
display: none;
}
.vue-treeselect--searchable .vue-treeselect__input-container {
padding-left: 0;
background-color: var(--color-main-background)
}
input.vue-treeselect__input {
margin: 0;
padding: 0;
border: 1px solid var(--color-border-maxcontrast) !important;
}
.vue-treeselect__menu {
background: var(--color-main-background);
}
.vue-treeselect--single .vue-treeselect__option--selected {
background: var(--color-primary-element-light);
border-radius: var(--border-radius-large);
}
.vue-treeselect__option.vue-treeselect__option--highlight,
.vue-treeselect__option:hover,
.vue-treeselect__option:focus {
border-radius: var(--border-radius-large);
}
.vue-treeselect__placeholder, .vue-treeselect__single-value {
line-height: 44px;
}
</style>