1
|
|
|
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from 'typeorm'; |
2
|
|
|
import {User} from '../User/User.entity'; |
3
|
|
|
import {Task} from '../Task/Task.entity'; |
4
|
|
|
import {Project} from '../Project/Project.entity'; |
5
|
|
|
|
6
|
|
|
export enum EventType { |
7
|
|
|
MISSION = 'mission', |
8
|
|
|
SUPPORT = 'support', |
9
|
|
|
DOJO = 'dojo', |
10
|
|
|
HOLIDAY = 'holiday', |
11
|
|
|
FORMATION_CONFERENCE = 'formationConference', |
12
|
|
|
WORK_FREE = 'workFree', |
13
|
|
|
MEDICAL_LEAVE = 'medicalLeave', |
14
|
|
|
OTHER = 'other' |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
@Entity() |
18
|
|
|
export class Event { |
19
|
|
|
// Times spent are stored in base 100 |
20
|
|
|
public static readonly MAXIMUM_TIMESPENT_PER_DAY: number = 100; |
21
|
|
|
|
22
|
|
|
@PrimaryGeneratedColumn('uuid') |
23
|
|
|
private id: string; |
24
|
|
|
|
25
|
|
|
@Column('enum', {enum: EventType, nullable: false}) |
26
|
|
|
private type: EventType; |
27
|
|
|
|
28
|
|
|
@Column({type: 'integer', nullable: false}) |
29
|
|
|
private time: number; |
30
|
|
|
|
31
|
|
|
@Column({type: 'date', nullable: false}) |
32
|
|
|
private date: string; |
33
|
|
|
|
34
|
|
|
@Column({type: 'varchar', nullable: true}) |
35
|
|
|
private summary: string; |
36
|
|
|
|
37
|
|
|
@ManyToOne(type => Project, {nullable: true}) |
38
|
|
|
private project: Project; |
39
|
|
|
|
40
|
|
|
@ManyToOne(type => Task, {nullable: true}) |
41
|
|
|
private task: Task; |
42
|
|
|
|
43
|
|
|
@ManyToOne(type => User, {nullable: false}) |
44
|
|
|
private user: User; |
45
|
|
|
|
46
|
|
|
constructor( |
47
|
|
|
type: EventType, |
48
|
|
|
user: User, |
49
|
|
|
time: number, |
50
|
|
|
date: string, |
51
|
|
|
project?: Project, |
52
|
|
|
task?: Task, |
53
|
|
|
summary?: string |
54
|
|
|
) { |
55
|
|
|
this.type = type; |
56
|
|
|
this.user = user; |
57
|
|
|
this.time = time; |
58
|
|
|
this.date = date; |
59
|
|
|
this.project = project; |
60
|
|
|
this.task = task; |
61
|
|
|
this.summary = summary; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public getId(): string { |
65
|
|
|
return this.id; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public getType(): string { |
69
|
|
|
return this.type; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public getTime(): number { |
73
|
|
|
return this.time; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public getDate(): string { |
77
|
|
|
return this.date; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public getSummary(): string | null { |
81
|
|
|
return this.summary; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public getProject(): Project | null { |
85
|
|
|
return this.project; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public getTask(): Task | null { |
89
|
|
|
return this.task; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public getUser(): User { |
93
|
|
|
return this.user; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|