From 6fe397e97ea99527f140ef6d9939345e99dcdf96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Thu, 15 Mar 2018 13:09:31 +0100 Subject: [PATCH] Adjust room joining so that you can't join a room with an id with less than 8 characters --- src/app/join-room/join-room.component.html | 3 ++- src/app/join-room/join-room.component.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/join-room/join-room.component.html b/src/app/join-room/join-room.component.html index 5a70e3b89..a90377652 100644 --- a/src/app/join-room/join-room.component.html +++ b/src/app/join-room/join-room.component.html @@ -5,8 +5,9 @@ [errorStateMatcher]="matcher" maxlength="8"/> <mat-hint align="end">{{roomId.value.length}} / 8</mat-hint> <mat-error *ngIf="roomFormControl.hasError('required')">Please enter a room-id.</mat-error> + <mat-error *ngIf="roomFormControl.hasError('minlength')">A room-id has exactly 8 digits.</mat-error> </mat-form-field> - <button mat-fab color="primary" (click)="joinRoom(roomId.value)"> + <button mat-fab color="primary" type="submit"> <mat-icon>send</mat-icon> </button> </div> diff --git a/src/app/join-room/join-room.component.ts b/src/app/join-room/join-room.component.ts index edb949a76..660e686ee 100644 --- a/src/app/join-room/join-room.component.ts +++ b/src/app/join-room/join-room.component.ts @@ -24,7 +24,7 @@ export class JoinRoomComponent implements OnInit { room: Room; demoId = '17703069'; - roomFormControl = new FormControl('', [Validators.required]); + roomFormControl = new FormControl('', [Validators.required, Validators.minLength(8)]); matcher = new RegisterErrorStateMatcher(); @@ -50,7 +50,7 @@ export class JoinRoomComponent implements OnInit { } joinRoom(id: string): void { - if (!this.roomFormControl.hasError('required')) { + if (!this.roomFormControl.hasError('required') && !this.roomFormControl.hasError('minlength')) { this.getRoom(id); } } -- GitLab