feat: user-search component UI

pull/621/head
NGPixel 7 years ago
parent 8726494340
commit 3752cf7415

@ -78,7 +78,7 @@
v-tab-item(key='users', :transition='false', :reverse-transition='false') v-tab-item(key='users', :transition='false', :reverse-transition='false')
v-card v-card
v-card-title.pb-0 v-card-title.pb-0
v-btn(color='primary') v-btn(color='primary', @click='assignUser')
v-icon(left) assignment_ind v-icon(left) assignment_ind
| Assign User | Assign User
v-data-table( v-data-table(
@ -106,17 +106,21 @@
v-alert.ma-3(icon='warning', :value='true', outline) No users to display. v-alert.ma-3(icon='warning', :value='true', outline) No users to display.
.text-xs-center.py-2(v-if='users.length > 15') .text-xs-center.py-2(v-if='users.length > 15')
v-pagination(v-model='pagination.page', :length='pages') v-pagination(v-model='pagination.page', :length='pages')
user-search(v-model='searchUserDialog')
</template> </template>
<script> <script>
import Criterias from '../common/criterias.vue' import Criterias from '../common/criterias.vue'
import UserSearch from '../common/user-search.vue'
import groupQuery from 'gql/admin-groups-query-single.gql' import groupQuery from 'gql/admin-groups-query-single.gql'
import deleteGroupMutation from 'gql/admin-groups-mutation-delete.gql' import deleteGroupMutation from 'gql/admin-groups-mutation-delete.gql'
export default { export default {
components: { components: {
Criterias Criterias,
UserSearch
}, },
data() { data() {
return { return {
@ -126,6 +130,7 @@ export default {
users: [] users: []
}, },
deleteGroupDialog: false, deleteGroupDialog: false,
searchUserDialog: false,
pagination: {}, pagination: {},
users: [], users: [],
headers: [ headers: [
@ -177,6 +182,9 @@ export default {
icon: 'warning' icon: 'warning'
}) })
} }
},
assignUser() {
this.searchUserDialog = true
} }
}, },
apollo: { apollo: {

@ -0,0 +1,82 @@
<template lang="pug">
v-dialog(v-model='dialogOpen', max-width='650')
v-card
.dialog-header Search User
v-card-text
v-select(
:items='items'
:loading='searchLoading'
:search-input.sync='search'
autocomplete
autofocus
cache-items
chips
clearable
hide-details
item-text='name',
item-value='id',
label='Search users...'
light
multiple
v-model='selectedItems'
)
v-card-actions
v-spacer
v-btn(flat, @click='close', :disabled='loading') Cancel
v-btn(color='primary', dark, @click='setUser', :loading='loading', :disabled='loading')
v-icon(left) assignment_ind
span Select User
</template>
<script>
import searchUsersQuery from 'gql/common-users-query-search.gql'
export default {
props: {
value: {
type: Boolean,
default: false
}
},
data() {
return {
loading: false,
searchLoading: false,
search: '',
items: [],
selectedItems: []
}
},
computed: {
dialogOpen: {
get() { return this.value },
set(value) { this.$emit('input', value) }
}
},
methods: {
close() {
this.$emit('input', false)
},
setUser() {
}
},
apollo: {
items: {
query: searchUsersQuery,
variables() {
return {
search: this.search
}
},
skip() {
return !this.search || this.search.length < 2
},
update: (data) => data.upsells.segments,
watchLoading (isLoading) {
this.searchLoading = isLoading
}
}
}
}
</script>

@ -0,0 +1,9 @@
query ($query: String!) {
users {
search(query:$query) {
id
name
email
}
}
}
Loading…
Cancel
Save