Merge pull request #24 from fLotte-meets-HWR-DB/dev

Dev
pull/26/head
leonnicolas 4 years ago committed by GitHub
commit eae48349c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

@ -65,7 +65,9 @@ export interface Lockable {
} }
export class Security { export class Security {
@Column() @Column({
nullable: true
})
frameNumber: string; frameNumber: string;
@Column({ @Column({
@ -190,9 +192,6 @@ export class CargoBike implements Lockable {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@DeleteDateColumn()
deleteDate: Date;
@Column({ @Column({
type: 'enum', type: 'enum',
enum: Group enum: Group
@ -268,19 +267,32 @@ export class CargoBike implements Lockable {
}) })
description: string; description: string;
@Column() @Column({
nullable: true
})
modelName: string; modelName: string;
@Column() @Column({
nullable: true
})
numberOfWheels: number; numberOfWheels: number;
@Column() @Column({
type: 'boolean',
nullable: true
})
forCargo: boolean; forCargo: boolean;
@Column() @Column({
type: 'boolean',
nullable: true
})
forChildren: boolean; forChildren: boolean;
@Column() @Column({
type: 'int',
nullable: true
})
numberOfChildren: number; numberOfChildren: number;
@Column(type => TechnicalEquipment) @Column(type => TechnicalEquipment)
@ -290,6 +302,7 @@ export class CargoBike implements Lockable {
dimensionsAndLoad: DimensionsAndLoad; dimensionsAndLoad: DimensionsAndLoad;
@Column({ @Column({
type: 'int',
nullable: true nullable: true
}) })
lockedBy: number; lockedBy: number;

@ -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 })
}, },

@ -45,12 +45,12 @@ export default gql`
numberOfWheels: Int numberOfWheels: Int
forCargo: Boolean forCargo: Boolean
forChildren: Boolean forChildren: Boolean
numberOfChildren: Int! numberOfChildren: Int
""" """
Safety is a custom type, that stores information about security features. Safety is a custom type, that stores information about security features.
TODO: Should this be called Security? TODO: Should this be called Security?
""" """
security: Security! security: Security
""" """
Does not refer to an extra table in the database. Does not refer to an extra table in the database.
""" """
@ -102,15 +102,15 @@ export default gql`
group: Group! group: Group!
name: String! name: String!
state: BikeState state: BikeState
modelName: String! modelName: String
numberOfWheels: Int! numberOfWheels: Int
forCargo: Boolean! forCargo: Boolean
forChildren: Boolean! forChildren: Boolean
numberOfChildren: Int! numberOfChildren: Int
""" """
Safety is a custom type, that stores information about security features. Safety is a custom type, that stores information about security features.
""" """
security: SecurityCreateInput! security: SecurityCreateInput
""" """
Does not refer to an extra table in the database. Does not refer to an extra table in the database.
""" """
@ -360,7 +360,7 @@ export default gql`
So no id needed for mutation. One Mutation for the CargoBike will be enough. So no id needed for mutation. One Mutation for the CargoBike will be enough.
""" """
type Security { type Security {
frameNumber: String! frameNumber: String
keyNumberFrameLock: String keyNumberFrameLock: String
keyNumberAXAChain: String keyNumberAXAChain: String
policeCoding: String policeCoding: String
@ -368,7 +368,7 @@ export default gql`
} }
input SecurityCreateInput { input SecurityCreateInput {
frameNumber: String! frameNumber: String
keyNumberFrameLock: String keyNumberFrameLock: String
keyNumberAXAChain: String keyNumberAXAChain: String
policeCoding: String policeCoding: String
@ -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