[IMP] auth_signup: improve web look-and-feel
bzr revid: rco@openerp.com-20120926130241-wlzeyzrsr1xwjdcm
This commit is contained in:
parent
a50dfa668d
commit
0605295602
|
@ -1,4 +1,10 @@
|
|||
@charset "utf-8";
|
||||
.openerp .oe_login input[type="checkbox"] {
|
||||
width: 21px !important;
|
||||
.openerp .oe_login .oe_signup_show {
|
||||
display: none;
|
||||
}
|
||||
.openerp .oe_login_signup .oe_signup_show {
|
||||
display: block !important;
|
||||
}
|
||||
.openerp .oe_login_signup .oe_signup_hide {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
@charset "utf-8"
|
||||
|
||||
.openerp
|
||||
// Login form
|
||||
// Regular login form
|
||||
.oe_login
|
||||
input[type="checkbox"]
|
||||
width: 21px !important
|
||||
.oe_signup_show
|
||||
display: none
|
||||
// Signup form
|
||||
.oe_login_signup
|
||||
.oe_signup_show
|
||||
display: block !important
|
||||
.oe_signup_hide
|
||||
display: none
|
||||
|
|
|
@ -7,9 +7,14 @@ openerp.auth_signup = function(instance) {
|
|||
var self = this;
|
||||
var d = this._super();
|
||||
|
||||
// hide the signup fields in the case of a regular login
|
||||
self.on_change_mode()
|
||||
self.$("form input[name=signup]").click(self.on_change_mode);
|
||||
// to switch between the signup and regular login form
|
||||
this.$('a.oe_signup_signup').click(function() {
|
||||
self.$el.addClass("oe_login_signup");
|
||||
});
|
||||
this.$('a.oe_signup_back').click(function() {
|
||||
self.$el.removeClass("oe_login_signup");
|
||||
delete self.params.token;
|
||||
});
|
||||
|
||||
// if there is an error message in params, show it then forget it
|
||||
if (self.params.error_message) {
|
||||
|
@ -26,15 +31,20 @@ openerp.auth_signup = function(instance) {
|
|||
return d;
|
||||
},
|
||||
on_token_loaded: function(result) {
|
||||
// set the name and login of user
|
||||
// switch to signup mode
|
||||
this.$el.addClass("oe_login_signup");
|
||||
// select the right the database
|
||||
this.selected_db = result.db;
|
||||
this.on_db_loaded({db_list: [result.db]});
|
||||
this.$("form input[name=signup]").val(result.login ? [] : ["check_signup"]);
|
||||
this.$("form input[name=name]").val(result.name);
|
||||
this.$("form input[name=login]").val(result.login || result.email);
|
||||
// set the name and login of user
|
||||
this.$("form input[name=name]").val(result.name).attr("readonly", "readonly");
|
||||
if (result.login) {
|
||||
this.$("form input[name=login]").val(result.login).attr("readonly", "readonly");
|
||||
} else {
|
||||
this.$("form input[name=login]").val(result.email);
|
||||
}
|
||||
this.$("form input[name=password]").val("");
|
||||
this.$("form input[name=confirm_password]").val("");
|
||||
this.on_change_mode();
|
||||
},
|
||||
on_token_failed: function(result, ev) {
|
||||
if (ev) {
|
||||
|
@ -44,12 +54,6 @@ openerp.auth_signup = function(instance) {
|
|||
delete this.params.db;
|
||||
delete this.params.token;
|
||||
},
|
||||
on_change_mode: function() {
|
||||
// 'mode' has changed: regular login, sign up, reset password
|
||||
var is_signup = this.$("input[name=signup]:checked").val();
|
||||
this.$(".oe_signup").toggleClass('oe_form_invisible', false && !is_signup);
|
||||
return true;
|
||||
},
|
||||
on_submit: function(ev) {
|
||||
if (ev) {
|
||||
ev.preventDefault();
|
||||
|
|
|
@ -3,24 +3,25 @@
|
|||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-extend="Login">
|
||||
<t t-jquery="form ul:first li:first" t-operation="before">
|
||||
<li class="oe_signup">
|
||||
<input name="signup" type="checkbox" value="check_signup"/>
|
||||
Create a new account
|
||||
</li>
|
||||
<li class="oe_signup">Name</li>
|
||||
<li class="oe_signup">
|
||||
<input name="name" type="text"/>
|
||||
</li>
|
||||
<t t-jquery="form ul:first li:contains('Username')" t-operation="before">
|
||||
<li class="oe_signup_show">Name</li>
|
||||
<li class="oe_signup_show"><input name="name" type="text"/></li>
|
||||
</t>
|
||||
<t t-jquery="form ul:first li:contains('Username')" t-operation="replace">
|
||||
<li>Username <span class="oe_signup">(Email)</span></li>
|
||||
<li class="oe_signup_hide">Username</li>
|
||||
<li class="oe_signup_show">Username (Email)</li>
|
||||
</t>
|
||||
<t t-jquery="form ul:first li:last" t-operation="before">
|
||||
<li class="oe_signup">Confirm Password</li>
|
||||
<li class="oe_signup">
|
||||
<input name="confirm_password" type="password"/>
|
||||
</li>
|
||||
<t t-jquery="form ul:first li:has(input[name=password])" t-operation="after">
|
||||
<li class="oe_signup_show">Confirm Password</li>
|
||||
<li class="oe_signup_show"><input name="confirm_password" type="password"/></li>
|
||||
</t>
|
||||
<t t-jquery="form ul:first li:has(button[name=submit])" t-operation="replace">
|
||||
<li class="oe_signup_hide"><button name="submit">Log in</button></li>
|
||||
<li class="oe_signup_show"><button name="submit">Sign in</button></li>
|
||||
</t>
|
||||
<t t-jquery="form ul:first li:last" t-operation="after">
|
||||
<li><a class="oe_signup_hide oe_signup_signup" href="#">Sign Up</a></li>
|
||||
<li><a class="oe_signup_show oe_signup_back" href="#">Back to Login</a></li>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
|
|
Loading…
Reference in New Issue