]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { Component, OnInit } from '@angular/core'; |
2 | import { Validators } from '@angular/forms'; | |
3 | ||
f67539c2 | 4 | import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; |
11fdf7f2 | 5 | |
f67539c2 TL |
6 | import { OsdService } from '~/app/shared/api/osd.service'; |
7 | import { ActionLabelsI18n } from '~/app/shared/constants/app.constants'; | |
8 | import { CdFormBuilder } from '~/app/shared/forms/cd-form-builder'; | |
9 | import { CdFormGroup } from '~/app/shared/forms/cd-form-group'; | |
11fdf7f2 TL |
10 | |
11 | @Component({ | |
12 | selector: 'cd-osd-reweight-modal', | |
13 | templateUrl: './osd-reweight-modal.component.html', | |
14 | styleUrls: ['./osd-reweight-modal.component.scss'] | |
15 | }) | |
16 | export class OsdReweightModalComponent implements OnInit { | |
17 | currentWeight = 1; | |
18 | osdId: number; | |
19 | reweightForm: CdFormGroup; | |
20 | ||
21 | constructor( | |
f67539c2 TL |
22 | public actionLabels: ActionLabelsI18n, |
23 | public activeModal: NgbActiveModal, | |
11fdf7f2 TL |
24 | private osdService: OsdService, |
25 | private fb: CdFormBuilder | |
26 | ) {} | |
27 | ||
28 | get weight() { | |
29 | return this.reweightForm.get('weight'); | |
30 | } | |
31 | ||
32 | ngOnInit() { | |
33 | this.reweightForm = this.fb.group({ | |
20effc67 | 34 | weight: this.fb.control(this.currentWeight, [Validators.required]) |
11fdf7f2 TL |
35 | }); |
36 | } | |
37 | ||
38 | reweight() { | |
39 | this.osdService | |
40 | .reweight(this.osdId, this.reweightForm.value.weight) | |
f67539c2 | 41 | .subscribe(() => this.activeModal.close()); |
11fdf7f2 TL |
42 | } |
43 | } |