Projekt

Obecné

Profil

Stáhnout (1.26 KB) Statistiky
| Větev: | Tag: | Revize:
1
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
2
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
3
import {ManagementService} from '../../../shared/api/endpoints/services/management.service';
4

    
5
@Component({
6
  selector: 'app-unit-popup',
7
  templateUrl: './unit-popup.component.html',
8
  styleUrls: ['./unit-popup.component.scss']
9
})
10
export class UnitPopupComponent implements OnInit {
11

    
12
  insertForm: FormGroup;
13

    
14
  @Input() isVisible;
15
  @Input() unit;
16
  @Output() isVisibleChange: EventEmitter<boolean> = new EventEmitter<boolean>();
17

    
18
  constructor(
19
    private formBuilder: FormBuilder,
20
    private managementService: ManagementService
21
  ) {
22
    this.initForm();
23
  }
24

    
25
  initForm() {
26
    this.insertForm = this.formBuilder.group({
27
      unitDescription: ['', Validators.required]
28
    });
29
  }
30

    
31
  ngOnInit(): void {
32
  }
33

    
34

    
35
  saveUnit() {
36
    if (this.insertForm.controls.unitDescription.value && this.insertForm.controls.unitDescription.value !== this.unit.description) {
37
      this.unit.description = this.insertForm.controls.unitDescription.value;
38
      // TODO this.managementService.updateUnit({ body: { unit: this.unit}});
39
      console.log(this.unit);
40
    }
41
  }
42

    
43
  close() {
44
    this.insertForm.reset();
45
    this.isVisibleChange.emit(false);
46
  }
47
}
(3-3/3)