mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Delete button sends call to Adminresolver deletePendingCreation.
This commit is contained in:
parent
b47bf3d41d
commit
48b7c9a0af
7
admin/src/graphql/deletePendingCreation.js
Normal file
7
admin/src/graphql/deletePendingCreation.js
Normal file
@ -0,0 +1,7 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const deletePendingCreation = gql`
|
||||
mutation ($id: Float!) {
|
||||
deletePendingCreation(id: $id)
|
||||
}
|
||||
`
|
||||
@ -12,6 +12,7 @@
|
||||
<script>
|
||||
import UserTable from '../components/UserTable.vue'
|
||||
import { getPendingCreations } from '../graphql/getPendingCreations'
|
||||
import { deletePendingCreation } from '../graphql/deletePendingCreation'
|
||||
|
||||
export default {
|
||||
name: 'CreationConfirm',
|
||||
@ -57,11 +58,23 @@ export default {
|
||||
|
||||
findArr = this.confirmResult.find((arr) => arr.id === e.id)
|
||||
|
||||
index = this.confirmResult.indexOf(findArr)
|
||||
|
||||
this.confirmResult.splice(index, 1)
|
||||
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
// console.log('findArr', findArr)
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: deletePendingCreation,
|
||||
variables: {
|
||||
id: findArr.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
index = this.confirmResult.indexOf(findArr)
|
||||
this.confirmResult.splice(index, 1)
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
this.$toasted.success('Pending Creation has been deleted')
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
}
|
||||
},
|
||||
getPendingCreations() {
|
||||
|
||||
@ -130,9 +130,8 @@ export class AdminResolver {
|
||||
@Mutation(() => Boolean)
|
||||
async deletePendingCreation(@Arg('id') id: number): Promise<boolean> {
|
||||
const pendingCreationRepository = getCustomRepository(PendingCreationRepository)
|
||||
const entity = await pendingCreationRepository.findOne(id)
|
||||
if (!entity) throw new Error('Not pending creation with this id.')
|
||||
const res = await pendingCreationRepository.manager.remove(entity)
|
||||
const entity = await pendingCreationRepository.findOneOrFail(id)
|
||||
const res = await pendingCreationRepository.delete(entity)
|
||||
return !!res
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user