From 9237f139f28aecb6a30de1a20d5d4cef74daae89 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 9 Dec 2021 11:13:07 +0100 Subject: [PATCH 01/15] Error in UpdatePendingCreationArgs changed export name, Added an InputType over the ArgsType for the CreatePendingCreationArgs, added a createPendingCreations mutation that creates multiple PendingCreation. --- .../graphql/arg/CreatePendingCreationArgs.ts | 3 +- .../graphql/arg/UpdatePendingCreationArgs.ts | 2 +- backend/src/graphql/resolver/AdminResolver.ts | 29 +++++++++---------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/backend/src/graphql/arg/CreatePendingCreationArgs.ts b/backend/src/graphql/arg/CreatePendingCreationArgs.ts index d2c17abf1..06a5369ac 100644 --- a/backend/src/graphql/arg/CreatePendingCreationArgs.ts +++ b/backend/src/graphql/arg/CreatePendingCreationArgs.ts @@ -1,5 +1,6 @@ -import { ArgsType, Field, Int } from 'type-graphql' +import { ArgsType, Field, InputType, Int } from 'type-graphql' +@InputType() @ArgsType() export default class CreatePendingCreationArgs { @Field(() => String) diff --git a/backend/src/graphql/arg/UpdatePendingCreationArgs.ts b/backend/src/graphql/arg/UpdatePendingCreationArgs.ts index bde7133aa..471519956 100644 --- a/backend/src/graphql/arg/UpdatePendingCreationArgs.ts +++ b/backend/src/graphql/arg/UpdatePendingCreationArgs.ts @@ -1,7 +1,7 @@ import { ArgsType, Field, Int } from 'type-graphql' @ArgsType() -export default class CreatePendingCreationArgs { +export default class UpdatePendingCreationArgs { @Field(() => Int) id: number diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 3c03227d5..43ca19aea 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -62,6 +62,19 @@ export class AdminResolver { return await getUserCreations(user.id) } + // @Authorized([RIGHTS.SEARCH_USERS]) + @Mutation(() => Boolean) + async createPendingCreations( + @Arg('pendingCreations', () => [CreatePendingCreationArgs]) + pendingCreations: CreatePendingCreationArgs[], + ): Promise { + pendingCreations.forEach((pendingCreation) => { + console.log('pendingCreation', pendingCreation) + this.createPendingCreation(pendingCreation) + }) + return true + } + // @Authorized([RIGHTS.SEARCH_USERS]) @Mutation(() => UpdatePendingCreation) async updatePendingCreation( @@ -90,22 +103,6 @@ export class AdminResolver { result.creation = await getUserCreations(user.id) return result - - // const creations = await getUserCreations(user.id) - // const creationDateObj = new Date(creationDate) - // if (isCreationValid(creations, amount, creationDateObj)) { - // const pendingCreationRepository = getCustomRepository(PendingCreationRepository) - // const loginPendingTaskAdmin = pendingCreationRepository.create() - // loginPendingTaskAdmin.userId = user.id - // loginPendingTaskAdmin.amount = BigInt(amount * 10000) - // loginPendingTaskAdmin.created = new Date() - // loginPendingTaskAdmin.date = creationDateObj - // loginPendingTaskAdmin.memo = memo - // loginPendingTaskAdmin.moderator = moderator - // - // pendingCreationRepository.save(loginPendingTaskAdmin) - // } - // return await getUserCreations(user.id) } @Query(() => [PendingCreation]) From 5ca221a0c09f05470083795dc034c73611f3dbc0 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Dec 2021 11:53:21 +0100 Subject: [PATCH 02/15] Added the new mutation to the admin, Implemented the send massCreation in admin, changed the log entries for not created pendingcreation. --- admin/src/components/CreationFormular.vue | 49 ++++++++++++++----- admin/src/graphql/createPendingCreations.js | 7 +++ backend/src/graphql/resolver/AdminResolver.ts | 5 +- 3 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 admin/src/graphql/createPendingCreations.js diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index d73ea3c81..d84056f18 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -122,6 +122,7 @@