Projekt

Obecné

Profil

Stáhnout (1.65 KB) Statistiky
| Větev: | Tag: | Revize:
1 8ef49edd Hung Hoang
import {Component, EventEmitter, Inject, OnInit, Output} from '@angular/core';
2
import {MAT_DIALOG_DATA, MatDialogRef, MatSnackBar} from '@angular/material';
3 79d7de40 Hung Hoang
import {UserType} from '../../enums/common.enum';
4 8ef49edd Hung Hoang
import {UserProfile} from '../../models/user.model';
5
import {UserSettings} from '../../models/settings.model';
6 79d7de40 Hung Hoang
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 8ef49edd Hung Hoang
  readonly _userTypes: string[] = ['EMPLOYER', 'EMPLOYEE'];
15 79d7de40 Hung Hoang
  private _sickDaysCount: number;
16
  private _vacationDaysCount: number;
17
  private _userType: UserType;
18 8ef49edd Hung Hoang
  private readonly _userId: number;
19
  @Output() postUserSettings = new EventEmitter<UserSettings>();
20 79d7de40 Hung Hoang
21
  constructor(public dialogRef: MatDialogRef<EditEmployeeDialogComponent>,
22 8ef49edd Hung Hoang
              @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 79d7de40 Hung Hoang
  }
29
30
  ngOnInit() {
31
  }
32
33
  onConfirmClick(): void {
34 8ef49edd Hung Hoang
    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 79d7de40 Hung Hoang
  }
47
48
  onCloseClick(): void {
49
    this.dialogRef.close();
50
  }
51
52
}