-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-meeting-modal.component.ts
More file actions
131 lines (111 loc) · 3.77 KB
/
Copy pathadd-meeting-modal.component.ts
File metadata and controls
131 lines (111 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { Component, Inject, OnDestroy, Optional } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Subscription } from 'rxjs';
import { YesNoToBooleanMapper } from 'src/app/shared/mappers/yes-no.mapper';
import { AttritionRisk, MeetingNotes, YesNo } from '../../models/meeting-notes.model';
import { PersonService } from '../../services/person.service';
import * as moment from 'moment';
import { inputValidator } from 'src/app/shared/validators/field.validator';
@Component({
selector: 'app-modal',
templateUrl: './add-meeting-modal.component.html',
styleUrls: ['./add-meeting-modal.component.css']
})
export class AddMeetingModalComponent implements OnDestroy {
private static readonly DATE_FORMAT = 'MM/DD/YYYY';
meetingForm: FormGroup;
cdkAutosizeMinRows = 1;
cdkAutosizeMaxRows = 4;
attritionRiskValues = [
AttritionRisk.NONE,
AttritionRisk.LOW,
AttritionRisk.MEDIUM,
AttritionRisk.HIGH
];
addMeetingNotes$?: Subscription;
constructor(
private dialogRef: MatDialogRef<AddMeetingModalComponent>,
private formBuilder: FormBuilder,
private personService: PersonService,
private yesNoMapper: YesNoToBooleanMapper,
@Optional() @Inject(MAT_DIALOG_DATA) protected personData: { id: string, name: string, unitId: string }
) {
this.meetingForm = this.formBuilder.group({
date: ['', [Validators.required]],
comments: ['', null, [inputValidator]],
questions: [''],
managerActionItems: [''],
subordinateActionItems: [''],
importantAgreements: [''],
satisfaction: [''],
plans: [''],
feedback: [''],
issues: [''],
attritionRisk: [AttritionRisk.NONE],
oneToOneReportSent: [YesNo.NO]
});
}
ngOnDestroy(): void {
this.addMeetingNotes$?.unsubscribe();
}
get date() {
const date: moment.Moment = this.meetingForm.get('date')!.value.date;
return date.format(AddMeetingModalComponent.DATE_FORMAT);
}
get comments() {
return this.meetingForm.get('comments')!.value;
}
get commentsControl() {
return this.meetingForm.get("comments");
}
get questions() {
return this.meetingForm.get('questions')!.value;
}
get managerActionItems() {
return this.meetingForm.get('managerActionItems')!.value;
}
get subordinateActionItems() {
return this.meetingForm.get('subordinateActionItems')!.value;
}
get importantAgreements() {
return this.meetingForm.get('importantAgreements')!.value;
}
get satisfaction() {
return this.meetingForm.get('satisfaction')!.value;
}
get plans() {
return this.meetingForm.get('plans')!.value;
}
get feedback() {
return this.meetingForm.get('feedback')!.value;
}
get issues() {
return this.meetingForm.get('issues')!.value;
}
get attritionRisk() {
return this.meetingForm.get('attritionRisk')!.value;
}
get oneToOneReportSent() {
return this.meetingForm.get('oneToOneReportSent')!.value;
}
onSubmit() {
const meetingNotes: MeetingNotes = {
date: this.date,
personId: this.personData.id,
comments: this.comments,
questions: this.questions,
managerActionItems: this.managerActionItems,
subordinateActionItems: this.subordinateActionItems,
importantAgreements: this.importantAgreements,
satisfaction: this.satisfaction,
plans: this.plans,
feedback: this.feedback,
issues: this.issues,
attritionRisk: this.attritionRisk,
oneToOneReportSent: this.yesNoMapper.toClient(this.oneToOneReportSent)
}
this.addMeetingNotes$ = this.personService.addMeetingNotes(this.personData.unitId, meetingNotes)
.subscribe(response => this.dialogRef.close({ meetingNotes }));
}
}