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: {
|
variables: {
|
||||||
pendingCreations: this.submitObj,
|
pendingCreations: this.submitObj,
|
||||||
},
|
},
|
||||||
|
fetchPolicy: 'no-cache',
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then((result) => {
|
||||||
this.$store.commit('openCreationsPlus', this.submitObj.length)
|
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')
|
this.$emit('remove-all-bookmark')
|
||||||
})
|
})
|
||||||
.catch(() => {
|
|
||||||
console.log('Fehler bei der mehrfach Schöpfung')
|
|
||||||
})
|
|
||||||
// $store - offene Schöpfungen hochzählen
|
// $store - offene Schöpfungen hochzählen
|
||||||
// this.$store.commit('openCreationsPlus', i)
|
// this.$store.commit('openCreationsPlus', i)
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,10 @@ import gql from 'graphql-tag'
|
|||||||
|
|
||||||
export const createPendingCreations = gql`
|
export const createPendingCreations = gql`
|
||||||
mutation ($pendingCreations: [CreatePendingCreationArgs!]!) {
|
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 { getCustomRepository, Raw } from 'typeorm'
|
||||||
import { UserAdmin } from '../model/UserAdmin'
|
import { UserAdmin } from '../model/UserAdmin'
|
||||||
import { PendingCreation } from '../model/PendingCreation'
|
import { PendingCreation } from '../model/PendingCreation'
|
||||||
|
import { CreatePendingCreations } from '../model/CreatePendingCreations'
|
||||||
import { UpdatePendingCreation } from '../model/UpdatePendingCreation'
|
import { UpdatePendingCreation } from '../model/UpdatePendingCreation'
|
||||||
import { RIGHTS } from '../../auth/RIGHTS'
|
import { RIGHTS } from '../../auth/RIGHTS'
|
||||||
import { TransactionRepository } from '../../typeorm/repository/Transaction'
|
import { TransactionRepository } from '../../typeorm/repository/Transaction'
|
||||||
@ -63,17 +64,62 @@ export class AdminResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Authorized([RIGHTS.SEARCH_USERS])
|
// @Authorized([RIGHTS.SEARCH_USERS])
|
||||||
@Mutation(() => Boolean)
|
@Mutation(() => CreatePendingCreations)
|
||||||
async createPendingCreations(
|
async createPendingCreations(
|
||||||
@Arg('pendingCreations', () => [CreatePendingCreationArgs])
|
@Arg('pendingCreations', () => [CreatePendingCreationArgs])
|
||||||
pendingCreations: CreatePendingCreationArgs[],
|
pendingCreations: CreatePendingCreationArgs[],
|
||||||
): Promise<boolean> {
|
): Promise<CreatePendingCreations> {
|
||||||
pendingCreations.forEach((pendingCreation) => {
|
let success = false
|
||||||
this.createPendingCreation(pendingCreation).catch((error) => {
|
const successfulCreation: string[] = []
|
||||||
console.log('pendingCreation ' + JSON.stringify(pendingCreation) + ' had an error ' + error)
|
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)
|
||||||
})
|
})
|
||||||
return true
|
}
|
||||||
|
// 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 {
|
||||||
|
success,
|
||||||
|
successfulCreation,
|
||||||
|
failedCreation,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Authorized([RIGHTS.SEARCH_USERS])
|
// @Authorized([RIGHTS.SEARCH_USERS])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user