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

@ -113,13 +113,6 @@ export default {
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 }),
isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req })
},

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

Loading…
Cancel
Save