1 |
bb7795cd
|
hlavja
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
2 |
a3ae1cab
|
hlavja
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
3 |
|
|
import {ManagementService} from '../../../shared/api/endpoints/services/management.service';
|
4 |
bb7795cd
|
hlavja
|
|
5 |
|
|
@Component({
|
6 |
25a20eec
|
hlavja
|
selector: 'app-unit-popup',
|
7 |
bb7795cd
|
hlavja
|
templateUrl: './unit-popup.component.html',
|
8 |
|
|
styleUrls: ['./unit-popup.component.scss']
|
9 |
|
|
})
|
10 |
|
|
export class UnitPopupComponent implements OnInit {
|
11 |
|
|
|
12 |
a3ae1cab
|
hlavja
|
insertForm: FormGroup;
|
13 |
|
|
|
14 |
bb7795cd
|
hlavja
|
@Input() isVisible;
|
15 |
|
|
@Input() unit;
|
16 |
|
|
@Output() isVisibleChange: EventEmitter<boolean> = new EventEmitter<boolean>();
|
17 |
a3ae1cab
|
hlavja
|
|
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 |
abe9aea2
|
hlavja
|
unitDescription: ['', Validators.required]
|
28 |
a3ae1cab
|
hlavja
|
});
|
29 |
|
|
}
|
30 |
bb7795cd
|
hlavja
|
|
31 |
|
|
ngOnInit(): void {
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
|
35 |
a3ae1cab
|
hlavja
|
saveUnit() {
|
36 |
abe9aea2
|
hlavja
|
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 |
bb7795cd
|
hlavja
|
}
|
42 |
|
|
|
43 |
|
|
close() {
|
44 |
a3ae1cab
|
hlavja
|
this.insertForm.reset();
|
45 |
bb7795cd
|
hlavja
|
this.isVisibleChange.emit(false);
|
46 |
|
|
}
|
47 |
|
|
}
|