Add button to deny contribution in the admin interface

This commit is contained in:
elweyn 2023-01-12 15:06:45 +01:00
parent 493aa32011
commit b88bfabb78
3 changed files with 42 additions and 1 deletions

View File

@ -8,7 +8,7 @@
@click="$emit('remove-creation', row.item)"
class="mr-2"
>
<b-icon icon="x" variant="light"></b-icon>
<b-icon icon="trash" variant="light"></b-icon>
</b-button>
</template>
<template #cell(editCreation)="row">
@ -49,6 +49,18 @@
</b-button>
</div>
</template>
<template #cell(deny)="row">
<div v-if="$store.state.moderator.id !== row.item.userId">
<b-button
variant="danger"
size="md"
@click="$emit('reject-creation', row.item)"
class="mr-2"
>
<b-icon icon="x" variant="light"></b-icon>
</b-button>
</div>
</template>
<template #row-details="row">
<row-details
:row="row"

View File

@ -0,0 +1,7 @@
import gql from 'graphql-tag'
export const rejectContribution = gql`
mutation ($id: Int!) {
rejectContribution(id: $id)
}
`

View File

@ -7,6 +7,7 @@
class="mt-4"
:items="pendingCreations"
:fields="fields"
@reject-creation="rejectCreation"
@remove-creation="removeCreation"
@show-overlay="showOverlay"
@update-state="updateState"
@ -20,6 +21,7 @@ import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
import { listUnconfirmedContributions } from '../graphql/listUnconfirmedContributions'
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
import { confirmContribution } from '../graphql/confirmContribution'
import { rejectContribution } from '../graphql/rejectContribution'
export default {
name: 'CreationConfirm',
@ -35,6 +37,25 @@ export default {
}
},
methods: {
rejectCreation(item) {
this.$bvModal.msgBoxConfirm(this.$t('creation_form.rejectNow')).then(async (value) => {
if (value) {
await this.$apollo
.mutate({
mutation: rejectContribution,
variables: {
id: item.id,
},
})
.then((result) => {
this.toastSuccess(this.$t('creation_form.toasted_rejected'))
})
.catch((error) => {
this.toastError(error.message)
})
}
})
},
removeCreation(item) {
this.$bvModal.msgBoxConfirm(this.$t('creation_form.deleteNow')).then(async (value) => {
if (value)
@ -110,6 +131,7 @@ export default {
{ key: 'moderator', label: this.$t('moderator') },
{ key: 'editCreation', label: this.$t('edit') },
{ key: 'confirm', label: this.$t('save') },
{ key: 'deny', label: this.$t('deny') },
]
},
},