mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
change user roles: fixed mutation parameters, added success toast
This commit is contained in:
parent
567758bc56
commit
9ef42940ae
@ -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
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
"placeholder": "E-Mail, Name oder Beschreibung"
|
||||
},
|
||||
"name": "Benutzer",
|
||||
"roleChanged": "Rolle erfolgreich geändert!",
|
||||
"table": {
|
||||
"columns": {
|
||||
"createdAt": "Erstellt am",
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
"placeholder": "e-mail, name or description"
|
||||
},
|
||||
"name": "Users",
|
||||
"roleChanged": "Role changed successfully!",
|
||||
"table": {
|
||||
"columns": {
|
||||
"createdAt": "Created at",
|
||||
|
||||
@ -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)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user