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 _vacationDaysCount: number;
17
  private _userType: UserType;
18
  private readonly _userId: number;
19
  @Output() postUserSettings = new EventEmitter<UserSettings>();
20

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

    
30
  ngOnInit() {
31
  }
32

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

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

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

    
52
}
(3-3/3)