Commit 7c37a2d1 authored by Dennis Willers's avatar Dennis Willers 🏀

Implement functionality for Input-field at gamesearch

parent 894e88a3
...@@ -17,6 +17,7 @@ import {MatCardModule} from '@angular/material/card'; ...@@ -17,6 +17,7 @@ import {MatCardModule} from '@angular/material/card';
import { OverviewComponent } from './overview/overview.component'; import { OverviewComponent } from './overview/overview.component';
import { ErrorComponent } from './error/error.component'; import { ErrorComponent } from './error/error.component';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import { FormsModule } from '@angular/forms';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -39,6 +40,7 @@ import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; ...@@ -39,6 +40,7 @@ import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
MatInputModule, MatInputModule,
MatCardModule, MatCardModule,
MatProgressSpinnerModule, MatProgressSpinnerModule,
FormsModule
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]
......
...@@ -8,18 +8,18 @@ ...@@ -8,18 +8,18 @@
<br> <br>
<mat-card class="transparent"> <mat-card class="transparent">
<mat-card-title>Spielsuche</mat-card-title> <mat-card-title>Spielsuche</mat-card-title>
<mat-card-subtitle>Finde ein Spiel über den Spielnamen oder erstelle ein neues</mat-card-subtitle> <mat-card-subtitle>Finde ein Spiel über den Spielnamen oder erstelle ein neues Spiel</mat-card-subtitle>
<mat-card-content> <mat-card-content>
<form> <form>
<mat-form-field> <mat-form-field>
<mat-label>Spielname</mat-label> <mat-label>Spielname</mat-label>
<input type="text" pattern="[0-9A-Za-z]*" matInput> <input #spielname type="text" matInput (keyup)="checkSpielname(spielname.value)" (keypress)="keyPressAlphaNumeric($event)">
</mat-form-field> </mat-form-field>
</form> </form>
</mat-card-content> </mat-card-content>
<mat-card-actions> <mat-card-actions>
<button mat-raised-button color="primary" (click)="getSpielSessions()">Spiel erstellen</button> <button [disabled]="buttonsDisabled" mat-raised-button color="primary" (click)="getSpielSessions()">Spiel erstellen</button>
<button mat-raised-button color="primary" (click)="joinGame($event)">Spiel beitreten</button> <button [disabled]="buttonsDisabled" mat-raised-button color="primary" (click)="joinGame()">Spiel beitreten</button>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>
</div> </div>
...@@ -9,6 +9,7 @@ import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; ...@@ -9,6 +9,7 @@ import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
}) })
export class SelectGameComponent implements OnInit { export class SelectGameComponent implements OnInit {
buttonsDisabled = true;
constructor(private router: Router, constructor(private router: Router,
private server: TabuMiddlewareService) { } private server: TabuMiddlewareService) { }
...@@ -21,7 +22,21 @@ export class SelectGameComponent implements OnInit { ...@@ -21,7 +22,21 @@ export class SelectGameComponent implements OnInit {
console.log('Response:', response); console.log('Response:', response);
} }
joinGame(event: any): void { joinGame(): void {
this.router.navigate(['/overview']); this.router.navigate(['/overview']);
} }
keyPressAlphaNumeric(event: KeyboardEvent): boolean {
if (/[a-zA-Z0-9]/.test(event.key)) {
return true;
} else {
event.preventDefault();
return false;
}
}
checkSpielname(spielname: string): void {
console.log(spielname)
this.buttonsDisabled = spielname.length === 0;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment