Projekt

Obecné

Profil

Stáhnout (1.57 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { Component, Inject } from '@angular/core';
2
import { MAT_DIALOG_DATA, MatDialogRef, MatSnackBar } from '@angular/material';
3
import { FormControl } from '@angular/forms';
4

    
5
@Component({
6
  selector: 'app-add-days-off-dialog',
7
  templateUrl: './add-days-off-dialog.component.html',
8
  styleUrls: ['./add-days-off-dialog.component.sass']
9
})
10
export class AddDaysOffDialogComponent {
11
  MINUTE_STEP = 15;
12

    
13
  selectedDaysOffType: string;
14
  daysOffTypes: string[] = ['Sick-days', 'Extra dovolená'];
15

    
16
  constructor(
17
    public dialogRef: MatDialogRef<AddDaysOffDialogComponent>,
18
    @Inject(MAT_DIALOG_DATA) public data: AddDaysOffDialogData,
19
    private snackBar: MatSnackBar
20
  ) {
21
    if (this.data.toDate == null) {
22
      this.data.toDate = this.data.fromDate;
23
    }
24
    if (this.data.fromTime == null) {
25
      this.data.fromTime = {hour: 8, minute: 0};
26
    }
27
    if (data.toTime == null) {
28
      this.data.toTime = {hour: 16, minute: 0};
29
    }
30
  }
31

    
32
  onConfirmClick(): void {
33
    // TODO lokalizace
34

    
35
    if (this.selectedDaysOffType == null) {
36
      this.snackBar.open('Nevybrán typ volna', 'Zavřít', { duration: 5000 });
37
    } else if (this.data.fromDate > this.data.toDate) {
38
      this.snackBar.open('Datum "od" nemůže být větší než "do"', 'Zavřít', { duration: 5000 });
39
    } else {
40
      // TODO API CALL
41
      this.dialogRef.close();
42
    }
43
  }
44

    
45
  onCloseClick(): void {
46
    this.dialogRef.close();
47
  }
48

    
49
}
50

    
51
export interface AddDaysOffDialogData {
52
  fromDate: FormControl;
53
  toDate: FormControl;
54
  fromTime: { hour: number, minute: number };
55
  toTime: { hour: number, minute: number };
56
}
(3-3/4)