-
Notifications
You must be signed in to change notification settings - Fork 4
/
RoleSelect.vue
79 lines (74 loc) · 1.37 KB
/
RoleSelect.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
<template>
<b-tooltip
:active="!!helpText"
:label="helpText"
multilined
class="blocked">
<p
v-show="!editable"
class="has-text-centered"><small> {{ roleLabel }} </small></p>
<b-select
v-show="editable"
v-model="role"
v-bind="$attrs"
expanded>
<option
v-for="(label, value) in roles"
:value="value"
:key="value">
{{ $t(`webapp.roles.${label.toLowerCase()}`) }}
</option>
</b-select>
</b-tooltip>
</template>
<script>
import {
ROLES,
} from '@/utils';
export default {
name: 'RoleSelect',
props: {
value: {
type: [Number, String],
default: null,
},
editable: {
type: Boolean,
default: true,
},
},
data() {
return {
roles: ROLES,
role: this.value,
};
},
computed: {
helpText() {
if (this.role === null) {
return null;
}
return this.$t(`webapp.roles.${this.roles[this.role].toLowerCase()}_description`);
},
roleLabel() {
if (this.role === null) {
return null;
}
return this.$t(`webapp.roles.${this.roles[this.role].toLowerCase()}`);
},
},
watch: {
value() {
this.role = this.value;
},
role() {
this.$emit('input', this.role);
},
},
};
</script>
<style lang="scss" scoped>
.blocked {
display: block;
}
</style>