Skip to content
Snippets Groups Projects
Commit fbb5681f authored by Max Henze's avatar Max Henze
Browse files

Actions

parent 518bea98
No related branches found
No related tags found
No related merge requests found
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object'
export default class LoginController extends Controller {
@tracked email = '';
@tracked password = '';
@tracked loginInvalid = false;
classLabel = 'is-invalid-label';
@action
login(event) {
event.preventDefault();
if(this.email === 'test@example.com' && this.password === 'password') {
this.loginInvalid = false;
} else {
this.loginInvalid = true;
}
}
@action
typing() {
this.loginInvalid = false;
}
}
<div class="grid-x grid-padding-x">
<form class="cell large-2 large-offset-5">
<form class="cell large-2 large-offset-5" {{on "submit" this.login}}>
<div class="callout">
<h1>Login</h1>
<label>E-Mail
<Input type="email" @value={{this.email}} />
<span class="form-error is-visible">No user exists with this e-mail address {{this.email}} or the password is not correct.</span>
<label class={{if loginInvalid this.classLabel}}>E-Mail
<Input type="email" @value={{this.email}} class={{if loginInvalid this.classInput}} {{on "keypress" this.typing}}/>
{{#if loginInvalid}}
<span class="form-error is-visible">No user exists with the e-mail address {{this.email}} or the password is incorrect.</span>
{{/if}}
</label>
<label>Password
<Input type="password" @value={{this.password}} />
<span class="form-error is-visible">No user exists with this e-mail address {{this.email}} or the password is not correct.</span>
<label class={{if loginInvalid this.classLabel}}>Password
<Input type="password" @value={{this.password}} class={{if loginInvalid this.classInput}} {{on "keypress" this.typing}} />
{{#if loginInvalid}}
<span class="form-error is-visible">No user exists with the e-mail address {{this.email}} or the password is incorrect.</span>
{{/if}}
</label>
<div class="text-right">
<button class="button">Login</button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment