src/schema/*: use dateRange for engagement

pull/24/head
leonnicolas 4 years ago
parent 4e33ec2095
commit 5e6e796fe8
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -179,7 +179,7 @@ export class ParticipantAPI extends DataSource {
.values([participant]) .values([participant])
.returning('*') .returning('*')
.execute(); .execute();
await entityManager.getRepository(Participant) participant.workshopIds && await entityManager.getRepository(Participant)
.createQueryBuilder('w') .createQueryBuilder('w')
.relation(Participant, 'workshopIds') .relation(Participant, 'workshopIds')
.of(participant.id) .of(participant.id)
@ -211,8 +211,8 @@ export class ParticipantAPI extends DataSource {
.update() .update()
.set({ ...participant }) .set({ ...participant })
.where('id = :id', { id: participant.id }) .where('id = :id', { id: participant.id })
.execute().then(value => { if (value.affected !== 1) { throw new GraphQLError('ID not found'); } }); .execute().then(value => { if (value.affected !== 1) { throw new UserInputError('ID not found'); } });
await entityManager.getRepository(Participant) workshops && await entityManager.getRepository(Participant)
.createQueryBuilder('w') .createQueryBuilder('w')
.relation(Participant, 'workshopIds') .relation(Participant, 'workshopIds')
.of(participant.id) .of(participant.id)

@ -113,13 +113,6 @@ export default {
return new GraphQLError('Insufficient Permissions'); return new GraphQLError('Insufficient Permissions');
} }
}, },
from (parent: any) {
return (parent.dateRange as string).split(',')[0].replace('[', '');
},
to (parent: any) {
const str = (parent.dateRange as string).split(',')[1].replace(')', '');
return (str.length > 0) ? str : null;
},
isLockedByMe: (parent: any, __: any, { req }: { req: any }) => isLockedByMe(parent, { req }), isLockedByMe: (parent: any, __: any, { req }: { req: any }) => isLockedByMe(parent, { req }),
isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req }) isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req })
}, },

@ -550,8 +550,7 @@ export default gql`
type Engagement { type Engagement {
id: ID! id: ID!
engagementType: EngagementType! engagementType: EngagementType!
from: Date! dateRange: DateRange!
to: Date
participant: Participant! participant: Participant!
cargoBike: CargoBike! cargoBike: CargoBike!
isLocked: Boolean! isLocked: Boolean!
@ -563,18 +562,14 @@ export default gql`
input EngagementCreateInput { input EngagementCreateInput {
engagementTypeId: ID! engagementTypeId: ID!
"will use CURRENT_DATE if not set" dateRange: DateRangeInput
from: Date
"will use infinit if not set"
to: Date
participantId: ID! participantId: ID!
cargoBikeId: ID! cargoBikeId: ID!
} }
input EngagementUpdateInput { input EngagementUpdateInput {
id: ID! id: ID!
engagementTypeId: ID engagementTypeId: ID
from: Date dateRange: DateRangeInput
to: Date
participantId: ID participantId: ID
cargoBikeId: ID cargoBikeId: ID
keepLock: Boolean keepLock: Boolean

Loading…
Cancel
Save