forked from mandiant/gocrack-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsersSelection.vue
More file actions
70 lines (63 loc) · 1.6 KB
/
UsersSelection.vue
File metadata and controls
70 lines (63 loc) · 1.6 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
<template>
<div class="form-group row">
<label for="additionalUsers" class="col-3 col-form-label">{{ $t('create_task.additional_users') }}</label>
<div class="col-9">
<multiselect
:multiple="true"
:loading="loading"
:options="users"
open-direction="bottom"
track-by="user_uuid"
label="username"
id="additionalUsers"
placeholder="Add a user"
@open="onUsersSelectOpen"
@input="onInput" />
<small class="form-text text-muted">{{ $t('create_task.description_users') }}</small>
</div>
</div>
</template>
<script>
import Multiselect from 'vue-multiselect'
import { mapGetters } from 'vuex'
import helpers from '@/helpers'
export default {
components: {
Multiselect
},
data () {
return {
loading: false,
users: []
}
},
computed: {
...mapGetters([
'getAuthDetails'
])
},
methods: {
onUsersSelectOpen () {
// dont keep hitting the API if we've already loaded it once
if (this.users.length > 0) {
return
}
this.loading = true
this.$gocrack.getUsers().then((users) => {
// filter out the current user from the dropdown
this.users = users.filter(value => {
return value.user_uuid !== this.getAuthDetails.user_uuid
})
this.loading = false
}).catch((error) => {
this.loading = false
let vm = this
helpers.componentToastError(vm, error)
})
},
onInput (value, id) {
this.$emit('usr-grant-change', value.map(user => user.user_uuid))
}
}
}
</script>