Projekt

Obecné

Profil

Stáhnout (1.65 KB) Statistiky
| Větev: | Tag: | Revize:
1
import {Component, EventEmitter, Inject, OnInit, Output} from '@angular/core';
2
import {MAT_DIALOG_DATA, MatDialogRef, MatSnackBar} from '@angular/material';
3
import {UserType} from '../../enums/common.enum';
4
import {UserProfile} from '../../models/user.model';
5
import {UserSettings} from '../../models/settings.model';
6

    
7

    
8
@Component({
9
  selector: 'app-edit-employee-dialog',
10
  templateUrl: './edit-employee-dialog.component.html',
11
  styleUrls: ['./edit-employee-dialog.component.sass']
12
})
13
export class EditEmployeeDialogComponent implements OnInit {
14
  readonly _userTypes: string[] = ['EMPLOYER', 'EMPLOYEE'];
15
  private _sickDaysCount: number;
16
  private _addVacationHoursCount: number;
17
  private _userType: UserType;
18
  private readonly _userId: number;
19

    
20
  @Output() postUserSettings = new EventEmitter<UserSettings>();
21

    
22
  constructor(public dialogRef: MatDialogRef<EditEmployeeDialogComponent>,
23
              @Inject(MAT_DIALOG_DATA) public data: UserProfile,
24
              private snackBar: MatSnackBar) {
25
    this._sickDaysCount = data.sickDayCount;
26
    this._addVacationHoursCount = 0;
27
    this._userType = data.role;
28
    this._userId = data.id;
29
  }
30

    
31
  ngOnInit() {
32
  }
33

    
34
  onConfirmClick(): void {
35
    if (this._sickDaysCount == null || this._addVacationHoursCount == null || this._userType == null) {
36
      this.snackBar.open('Vyplňte prosím všechny údaje', 'Zavřít');
37
    } else {
38
      this.postUserSettings.emit({
39
        id: this._userId,
40
        role: this._userType,
41
        sickDayCount: this._sickDaysCount,
42
        vacationCount: this._addVacationHoursCount
43
      });
44

    
45
      this.dialogRef.close();
46
    }
47
  }
48

    
49
  onCloseClick(): void {
50
    this.dialogRef.close();
51
  }
52

    
53
}
(3-3/3)