Projekt

Obecné

Profil

« Předchozí | Další » 

Revize f8b40fd5

Přidáno uživatelem Hung Hoang před téměř 6 roky(ů)

Re#7494 Implemented edit user settings

Zobrazit rozdíly:

webapp/src/app/employees/edit-employee-dialog/edit-employee-dialog.component.ts
1
import {Component, Inject, Input, OnInit} from '@angular/core';
2
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
3
import {User} from '../user.model';
1
import {Component, EventEmitter, Inject, OnInit, Output} from '@angular/core';
2
import {MAT_DIALOG_DATA, MatDialogRef, MatSnackBar} from '@angular/material';
4 3
import {UserType} from '../../enums/common.enum';
4
import {UserProfile} from '../../models/user.model';
5
import {UserSettings} from '../../models/settings.model';
5 6

  
6 7

  
7 8
@Component({
......
10 11
  styleUrls: ['./edit-employee-dialog.component.sass']
11 12
})
12 13
export class EditEmployeeDialogComponent implements OnInit {
13
  readonly _userTypes: string[] = ['Zaměstnanec', 'Zaměstnavatel'];
14
  readonly _userTypes: string[] = ['EMPLOYER', 'EMPLOYEE'];
14 15
  private _sickDaysCount: number;
15 16
  private _vacationDaysCount: number;
16 17
  private _userType: UserType;
18
  private readonly _userId: number;
19
  @Output() postUserSettings = new EventEmitter<UserSettings>();
17 20

  
18 21
  constructor(public dialogRef: MatDialogRef<EditEmployeeDialogComponent>,
19
              @Inject(MAT_DIALOG_DATA) public data: User) {
20

  
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;
21 28
  }
22 29

  
23 30
  ngOnInit() {
24 31
  }
25 32

  
26
  @Input()
27
  set userType(userType: string) {
28
    this._userType = UserType.EMPLOYEE;
29
    console.log('intercepted ' + this._userType);
30
  }
31

  
32 33
  onConfirmClick(): void {
33
    this.dialogRef.close();
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
    }
34 46
  }
35 47

  
36

  
37 48
  onCloseClick(): void {
38 49
    this.dialogRef.close();
39 50
  }

Také k dispozici: Unified diff