Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
frag.jetzt SWTP 2022
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Marc Tröll
frag.jetzt SWTP 2022
Commits
b677f87a
Commit
b677f87a
authored
7 years ago
by
Thomas Lenz
Browse files
Options
Downloads
Patches
Plain Diff
Implement check for valid inputs (no empty input-fields allowed)
parent
f973b2b5
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/room-creation/room-creation.component.html
+10
-7
10 additions, 7 deletions
src/app/room-creation/room-creation.component.html
src/app/room-creation/room-creation.component.ts
+5
-0
5 additions, 0 deletions
src/app/room-creation/room-creation.component.ts
with
15 additions
and
7 deletions
src/app/room-creation/room-creation.component.html
+
10
−
7
View file @
b677f87a
<form
(ngSubmit)=
"addRoom(longRoomName.value, shortRoomName.value)"
>
<div
fxLayout=
"column"
fxLayoutAlign=
"center"
fxLayoutGap=
"10px"
>
<mat-form-field>
<input
matInput
#longRoomName
class=
"input-block"
type=
"text"
placeholder=
"Name"
maxlength=
"50"
<input
(keypress)=
"resetEmptyInputs()"
matInput
#longRoomName
class=
"input-block"
type=
"text"
placeholder=
"Name"
maxlength=
"50"
[(ngModel)]=
"longName"
/>
<mat-hint
align=
"start"
><strong>
Max. letters / signs:
</strong></mat-hint>
<mat-hint
align=
"end"
>
{{longRoomName.value.length}} / 50
</mat-hint>
<mat-hint
align=
"start"
*ngIf=
"!emptyInputs"
><strong>
Max. letters / signs:
</strong></mat-hint>
<mat-hint
align=
"end"
*ngIf=
"!emptyInputs"
>
{{longRoomName.value.length}} / 50
</mat-hint>
<mat-hint
align=
"start"
*ngIf=
"emptyInputs"
><strong>
Input is required
</strong></mat-hint>
<button
mat-button
*ngIf=
"longName"
matSuffix
mat-icon-button
aria-label=
"Clear"
(click)=
"longName=''"
>
<mat-icon>
close
</mat-icon>
</button>
</mat-form-field>
<mat-form-field>
<input
matInput
#shortRoomName
class=
"input-block"
type=
"text"
placeholder=
"Short name"
maxlength=
"8"
<input
(keypress)=
"resetEmptyInputs()"
matInput
#shortRoomName
class=
"input-block"
type=
"text"
placeholder=
"Short name"
maxlength=
"8"
[(ngModel)]=
"shortName"
/>
<mat-hint
align=
"start"
><strong>
Max. letters / signs:
</strong></mat-hint>
<mat-hint
align=
"end"
>
{{shortRoomName.value.length}} / 8
</mat-hint>
<mat-hint
align=
"start"
*ngIf=
"!emptyInputs"
><strong>
Max. letters / signs:
</strong></mat-hint>
<mat-hint
align=
"end"
*ngIf=
"!emptyInputs"
>
{{shortRoomName.value.length}} / 8
</mat-hint>
<mat-hint
align=
"start"
*ngIf=
"emptyInputs"
><strong>
Input is required
</strong></mat-hint>
<button
mat-button
*ngIf=
"shortName"
matSuffix
mat-icon-button
aria-label=
"Clear"
(click)=
"shortName=''"
>
<mat-icon>
close
</mat-icon>
</button>
...
...
This diff is collapsed.
Click to expand it.
src/app/room-creation/room-creation.component.ts
+
5
−
0
View file @
b677f87a
...
...
@@ -13,6 +13,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
export
class
RoomCreationComponent
implements
OnInit
{
longName
:
string
;
shortName
:
string
;
emptyInputs
=
false
;
constructor
(
private
roomService
:
RoomService
,
private
router
:
Router
,
...
...
@@ -27,11 +28,15 @@ export class RoomCreationComponent implements OnInit {
ngOnInit
()
{
}
resetEmptyInputs
():
void
{
this
.
emptyInputs
=
false
;
}
addRoom
(
longRoomName
:
string
,
shortRoomName
:
string
)
{
longRoomName
=
longRoomName
.
trim
();
shortRoomName
=
shortRoomName
.
trim
();
if
(
!
longRoomName
||
!
shortRoomName
)
{
this
.
emptyInputs
=
true
;
return
;
}
this
.
roomService
.
addRoom
({
name
:
longRoomName
,
abbreviation
:
shortRoomName
}
as
Room
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment