mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 13:30:47 +08:00
Retain relevant data when switching between login/signup modals
This commit is contained in:
parent
e5532d9618
commit
20dfc6c341
|
@ -9,8 +9,8 @@ export default class LoginModal extends FormModal {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.email = m.prop();
|
||||
this.password = m.prop();
|
||||
this.email = m.prop(this.props.email || '');
|
||||
this.password = m.prop(this.props.password || '');
|
||||
}
|
||||
|
||||
view() {
|
||||
|
@ -19,10 +19,10 @@ export default class LoginModal extends FormModal {
|
|||
title: 'Log In',
|
||||
body: [
|
||||
m('div.form-group', [
|
||||
m('input.form-control[name=email][placeholder=Username or Email]', {onchange: m.withAttr('value', this.email), disabled: this.loading()})
|
||||
m('input.form-control[name=email][placeholder=Username or Email]', {value: this.email(), onchange: m.withAttr('value', this.email), disabled: this.loading()})
|
||||
]),
|
||||
m('div.form-group', [
|
||||
m('input.form-control[type=password][name=password][placeholder=Password]', {onchange: m.withAttr('value', this.password), disabled: this.loading()})
|
||||
m('input.form-control[type=password][name=password][placeholder=Password]', {value: this.password(), onchange: m.withAttr('value', this.password), disabled: this.loading()})
|
||||
]),
|
||||
m('div.form-group', [
|
||||
m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Log In')
|
||||
|
@ -32,7 +32,12 @@ export default class LoginModal extends FormModal {
|
|||
m('p.forgot-password-link', m('a[href=javascript:;]', {onclick: () => app.modal.show(new ForgotPasswordModal({email: this.email()}))}, 'Forgot password?')),
|
||||
m('p.sign-up-link', [
|
||||
'Don\'t have an account? ',
|
||||
m('a[href=javascript:;]', {onclick: () => app.modal.show(new SignupModal())}, 'Sign Up')
|
||||
m('a[href=javascript:;]', {onclick: () => {
|
||||
var props = {password: this.password()};
|
||||
var email = this.email();
|
||||
props[email.indexOf('@') !== -1 ? 'email' : 'username'] = email;
|
||||
app.modal.show(new SignupModal(props));
|
||||
}}, 'Sign Up')
|
||||
])
|
||||
]
|
||||
});
|
||||
|
|
|
@ -9,9 +9,9 @@ export default class SignupModal extends FormModal {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.username = m.prop();
|
||||
this.email = m.prop();
|
||||
this.password = m.prop();
|
||||
this.username = m.prop(this.props.username || '');
|
||||
this.email = m.prop(this.props.email || '');
|
||||
this.password = m.prop(this.props.password || '');
|
||||
this.welcomeUser = m.prop();
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,13 @@ export default class SignupModal extends FormModal {
|
|||
title: 'Sign Up',
|
||||
body: [
|
||||
m('div.form-group', [
|
||||
m('input.form-control[name=username][placeholder=Username]', {onchange: m.withAttr('value', this.username), disabled: this.loading()})
|
||||
m('input.form-control[name=username][placeholder=Username]', {value: this.username(), onchange: m.withAttr('value', this.username), disabled: this.loading()})
|
||||
]),
|
||||
m('div.form-group', [
|
||||
m('input.form-control[name=email][placeholder=Email]', {onchange: m.withAttr('value', this.email), disabled: this.loading()})
|
||||
m('input.form-control[name=email][placeholder=Email]', {value: this.email(), onchange: m.withAttr('value', this.email), disabled: this.loading()})
|
||||
]),
|
||||
m('div.form-group', [
|
||||
m('input.form-control[type=password][name=password][placeholder=Password]', {onchange: m.withAttr('value', this.password), disabled: this.loading()})
|
||||
m('input.form-control[type=password][name=password][placeholder=Password]', {value: this.password(), onchange: m.withAttr('value', this.password), disabled: this.loading()})
|
||||
]),
|
||||
m('div.form-group', [
|
||||
m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Sign Up')
|
||||
|
@ -39,7 +39,7 @@ export default class SignupModal extends FormModal {
|
|||
footer: [
|
||||
m('p.log-in-link', [
|
||||
'Already have an account? ',
|
||||
m('a[href=javascript:;]', {onclick: () => app.modal.show(new LoginModal())}, 'Log In')
|
||||
m('a[href=javascript:;]', {onclick: () => app.modal.show(new LoginModal({email: this.email() || this.username(), password: this.password()}))}, 'Log In')
|
||||
])
|
||||
]
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user