1
|
import {Component, Inject} from '@angular/core';
|
2
|
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
|
3
|
|
4
|
@Component({
|
5
|
selector: 'app-default-settings',
|
6
|
templateUrl: './default-settings-dialog.component.html',
|
7
|
styleUrls: ['./default-settings.component.sass']
|
8
|
})
|
9
|
export class DefaultSettingsDialogComponent {
|
10
|
MINUTE_STEP = 15;
|
11
|
|
12
|
constructor(
|
13
|
public dialogRef: MatDialogRef<DefaultSettingsDialogComponent>,
|
14
|
@Inject(MAT_DIALOG_DATA) public data: DefaultSettingsDialogData
|
15
|
) {
|
16
|
}
|
17
|
|
18
|
onConfirmClick(): void {
|
19
|
let data;
|
20
|
if (this.data.notificationDate && sickDayCount) {
|
21
|
data = {
|
22
|
isConfirmed: true,
|
23
|
notificationDatetime: this.toNotificationDatetime(),
|
24
|
sickDayCount: this.data.sickDayCount
|
25
|
};
|
26
|
} else {
|
27
|
data = {
|
28
|
isConfirmed: false
|
29
|
};
|
30
|
}
|
31
|
|
32
|
this.dialogRef.close(data);
|
33
|
}
|
34
|
|
35
|
onCloseClick(): void {
|
36
|
this.dialogRef.close({
|
37
|
isConfirmed: false
|
38
|
});
|
39
|
}
|
40
|
|
41
|
private toNotificationDatetime(): Date {
|
42
|
const splittedTime = this.data.notificationTime.split(':');
|
43
|
|
44
|
return new Date(
|
45
|
this.data.notificationDate.getFullYear(),
|
46
|
this.data.notificationDate.getMonth(),
|
47
|
this.data.notificationDate.getDate(),
|
48
|
Number(splittedTime[0]),
|
49
|
Number(splittedTime[1])
|
50
|
);
|
51
|
}
|
52
|
|
53
|
}
|
54
|
|
55
|
export class DefaultSettingsDialogData {
|
56
|
notificationDate: Date;
|
57
|
notificationTime: string;
|
58
|
sickDayCount: number;
|
59
|
}
|