diff --git a/src/app/components/shared/room-join/room-join.component.html b/src/app/components/shared/room-join/room-join.component.html index 0df7178cf7021093ffb88c02e63cb76c488c1e94..0d3297e0ef613174bb69fefc7506fe35a76b5eea 100644 --- a/src/app/components/shared/room-join/room-join.component.html +++ b/src/app/components/shared/room-join/room-join.component.html @@ -8,7 +8,7 @@ placeholder="Session-Id" [formControl]="roomFormControl" [errorStateMatcher]="matcher"/> <mat-hint align="end">{{ roomId.value.length - (roomId.value.split(' ').length -1) }} / 8</mat-hint> <mat-error *ngIf="roomFormControl.hasError('required')">{{ 'home-page.please-enter' | translate}}</mat-error> - <mat-error *ngIf="roomFormControl.hasError('minlength')">{{ 'home-page.exactly-8' | translate}}</mat-error> + <mat-error *ngIf="roomFormControl.hasError('pattern')">{{ 'home-page.only-numbers' | translate}}</mat-error> </mat-form-field> <button mat-fab color="accent" type="submit"> <mat-icon>input</mat-icon> diff --git a/src/app/components/shared/room-join/room-join.component.ts b/src/app/components/shared/room-join/room-join.component.ts index 91fe23420270c29431902ba4e1bbd8f5401988a1..ce606ce858d0fe604207486b9b0c279b4b9613d4 100644 --- a/src/app/components/shared/room-join/room-join.component.ts +++ b/src/app/components/shared/room-join/room-join.component.ts @@ -30,7 +30,7 @@ export class RoomJoinComponent implements OnInit { demoId = '95680586'; user: User; - roomFormControl = new FormControl('', [Validators.required, Validators.minLength(9), Validators.maxLength(9)]); + roomFormControl = new FormControl('', [Validators.required, Validators.pattern('[0-9 ]*')]); matcher = new RegisterErrorStateMatcher(); @@ -46,7 +46,16 @@ export class RoomJoinComponent implements OnInit { } getRoom(id: string): void { - this.roomService.getRoomByShortId(id.replace(/\s/g, "")) + if (id.length -1 < 8) { + this.translateService.get('home-page.exactly-8').subscribe(message => { + this.notificationService.show(message); + }); + } else if (this.roomFormControl.hasError('pattern')) { + this.translateService.get('home-page.only-numbers').subscribe(message => { + this.notificationService.show(message); + }); + } else { + this.roomService.getRoomByShortId(id.replace(/\s/g, "")) .subscribe(room => { this.room = room; if (!room) { @@ -65,6 +74,8 @@ export class RoomJoinComponent implements OnInit { } } }); + } + } joinRoom(id: string): void { diff --git a/src/assets/i18n/home/de.json b/src/assets/i18n/home/de.json index 422bf9395322cf759d6d29b85f7d14ff5f88b22e..567c75242fdecc63f25d237471328bf11dcc8559 100644 --- a/src/assets/i18n/home/de.json +++ b/src/assets/i18n/home/de.json @@ -25,7 +25,8 @@ "create-session": "Session erstellen", "no-empty-name": "Bitte geben Sie einen Namen ein.", "created-1": "Session '", - "created-2": "' erfolgreich erstellt." + "created-2": "' erfolgreich erstellt.", + "only-numbers": "Eine Session-Id besteht aus Nummern." }, "login": { "email": "E-Mail", diff --git a/src/assets/i18n/home/en.json b/src/assets/i18n/home/en.json index ad19e53b9a8110869772f856e2746b606aba8a68..b3853c79bf66eda657ec172e8049dce5c3de0a24 100644 --- a/src/assets/i18n/home/en.json +++ b/src/assets/i18n/home/en.json @@ -25,7 +25,8 @@ "create-session": "Create session", "no-empty-name": "Please enter a name.", "created-1": "Session '", - "created-2": "' successfully created." + "created-2": "' successfully created.", + "only-numbers": "A session-id only contains numbers." }, "login": { "email": "E-Mail",