|
1 | 1 | import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core'; |
2 | 2 | import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms'; |
3 | | -import {CdkDragDrop, moveItemInArray} from '@angular/cdk/drag-drop'; |
| 3 | +import {CdkDragDrop} from '@angular/cdk/drag-drop'; |
4 | 4 | import {TabletSchusszettel} from '../../models/tablet-schusszettel.model'; |
5 | 5 | import {SchuetzenSatzDTO} from '../../types/datatransfer/satz-eingabe-dto'; |
6 | 6 | import {SchuetzeStammdatenDTO} from '../../types/inside/schuetze-stammdaten-dto'; |
7 | 7 | import {ShooterOrderService} from '../../services/shooter-order.service'; |
8 | 8 | import {Subject} from 'rxjs'; |
9 | 9 | import {AppComponent} from 'src/app/app.component'; |
10 | | -import {QueryList, ViewChildren, ElementRef} from '@angular/core'; |
| 10 | +import {QueryList, ViewChild, ViewChildren, ElementRef} from '@angular/core'; |
11 | 11 | import { |
12 | 12 | NotificationService, |
13 | 13 | NotificationSeverity, |
@@ -40,6 +40,7 @@ export class PasseEingabeComponent implements OnInit, OnDestroy { |
40 | 40 | ) {} |
41 | 41 |
|
42 | 42 | @ViewChildren('inputField') inputFields: QueryList<ElementRef>; |
| 43 | + @ViewChild('confirmButton', { read: ElementRef }) confirmButton?: ElementRef; |
43 | 44 |
|
44 | 45 | getInputElement(field: string, i: number): ElementRef | undefined { |
45 | 46 | const id = `${field}-${i}`; |
@@ -170,7 +171,7 @@ export class PasseEingabeComponent implements OnInit, OnDestroy { |
170 | 171 | formArray.insert(event.currentIndex, item); |
171 | 172 |
|
172 | 173 | // Save the new order |
173 | | - const shooterIds = this.orderedShooters.map(s => s.schuetzenId); |
| 174 | + const shooterIds = this.orderedShooters.map((s) => s.schuetzenId); |
174 | 175 | this.shooterOrderService.saveShooterOrder( |
175 | 176 | this.infos.eigenesTeam.teamId, |
176 | 177 | this.infos.wettkampfInfo?.wettkampfId || 0, |
@@ -227,6 +228,12 @@ export class PasseEingabeComponent implements OnInit, OnDestroy { |
227 | 228 | } |
228 | 229 |
|
229 | 230 | focusNextField(i: number, field: 'schuss1' | 'schuss2') { |
| 231 | + if (field === 'schuss2' && i === this.orderedShooters.length - 1) { |
| 232 | + if (this.form.valid && this.confirmButton) { |
| 233 | + this.confirmButton.nativeElement.focus(); |
| 234 | + } |
| 235 | + return; |
| 236 | + } |
230 | 237 | const nextFieldId = |
231 | 238 | field === 'schuss1' |
232 | 239 | ? `schuss2-${i}` |
|
0 commit comments