Skip to content

Commit a3f989d

Browse files
authored
Merge pull request #625 from bettercodepaul/swt2#2114
swt2#2115 Auto-Fokus auf Bestätigen-Button nach letztem Schuss
2 parents 7730a5e + 79e04e0 commit a3f989d

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

bogenliga/src/app/modules/schusszettel/components/maske2eingabe/passe-eingabe.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h2>Passe {{ currentPasse }}</h2>
8181
</table>
8282
</div>
8383

84-
<button mat-raised-button color="primary" type="submit" [disabled]="form.invalid" class="confirm-button">
84+
<button #confirmButton mat-raised-button color="primary" type="submit" [disabled]="form.invalid" class="confirm-button">
8585
Eingabe bestätigen <span class="arrow"></span>
8686
</button>
8787
</form>

bogenliga/src/app/modules/schusszettel/components/maske2eingabe/passe-eingabe.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
22
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';
44
import {TabletSchusszettel} from '../../models/tablet-schusszettel.model';
55
import {SchuetzenSatzDTO} from '../../types/datatransfer/satz-eingabe-dto';
66
import {SchuetzeStammdatenDTO} from '../../types/inside/schuetze-stammdaten-dto';
77
import {ShooterOrderService} from '../../services/shooter-order.service';
88
import {Subject} from 'rxjs';
99
import {AppComponent} from 'src/app/app.component';
10-
import {QueryList, ViewChildren, ElementRef} from '@angular/core';
10+
import {QueryList, ViewChild, ViewChildren, ElementRef} from '@angular/core';
1111
import {
1212
NotificationService,
1313
NotificationSeverity,
@@ -40,6 +40,7 @@ export class PasseEingabeComponent implements OnInit, OnDestroy {
4040
) {}
4141

4242
@ViewChildren('inputField') inputFields: QueryList<ElementRef>;
43+
@ViewChild('confirmButton', { read: ElementRef }) confirmButton?: ElementRef;
4344

4445
getInputElement(field: string, i: number): ElementRef | undefined {
4546
const id = `${field}-${i}`;
@@ -170,7 +171,7 @@ export class PasseEingabeComponent implements OnInit, OnDestroy {
170171
formArray.insert(event.currentIndex, item);
171172

172173
// Save the new order
173-
const shooterIds = this.orderedShooters.map(s => s.schuetzenId);
174+
const shooterIds = this.orderedShooters.map((s) => s.schuetzenId);
174175
this.shooterOrderService.saveShooterOrder(
175176
this.infos.eigenesTeam.teamId,
176177
this.infos.wettkampfInfo?.wettkampfId || 0,
@@ -227,6 +228,12 @@ export class PasseEingabeComponent implements OnInit, OnDestroy {
227228
}
228229

229230
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+
}
230237
const nextFieldId =
231238
field === 'schuss1'
232239
? `schuss2-${i}`

0 commit comments

Comments
 (0)