feat: admin group edit / assign / unassign
This commit is contained in:
@@ -21,15 +21,20 @@
|
||||
v-text-field(label='Site Description', :counter='255', prepend-icon='public')
|
||||
v-text-field(label='Site Keywords', :counter='255', prepend-icon='public')
|
||||
v-select(label='Meta Robots', chips, tags, :items='metaRobots', v-model='metaRobotsSelection', prepend-icon='public')
|
||||
v-divider
|
||||
.px-3.pb-3
|
||||
v-btn(color='primary') Save
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(color='primary')
|
||||
v-icon(left) chevron_right
|
||||
span Save
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='primary', dark, dense, flat)
|
||||
v-toolbar-title
|
||||
.subheading Site Branding
|
||||
v-card-text ---
|
||||
v-card-text
|
||||
v-text-field(label='Logo', prepend-icon='image')
|
||||
v-divider
|
||||
|
||||
</template>
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
v-card
|
||||
v-card(flat, color='grey lighten-5').pa-3.pt-4
|
||||
.headline.blue--text.text--darken-2 Edit Group
|
||||
.subheading.grey--text {{group.name}}
|
||||
.subheading.grey--text {{name}}
|
||||
v-btn(color='primary', fab, absolute, bottom, right, small, to='/groups'): v-icon arrow_upward
|
||||
v-tabs(v-model='tab', color='grey lighten-4', fixed-tabs, slider-color='primary', show-arrows)
|
||||
v-tab(key='properties') Properties
|
||||
@@ -12,9 +12,9 @@
|
||||
v-tab-item(key='properties', :transition='false', :reverse-transition='false')
|
||||
v-card
|
||||
v-card-text
|
||||
v-text-field(v-model='group.name', label='Group Name', counter='255', prepend-icon='people')
|
||||
v-text-field(v-model='name', label='Group Name', counter='255', prepend-icon='people')
|
||||
v-card-actions.pa-3
|
||||
v-btn(color='primary', @click='')
|
||||
v-btn(color='primary', @click='updateGroup')
|
||||
v-icon(left) check
|
||||
| Save Changes
|
||||
.caption.ml-4.grey--text ID: {{group.id}}
|
||||
@@ -25,7 +25,7 @@
|
||||
| Delete Group
|
||||
v-card
|
||||
.dialog-header.is-red Delete Group?
|
||||
v-card-text Are you sure you want to delete group #[strong {{ group.name }}]? All users will be unassigned from this group.
|
||||
v-card-text Are you sure you want to delete group #[strong {{ name }}]? All users will be unassigned from this group.
|
||||
v-card-actions
|
||||
v-spacer
|
||||
v-btn(flat, @click='deleteGroupDialog = false') Cancel
|
||||
@@ -78,7 +78,7 @@
|
||||
v-tab-item(key='users', :transition='false', :reverse-transition='false')
|
||||
v-card
|
||||
v-card-title.pb-0
|
||||
v-btn(color='primary', @click='assignUser')
|
||||
v-btn(color='primary', @click='searchUserDialog = true')
|
||||
v-icon(left) assignment_ind
|
||||
| Assign User
|
||||
v-data-table(
|
||||
@@ -98,7 +98,7 @@
|
||||
v-menu(bottom, right, min-width='200')
|
||||
v-btn(icon, slot='activator'): v-icon.grey--text.text--darken-1 more_horiz
|
||||
v-list
|
||||
v-list-tile(@click='deleteGroupConfirm(props.item)')
|
||||
v-list-tile(@click='unassignUser(props.item.id)')
|
||||
v-list-tile-action: v-icon(color='orange') highlight_off
|
||||
v-list-tile-content
|
||||
v-list-tile-title Unassign
|
||||
@@ -107,7 +107,7 @@
|
||||
.text-xs-center.py-2(v-if='users.length > 15')
|
||||
v-pagination(v-model='pagination.page', :length='pages')
|
||||
|
||||
user-search(v-model='searchUserDialog')
|
||||
user-search(v-model='searchUserDialog', @select='assignUser')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -115,7 +115,10 @@ import Criterias from '../common/criterias.vue'
|
||||
import UserSearch from '../common/user-search.vue'
|
||||
|
||||
import groupQuery from 'gql/admin-groups-query-single.gql'
|
||||
import assignUserMutation from 'gql/admin-groups-mutation-assign.gql'
|
||||
import deleteGroupMutation from 'gql/admin-groups-mutation-delete.gql'
|
||||
import unassignUserMutation from 'gql/admin-groups-mutation-unassign.gql'
|
||||
import updateGroupMutation from 'gql/admin-groups-mutation-update.gql'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -125,10 +128,11 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
group: {
|
||||
id: 7,
|
||||
name: 'Editors',
|
||||
id: 0,
|
||||
name: '',
|
||||
users: []
|
||||
},
|
||||
name: '',
|
||||
deleteGroupDialog: false,
|
||||
searchUserDialog: false,
|
||||
pagination: {},
|
||||
@@ -152,10 +156,36 @@ export default {
|
||||
return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
group(newValue, oldValue) {
|
||||
this.name = newValue.name
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async deleteGroupConfirm(group) {
|
||||
this.deleteGroupDialog = true
|
||||
this.selectedGroup = group
|
||||
async updateGroup() {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: updateGroupMutation,
|
||||
variables: {
|
||||
id: this.group.id,
|
||||
name: this.name
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-update')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `Group changes have been saved.`,
|
||||
icon: 'check'
|
||||
})
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
},
|
||||
async deleteGroup() {
|
||||
this.deleteGroupDialog = false
|
||||
@@ -183,8 +213,57 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
assignUser() {
|
||||
this.searchUserDialog = true
|
||||
async assignUser(id) {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: assignUserMutation,
|
||||
variables: {
|
||||
groupId: this.group.id,
|
||||
userId: id
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-assign')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `User has been assigned to ${this.group.name}.`,
|
||||
icon: 'assignment_ind'
|
||||
})
|
||||
this.$apollo.queries.group.refetch()
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
},
|
||||
async unassignUser(id) {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: unassignUserMutation,
|
||||
variables: {
|
||||
groupId: this.group.id,
|
||||
userId: id
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-unassign')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `User has been unassigned from ${this.group.name}.`,
|
||||
icon: 'assignment_ind'
|
||||
})
|
||||
this.$apollo.queries.group.refetch()
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
@@ -195,6 +274,7 @@ export default {
|
||||
id: this.$route.params.id
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'network-only',
|
||||
update: (data) => data.groups.single,
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-refresh')
|
||||
|
@@ -156,6 +156,7 @@ export default {
|
||||
apollo: {
|
||||
groups: {
|
||||
query: groupsQuery,
|
||||
fetchPolicy: 'network-only',
|
||||
update: (data) => data.groups.list,
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-refresh')
|
||||
|
@@ -8,7 +8,7 @@
|
||||
v-layout(row wrap)
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='grey darken-3', dark, dense, flat)
|
||||
v-toolbar(color='primary', dark, dense, flat)
|
||||
v-toolbar-title
|
||||
.subheading Locale Settings
|
||||
v-card-text
|
||||
@@ -38,8 +38,9 @@
|
||||
persistent-hint
|
||||
hint='Automatically download updates to this locale as they become available.'
|
||||
)
|
||||
v-divider
|
||||
.px-3.pb-3
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(color='primary', :loading='loading', @click='save')
|
||||
v-icon(left) chevron_right
|
||||
span Save
|
||||
@@ -49,7 +50,7 @@
|
||||
v-toolbar-title
|
||||
.subheading Download Locale
|
||||
v-list
|
||||
v-list-tile(v-for='lc in locales')
|
||||
v-list-tile(v-for='lc in locales', :key='lc.code')
|
||||
v-list-tile-avatar
|
||||
v-avatar.teal.white--text(tile, size='40') {{lc.code.toUpperCase()}}
|
||||
v-list-tile-content
|
||||
@@ -159,7 +160,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
|
||||
</style>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
v-layout(row wrap)
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='grey darken-3', dark, dense, flat)
|
||||
v-toolbar(color='primary', dark, dense, flat)
|
||||
v-toolbar-title
|
||||
.subheading Theme
|
||||
v-card-text
|
||||
@@ -21,9 +21,12 @@
|
||||
v-list-tile-sub-title(v-html='data.item.author')
|
||||
v-divider
|
||||
v-switch(v-model='darkMode', label='Dark Mode', color='primary', persistent-hint, hint='Not recommended for accessibility.')
|
||||
v-divider
|
||||
.px-3.pb-3
|
||||
v-btn(color='primary') Save
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(color='primary', :loading='loading', @click='save')
|
||||
v-icon(left) chevron_right
|
||||
span Save
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='teal', dark, dense, flat)
|
||||
|
@@ -1,38 +1,66 @@
|
||||
<template lang="pug">
|
||||
v-dialog(v-model='dialogOpen', max-width='650')
|
||||
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
|
||||
.dialog-header
|
||||
span Search User
|
||||
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
|
||||
v-progress-circular(
|
||||
indeterminate
|
||||
color='white'
|
||||
:size='20'
|
||||
:width='2'
|
||||
v-show='searchLoading'
|
||||
)
|
||||
v-card-text
|
||||
v-text-field.blue.lighten-5(
|
||||
solo
|
||||
flat
|
||||
label='Search Users...'
|
||||
v-model='search'
|
||||
prepend-icon='search'
|
||||
color='primary'
|
||||
ref='searchIpt'
|
||||
)
|
||||
v-list(two-line)
|
||||
template(v-for='(usr, idx) in items')
|
||||
v-list-tile(:key='usr.id', @click='setUser(usr.id)')
|
||||
v-list-tile-avatar(size='40', color='primary')
|
||||
span.body-1.white--text {{usr.name | initials}}
|
||||
v-list-tile-content
|
||||
v-list-tile-title {{usr.name}}
|
||||
v-list-tile-sub-title {{usr.email}}
|
||||
v-list-tile-action
|
||||
v-icon(color='primary') arrow_forward
|
||||
v-divider.my-0(v-if='idx < items.length - 1')
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(
|
||||
flat
|
||||
@click='close'
|
||||
:disabled='loading'
|
||||
) Cancel
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
|
||||
import searchUsersQuery from 'gql/common-users-query-search.gql'
|
||||
|
||||
export default {
|
||||
filters: {
|
||||
initials(val) {
|
||||
return val.split(' ').map(v => v.substring(0, 1)).join()
|
||||
}
|
||||
},
|
||||
props: {
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
value: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -43,8 +71,7 @@ export default {
|
||||
loading: false,
|
||||
searchLoading: false,
|
||||
search: '',
|
||||
items: [],
|
||||
selectedItems: []
|
||||
items: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -53,12 +80,25 @@ export default {
|
||||
set(value) { this.$emit('input', value) }
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value(newValue, oldValue) {
|
||||
if (newValue && !oldValue) {
|
||||
this.search = ''
|
||||
this.selectedItems = null
|
||||
_.delay(() => { this.$refs.searchIpt.focus() }, 100)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.$emit('input', false)
|
||||
},
|
||||
setUser() {
|
||||
|
||||
setUser(id) {
|
||||
this.$emit('select', id)
|
||||
this.close()
|
||||
},
|
||||
searchFilter(item, queryText, itemText) {
|
||||
return _.includes(_.toLower(item.email), _.toLower(queryText)) || _.includes(_.toLower(item.name), _.toLower(queryText))
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
@@ -66,13 +106,13 @@ export default {
|
||||
query: searchUsersQuery,
|
||||
variables() {
|
||||
return {
|
||||
search: this.search
|
||||
query: this.search
|
||||
}
|
||||
},
|
||||
skip() {
|
||||
return !this.search || this.search.length < 2
|
||||
},
|
||||
update: (data) => data.upsells.segments,
|
||||
update: (data) => data.users.search,
|
||||
watchLoading (isLoading) {
|
||||
this.searchLoading = isLoading
|
||||
}
|
||||
|
Reference in New Issue
Block a user