change user roles: fixed mutation parameters, added success toast

This commit is contained in:
Moriz Wahl 2021-02-08 18:43:12 +01:00 committed by Ulf Gebhardt
parent 567758bc56
commit 9ef42940ae
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
4 changed files with 18 additions and 10 deletions

View File

@ -13,13 +13,14 @@ export const FetchAllRoles = gql`
export const updateUserRole = (role, id) => {
return gql`
mutation {
switchUserRole(role: ${role}, id: "${id}" ) {
name
role
id
updatedAt
email
}
}`
mutation($role: UserGroup!, $id: ID!) {
switchUserRole(role: $role, id: $id) {
name
role
id
updatedAt
email
}
}
`
}

View File

@ -63,6 +63,7 @@
"placeholder": "E-Mail, Name oder Beschreibung"
},
"name": "Benutzer",
"roleChanged": "Rolle erfolgreich geändert!",
"table": {
"columns": {
"createdAt": "Erstellt am",

View File

@ -63,6 +63,7 @@
"placeholder": "e-mail, name or description"
},
"name": "Users",
"roleChanged": "Role changed successfully!",
"table": {
"columns": {
"createdAt": "Created at",

View File

@ -49,11 +49,12 @@
{{ scope.row.createdAt | dateTime }}
</template>
<template slot="role" slot-scope="scope" v-if="scope.row.email != currentUser.email">
<template slot="role" slot-scope="scope">
<ApolloQuery :query="FetchAllRoles">
<template v-slot="{ result: { data } }">
<template v-if="data">
<select
v-if="scope.row.id !== currentUser.id"
:value="`${scope.row.role}`"
v-on:change="changeUserRole(scope.row.id, $event)"
>
@ -61,6 +62,7 @@
{{ value.name }}
</option>
</select>
<ds-text v-else>{{ scope.row.role }}</ds-text>
</template>
</template>
</ApolloQuery>
@ -204,6 +206,9 @@ export default {
mutation: updateUserRole(newRole, id),
variables: { role: newRole, id },
})
.then(({ data }) => {
this.$toast.success(this.$t('admin.users.roleChanged'))
})
.catch((error) => {
this.$toast.error(error.message)
})