mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Finalizing the mass creation.
This commit is contained in:
parent
5ca221a0c0
commit
79fb25d51e
@ -236,14 +236,21 @@ export default {
|
||||
variables: {
|
||||
pendingCreations: this.submitObj,
|
||||
},
|
||||
fetchPolicy: 'no-cache',
|
||||
})
|
||||
.then(() => {
|
||||
this.$store.commit('openCreationsPlus', this.submitObj.length)
|
||||
.then((result) => {
|
||||
console.log('result', result)
|
||||
this.$store.commit(
|
||||
'openCreationsPlus',
|
||||
result.data.createPendingCreations.successfulCreation.length,
|
||||
)
|
||||
if (result.data.createPendingCreations.failedCreation.length > 0) {
|
||||
result.data.createPendingCreations.failedCreation.forEach((failed) => {
|
||||
this.$toasted.error('Could not created PendingCreation for ' + failed)
|
||||
})
|
||||
}
|
||||
this.$emit('remove-all-bookmark')
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('Fehler bei der mehrfach Schöpfung')
|
||||
})
|
||||
// $store - offene Schöpfungen hochzählen
|
||||
// this.$store.commit('openCreationsPlus', i)
|
||||
|
||||
|
||||
@ -2,6 +2,10 @@ import gql from 'graphql-tag'
|
||||
|
||||
export const createPendingCreations = gql`
|
||||
mutation ($pendingCreations: [CreatePendingCreationArgs!]!) {
|
||||
createPendingCreations(pendingCreations: $pendingCreations)
|
||||
createPendingCreations(pendingCreations: $pendingCreations) {
|
||||
success
|
||||
successfulCreation
|
||||
failedCreation
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
19
backend/src/graphql/model/CreatePendingCreations.ts
Normal file
19
backend/src/graphql/model/CreatePendingCreations.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { ObjectType, Field, Int } from 'type-graphql'
|
||||
|
||||
@ObjectType()
|
||||
export class CreatePendingCreations {
|
||||
constructor() {
|
||||
this.success = false
|
||||
this.successfulCreation = []
|
||||
this.failedCreation = []
|
||||
}
|
||||
|
||||
@Field(() => Boolean)
|
||||
success: boolean
|
||||
|
||||
@Field(() => [String])
|
||||
successfulCreation: string[]
|
||||
|
||||
@Field(() => [String])
|
||||
failedCreation: string[]
|
||||
}
|
||||
@ -2,6 +2,7 @@ import { Resolver, Query, Arg, Args, Authorized, Mutation } from 'type-graphql'
|
||||
import { getCustomRepository, Raw } from 'typeorm'
|
||||
import { UserAdmin } from '../model/UserAdmin'
|
||||
import { PendingCreation } from '../model/PendingCreation'
|
||||
import { CreatePendingCreations } from '../model/CreatePendingCreations'
|
||||
import { UpdatePendingCreation } from '../model/UpdatePendingCreation'
|
||||
import { RIGHTS } from '../../auth/RIGHTS'
|
||||
import { TransactionRepository } from '../../typeorm/repository/Transaction'
|
||||
@ -63,17 +64,62 @@ export class AdminResolver {
|
||||
}
|
||||
|
||||
// @Authorized([RIGHTS.SEARCH_USERS])
|
||||
@Mutation(() => Boolean)
|
||||
@Mutation(() => CreatePendingCreations)
|
||||
async createPendingCreations(
|
||||
@Arg('pendingCreations', () => [CreatePendingCreationArgs])
|
||||
pendingCreations: CreatePendingCreationArgs[],
|
||||
): Promise<boolean> {
|
||||
pendingCreations.forEach((pendingCreation) => {
|
||||
this.createPendingCreation(pendingCreation).catch((error) => {
|
||||
console.log('pendingCreation ' + JSON.stringify(pendingCreation) + ' had an error ' + error)
|
||||
})
|
||||
): Promise<CreatePendingCreations> {
|
||||
let success = false
|
||||
const successfulCreation: string[] = []
|
||||
const failedCreation: string[] = []
|
||||
for (const pendingCreation of pendingCreations) {
|
||||
await this.createPendingCreation(pendingCreation)
|
||||
.then((result) => {
|
||||
console.log('Successfuly created ' + JSON.stringify(pendingCreation) + ' ' + result)
|
||||
successfulCreation.push(pendingCreation.email)
|
||||
success = true
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('Failed to creat ' + JSON.stringify(pendingCreation))
|
||||
failedCreation.push(pendingCreation.email)
|
||||
})
|
||||
}
|
||||
// await Promise.all(
|
||||
// pendingCreations.map(async (pendingCreation) => {
|
||||
// await this.createPendingCreation(pendingCreation)
|
||||
// .then((result) => {
|
||||
// console.log('Successfuly created ' + JSON.stringify(pendingCreation) + ' ' + result)
|
||||
// successfulCreation.push(pendingCreation.email)
|
||||
// success = true
|
||||
// })
|
||||
// .catch(() => {
|
||||
// console.log('Failed to creat ' + JSON.stringify(pendingCreation))
|
||||
// failedCreation.push(pendingCreation.email)
|
||||
// })
|
||||
// }),
|
||||
// )
|
||||
// await pendingCreations.forEach(async (pendingCreation) => {
|
||||
// await this.createPendingCreation(pendingCreation)
|
||||
// .then((result) => {
|
||||
// console.log('Successfuly created ' + JSON.stringify(pendingCreation) + ' ' + result)
|
||||
// successfulCreation.push(pendingCreation.email)
|
||||
// success = true
|
||||
// })
|
||||
// .catch(() => {
|
||||
// console.log('Failed to creat ' + JSON.stringify(pendingCreation))
|
||||
// failedCreation.push(pendingCreation.email)
|
||||
// })
|
||||
// })
|
||||
console.log('createPendingCreations', {
|
||||
success,
|
||||
successfulCreation,
|
||||
failedCreation,
|
||||
})
|
||||
return true
|
||||
return {
|
||||
success,
|
||||
successfulCreation,
|
||||
failedCreation,
|
||||
}
|
||||
}
|
||||
|
||||
// @Authorized([RIGHTS.SEARCH_USERS])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user