feat(settings): handle court number settings
This commit is contained in:
@@ -37,6 +37,7 @@ export interface Settings {
|
|||||||
id: number;
|
id: number;
|
||||||
withServiceJudge: boolean;
|
withServiceJudge: boolean;
|
||||||
numberOfCourts: number;
|
numberOfCourts: number;
|
||||||
|
showAlert: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = new Dexie('CourtPilot') as Dexie & {
|
const db = new Dexie('CourtPilot') as Dexie & {
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
<div id="container">
|
|
||||||
<strong>{{ name }}</strong>
|
|
||||||
<p>
|
|
||||||
Explore
|
|
||||||
<a
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
href="https://ionicframework.com/docs/components"
|
|
||||||
>UI Components</a
|
|
||||||
>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#container {
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
#container strong {
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 26px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container p {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 22px;
|
|
||||||
|
|
||||||
color: #8c8c8c;
|
|
||||||
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { ExploreContainerComponent } from './explore-container.component';
|
|
||||||
|
|
||||||
describe('ExploreContainerComponent', () => {
|
|
||||||
let component: ExploreContainerComponent;
|
|
||||||
let fixture: ComponentFixture<ExploreContainerComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
fixture = TestBed.createComponent(ExploreContainerComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-explore-container',
|
|
||||||
templateUrl: './explore-container.component.html',
|
|
||||||
styleUrls: ['./explore-container.component.scss'],
|
|
||||||
})
|
|
||||||
export class ExploreContainerComponent {
|
|
||||||
@Input() name?: string;
|
|
||||||
}
|
|
||||||
@@ -39,7 +39,8 @@ export class SettingsService {
|
|||||||
await db.settings.put({
|
await db.settings.put({
|
||||||
id: 1,
|
id: 1,
|
||||||
numberOfCourts: 5,
|
numberOfCourts: 5,
|
||||||
withServiceJudge: true
|
withServiceJudge: true,
|
||||||
|
showAlert: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-11
@@ -1,17 +1,46 @@
|
|||||||
<ion-header [translucent]="true">
|
<ion-header>
|
||||||
<ion-toolbar>
|
<ion-toolbar>
|
||||||
<ion-title>
|
<ion-title>Beállítások</ion-title>
|
||||||
Tab 3
|
|
||||||
</ion-title>
|
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content [fullscreen]="true">
|
<ion-content>
|
||||||
<ion-header collapse="condense">
|
<ion-grid [fixed]="true">
|
||||||
<ion-toolbar>
|
<ion-row>
|
||||||
<ion-title size="large">Tab 3</ion-title>
|
<ion-col sizeLg="6" pushLg="3">
|
||||||
</ion-toolbar>
|
@if (settings(); as currentSettings) {
|
||||||
</ion-header>
|
|
||||||
|
|
||||||
<app-explore-container name="Tab 3 page"></app-explore-container>
|
<ion-list>
|
||||||
|
<ion-item>
|
||||||
|
<ion-toggle
|
||||||
|
[checked]="currentSettings.withServiceJudge"
|
||||||
|
(ionChange)="updateWithServiceJudge($event)">
|
||||||
|
Adogatásbíró
|
||||||
|
</ion-toggle>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-toggle
|
||||||
|
[checked]="currentSettings.showAlert"
|
||||||
|
(ionChange)="updateShowAlert($event)">
|
||||||
|
Figyelmeztetések megjelenítése a gyors gomboknál
|
||||||
|
</ion-toggle>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-input
|
||||||
|
label="Pályák száma"
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
labelPlacement="floating"
|
||||||
|
[value]="currentSettings.numberOfCourts"
|
||||||
|
(ionInput)="updateNumberOfCourts($event)">
|
||||||
|
</ion-input>
|
||||||
|
</ion-item>
|
||||||
|
</ion-list>
|
||||||
|
|
||||||
|
}
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
</ion-grid>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@@ -1,13 +1,79 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
|
import {
|
||||||
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
IonHeader,
|
||||||
|
IonToolbar,
|
||||||
|
IonTitle,
|
||||||
|
IonContent,
|
||||||
|
IonList,
|
||||||
|
IonItem,
|
||||||
|
IonToggle,
|
||||||
|
IonInput,
|
||||||
|
IonGrid,
|
||||||
|
IonCol,
|
||||||
|
IonRow
|
||||||
|
} from '@ionic/angular/standalone';
|
||||||
|
import { SettingsService } from '../services/settings-service';
|
||||||
|
import { CourtUmpireService } from '../services/court.umpire.service';
|
||||||
|
import { CourtServiceJudgeService } from '../services/court.service.judge.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tab3',
|
selector: 'app-tab3',
|
||||||
templateUrl: 'tab3.page.html',
|
templateUrl: 'tab3.page.html',
|
||||||
styleUrls: ['tab3.page.scss'],
|
styleUrls: ['tab3.page.scss'],
|
||||||
imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent],
|
imports: [
|
||||||
|
IonRow,
|
||||||
|
IonCol,
|
||||||
|
IonGrid,
|
||||||
|
IonInput,
|
||||||
|
IonToggle,
|
||||||
|
IonItem,
|
||||||
|
IonList,
|
||||||
|
IonHeader,
|
||||||
|
IonToolbar,
|
||||||
|
IonTitle,
|
||||||
|
IonContent
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class Tab3Page {
|
export class Tab3Page {
|
||||||
constructor() {}
|
readonly settingsService = inject(SettingsService);
|
||||||
|
readonly courtUmpireService = inject(CourtUmpireService);
|
||||||
|
readonly courtServiceJudgeService = inject(CourtServiceJudgeService);
|
||||||
|
|
||||||
|
readonly settings = this.settingsService.settings;
|
||||||
|
|
||||||
|
async updateNumberOfCourts(event: CustomEvent): Promise<void> {
|
||||||
|
this.courtUmpireService
|
||||||
|
.umpires()
|
||||||
|
.filter((cu) => {
|
||||||
|
return cu.courtNo > Number(event.detail.value);
|
||||||
|
})
|
||||||
|
.map((cu) => {
|
||||||
|
this.courtUmpireService.delete(cu.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.courtServiceJudgeService
|
||||||
|
.umpires()
|
||||||
|
.filter((cu) => {
|
||||||
|
return cu.courtNo > Number(event.detail.value);
|
||||||
|
})
|
||||||
|
.map((cu) => {
|
||||||
|
this.courtServiceJudgeService.delete(cu.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.settingsService.update({
|
||||||
|
numberOfCourts: Number(event.detail.value)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateWithServiceJudge(event: CustomEvent): Promise<void> {
|
||||||
|
await this.settingsService.update({
|
||||||
|
withServiceJudge: event.detail.checked
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateShowAlert(event: CustomEvent): Promise<void> {
|
||||||
|
await this.settingsService.update({
|
||||||
|
showAlert: event.detail.checked
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,17 @@
|
|||||||
<ion-tabs>
|
<ion-tabs>
|
||||||
<ion-tab-bar slot="bottom">
|
<ion-tab-bar slot="bottom">
|
||||||
<ion-tab-button tab="pilot" href="/tabs/pilot">
|
<ion-tab-button tab="pilot" href="/tabs/pilot">
|
||||||
<ion-icon aria-hidden="true" name="triangle"></ion-icon>
|
<ion-icon aria-hidden="true" name="grid-outline"></ion-icon>
|
||||||
<ion-label>Pályák</ion-label>
|
<ion-label>Pályák</ion-label>
|
||||||
</ion-tab-button>
|
</ion-tab-button>
|
||||||
|
|
||||||
<ion-tab-button tab="umpires" href="/tabs/umpires">
|
<ion-tab-button tab="umpires" href="/tabs/umpires">
|
||||||
<ion-icon aria-hidden="true" name="ellipse"></ion-icon>
|
<ion-icon aria-hidden="true" name="people-outline"></ion-icon>
|
||||||
<ion-label>Játékvezetők</ion-label>
|
<ion-label>Játékvezetők</ion-label>
|
||||||
</ion-tab-button>
|
</ion-tab-button>
|
||||||
|
|
||||||
<ion-tab-button tab="stats" href="/tabs/stats">
|
|
||||||
<ion-icon aria-hidden="true" name="square"></ion-icon>
|
|
||||||
<ion-label>Tab 3</ion-label>
|
|
||||||
</ion-tab-button>
|
|
||||||
|
|
||||||
<ion-tab-button tab="settings" href="/tabs/settings">
|
<ion-tab-button tab="settings" href="/tabs/settings">
|
||||||
<ion-icon aria-hidden="true" name="square"></ion-icon>
|
<ion-icon aria-hidden="true" name="settings-outline"></ion-icon>
|
||||||
<ion-label>Beállítások</ion-label>
|
<ion-label>Beállítások</ion-label>
|
||||||
</ion-tab-button>
|
</ion-tab-button>
|
||||||
</ion-tab-bar>
|
</ion-tab-bar>
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
import { Component, EnvironmentInjector, inject } from '@angular/core';
|
import { Component, EnvironmentInjector, inject } from '@angular/core';
|
||||||
import { IonTabs, IonTabBar, IonTabButton, IonIcon, IonLabel } from '@ionic/angular/standalone';
|
import {
|
||||||
|
IonTabs,
|
||||||
|
IonTabBar,
|
||||||
|
IonTabButton,
|
||||||
|
IonIcon,
|
||||||
|
IonLabel
|
||||||
|
} from '@ionic/angular/standalone';
|
||||||
import { addIcons } from 'ionicons';
|
import { addIcons } from 'ionicons';
|
||||||
import { triangle, ellipse, square } from 'ionicons/icons';
|
import { gridOutline, peopleOutline, settingsOutline } from 'ionicons/icons';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tabs',
|
selector: 'app-tabs',
|
||||||
templateUrl: 'tabs.page.html',
|
templateUrl: 'tabs.page.html',
|
||||||
styleUrls: ['tabs.page.scss'],
|
styleUrls: ['tabs.page.scss'],
|
||||||
imports: [IonTabs, IonTabBar, IonTabButton, IonIcon, IonLabel],
|
imports: [IonTabs, IonTabBar, IonTabButton, IonIcon, IonLabel]
|
||||||
})
|
})
|
||||||
export class TabsPage {
|
export class TabsPage {
|
||||||
public environmentInjector = inject(EnvironmentInjector);
|
public environmentInjector = inject(EnvironmentInjector);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
addIcons({ triangle, ellipse, square });
|
addIcons({ gridOutline, peopleOutline, settingsOutline });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const routes: Routes = [
|
|||||||
loadComponent: () => import('../tab2/tab2.page').then((m) => m.Tab2Page)
|
loadComponent: () => import('../tab2/tab2.page').then((m) => m.Tab2Page)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'stats',
|
path: 'settings',
|
||||||
loadComponent: () => import('../tab3/tab3.page').then((m) => m.Tab3Page)
|
loadComponent: () => import('../tab3/tab3.page').then((m) => m.Tab3Page)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user