-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Login form - route configuration, fields validation, template
- Loading branch information
daniel.faderski
committed
Feb 27, 2017
1 parent
4b5e50e
commit 9a9a766
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Ember from 'ember'; | ||
import {TextInput, MinLength} from '../utils/text-input' | ||
|
||
export default Ember.Component.extend({ | ||
username: TextInput.create({ | ||
value: '', | ||
validators: [ | ||
new MinLength(1) | ||
] | ||
}), | ||
|
||
password: TextInput.create({ | ||
value: '', | ||
validators: [ | ||
new MinLength(1) | ||
] | ||
}), | ||
|
||
init() { | ||
this._super(...arguments); | ||
let username = this.get('username'); | ||
let password = this.get('password'); | ||
this.nonFieldErrors = null; | ||
}, | ||
|
||
showUsernameErrors: Ember.computed('username.{pristine,errors}', function () { | ||
return !this.get('username.pristine') && this.get('username.errors'); | ||
}), | ||
|
||
showPasswordErrors: Ember.computed('password.{pristine,errors}', function () { | ||
return !this.get('password.pristine') && this.get('password.errors'); | ||
}), | ||
|
||
formInvalid: Ember.computed('showUsernameErrors','showPasswordErrors', function () { | ||
return this.get('showUsernameErrors') || this.get('showPasswordErrors'); | ||
}) | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<form> | ||
<div> | ||
<label for="username">Username</label> | ||
{{ input type="text" value=username.value id="username" class="form-control" | ||
name="username" aria-describedby="usernameHelpBlock" }} | ||
|
||
{{#if showUsernameErrors}} | ||
<div class="alert alert-danger"> | ||
This field is required | ||
</div> | ||
{{/if}} | ||
</div> | ||
|
||
<div> | ||
<label for="password">Password</label> | ||
{{ input type="password" value=password.value id="password" class="form-control" | ||
name="password" aria-describedby="passwordHelpBlock" }} | ||
{{# if showPasswordErrors }} | ||
<div class="alert alert-danger"> | ||
This field is required | ||
</div> | ||
{{/if}} | ||
</div> | ||
|
||
<button type="submit" class="btn btn-primary" disabled={{formInvalid}}>Login</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{login-form}} |