feat(pilot): add next TOs to a court
This commit is contained in:
@@ -152,4 +152,10 @@ export class WaitingServiceJudgesService {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async getCurrentUmpire(): Promise<Umpire | undefined> {
|
||||
const item = await db.waitingServiceJudges.where('order').equals(1).first();
|
||||
|
||||
return item ? db.umpires.get(item.serviceJudgeId) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,4 +152,10 @@ export class WaitingUmpiresService {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async getCurrentUmpire(): Promise<Umpire | undefined> {
|
||||
const item = await db.waitingUmpires.where('order').equals(1).first();
|
||||
|
||||
return item ? db.umpires.get(item.umpireId) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,15 +80,29 @@
|
||||
<ion-col size="2" sizeLg="1">
|
||||
<ion-list>
|
||||
<ion-item lines="none">
|
||||
@if (umpireByCourt().get($index + 1) &&
|
||||
serviceJudgeByCourt().get($index + 1)) {
|
||||
<ion-button
|
||||
[color]="'danger'"
|
||||
[disabled]="!umpireByCourt().get($index + 1) || !serviceJudgeByCourt().get($index + 1)"
|
||||
(click)="showRemoveConfirmation($index + 1)">
|
||||
<ion-icon
|
||||
slot="icon-only"
|
||||
size="large"
|
||||
name="exit-outline"></ion-icon>
|
||||
</ion-button>
|
||||
} @else if (!umpireByCourt().get($index + 1) &&
|
||||
!serviceJudgeByCourt().get($index + 1) && waitingUmpires().length &&
|
||||
waitingServiceJudges().length) {
|
||||
<ion-button
|
||||
[color]="'success'"
|
||||
[disabled]=""
|
||||
(click)="showAddConfirmation($index + 1)">
|
||||
<ion-icon
|
||||
slot="icon-only"
|
||||
size="large"
|
||||
name="enter-outline"></ion-icon>
|
||||
</ion-button>
|
||||
}
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-col>
|
||||
|
||||
@@ -31,7 +31,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { CourtUmpireService } from '../services/court.umpire.service';
|
||||
import { CourtServiceJudgeService } from '../services/court.service.judge.service';
|
||||
import { addIcons } from 'ionicons';
|
||||
import { exitOutline } from 'ionicons/icons';
|
||||
import { enterOutline, exitOutline } from 'ionicons/icons';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tab1',
|
||||
@@ -61,7 +61,7 @@ import { exitOutline } from 'ionicons/icons';
|
||||
})
|
||||
export class Tab1Page {
|
||||
constructor() {
|
||||
addIcons({ exitOutline });
|
||||
addIcons({ exitOutline, enterOutline });
|
||||
}
|
||||
|
||||
readonly settingsService = inject(SettingsService);
|
||||
@@ -417,4 +417,51 @@ export class Tab1Page {
|
||||
await this.waitingUmpireService.add(serviceJudge.id);
|
||||
await this.waitingServiceJudgeService.add(umpire.id);
|
||||
}
|
||||
|
||||
public async showAddConfirmation(courtNo: number) {
|
||||
const umpire = await this.waitingUmpireService.getCurrentUmpire();
|
||||
const serviceJudge =
|
||||
await this.waitingServiceJudgeService.getCurrentUmpire();
|
||||
|
||||
if (typeof umpire === 'undefined' || typeof serviceJudge === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
const alert = await this.alertController.create({
|
||||
header: `Pálya ${courtNo}`,
|
||||
cssClass: 'wide',
|
||||
subHeader: 'Biztos pályára küldöd őket?',
|
||||
message: `${this.fullnamePipe.transform(umpire)} - ${this.fullnamePipe.transform(serviceJudge)}`,
|
||||
buttons: [
|
||||
{
|
||||
text: 'Nem',
|
||||
role: 'cancel'
|
||||
},
|
||||
{
|
||||
text: 'Igen',
|
||||
role: 'confirm',
|
||||
handler: () => {
|
||||
this.addUmpiresToCourt(courtNo, umpire, serviceJudge);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await alert.present();
|
||||
}
|
||||
|
||||
private async addUmpiresToCourt(
|
||||
courtNo: number,
|
||||
umpire: Umpire,
|
||||
serviceJudge: Umpire
|
||||
) {
|
||||
await this.courtUmpireService.save({ courtNo, umpireId: umpire.id });
|
||||
await this.courtServiceJudgeService.save({
|
||||
courtNo,
|
||||
umpireId: serviceJudge.id
|
||||
});
|
||||
|
||||
await this.waitingUmpireService.removeByUmpireId(umpire.id);
|
||||
await this.waitingServiceJudgeService.removeByUmpireId(serviceJudge.id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user