several bug fixes

pull/35/head
leonnicolas 4 years ago
parent adab4ea272
commit e34e544629
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -237,12 +237,13 @@ export class CargoBikeAPI extends DataSource {
}
async createBikeEvent ({ bikeEvent }: { bikeEvent: any }) {
return (await this.connection.getRepository(BikeEvent)
const inserts = await this.connection.getRepository(BikeEvent)
.createQueryBuilder('be')
.insert()
.values([bikeEvent])
.returning('*')
.execute()).generatedMaps[0];
.execute();
return await this.bikeEventById(inserts.identifiers[0].id);
}
async updateBikeEvent (bikeEvent: any, userId: number) {
@ -310,7 +311,7 @@ export class CargoBikeAPI extends DataSource {
return (await this.connection.getRepository(BikeEventType)
.createQueryBuilder('bet')
.insert()
.values([{ name: bikeEventType }])
.values([bikeEventType])
.returning('*')
.execute())?.generatedMaps[0];
}

@ -134,6 +134,14 @@ export class WorkshopAPI extends DataSource {
.getOne();
}
async workshopTypeByWorkshopId (id: number) {
return await this.connection.getRepository(Workshop)
.createQueryBuilder('w')
.relation(Workshop, 'workshopTypeId')
.of(id)
.loadOne();
}
async workshopTypes (offset?: number, limit?: number) {
return DBUtils.getAllEntity(this.connection, WorkshopType, 'wt', offset, limit);
}

@ -215,11 +215,14 @@ export default {
},
related (parent: any, __: any, { dataSources, req }: { dataSources: any, req: any }) {
if (req.permissions.includes(Permission.ReadParticipant)) {
return dataSources.cargoBikeAPI.relatedByBikeEventId(parent.id);
return dataSources.cargoBikeAPI.relatedByBikeEventId(parent.workshopTypeId);
} else {
throw new PermissionError();
}
},
documents: (parent: any) => {
return (parent.documents) ? parent.documents : [];
},
isLockedByMe: (parent: any, __: any, { req }: { req: any }) => isLockedByMe(parent, { req }),
isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req })
},
@ -368,9 +371,9 @@ export default {
throw new PermissionError();
}
},
createBikeEventType: (_: any, { name }: { name: any }, { dataSources, req }: { dataSources: any, req: any }) => {
createBikeEventType: (_: any, { bikeEventType }: { bikeEventType: any }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.WriteEventType)) {
return dataSources.cargoBikeAPI.createBikeEventType(name);
return dataSources.cargoBikeAPI.createBikeEventType(bikeEventType);
} else {
throw new PermissionError();
}

@ -75,6 +75,13 @@ export default {
throw new PermissionError();
}
},
workshopType (parent: any, _: any, { dataSources, req }: { dataSources: any; req: any }) {
if (req.permissions.includes(Permission.ReadWorkshop)) {
return dataSources.workshopAPI.workshopTypeByWorkshopId(parent.id);
} else {
throw new PermissionError();
}
},
isLockedByMe: (parent: any, __: any, { req }: { req: any }) => isLockedByMe(parent, { req }),
isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req })
},

@ -723,6 +723,10 @@ export default gql`
keepLock: Boolean
}
input BikeEventTypeCreateInput {
name: String!
}
"(dt. Anbieter) bezieht sich auf die Beziehung einer Person oder Organisation zum Lastenrad"
type Provider {
id: ID!
@ -1126,7 +1130,7 @@ export default gql`
"""
BIKEEVENT
"""
createBikeEventType(name: String!): BikeEventType!
createBikeEventType(bikeEventType: BikeEventTypeCreateInput!): BikeEventType!
lockBikeEventType(id: ID!): BikeEventType!
unlockBikeEventType(id:ID!): BikeEventType!
updateBikeEventType(bikeEventType: BikeEventTypeUpdateInput!): BikeEventType!

Loading…
Cancel
Save