[FIX] Improved required validation.
bzr revid: noz@tinyerp.com-20110707090444-iaf58v4umq53lb88
This commit is contained in:
@@ -124,7 +124,10 @@ class Session(openerpweb.Controller):
|
||||
@openerpweb.jsonrequest
|
||||
def db_operation(self, req, flag, **kw):
|
||||
|
||||
if flag == 'drop':
|
||||
if flag == 'create':
|
||||
pass
|
||||
|
||||
elif flag == 'drop':
|
||||
db = kw.get('db')
|
||||
password = kw.get('password')
|
||||
|
||||
|
||||
@@ -190,6 +190,10 @@ ul.db_options li {
|
||||
-moz-border-radius: 10px;
|
||||
}
|
||||
|
||||
table.db_option_table input.required {
|
||||
background-color: #D2D2FF;
|
||||
}
|
||||
|
||||
.db_option_table input[type="text"], input[type="password"], select {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
@@ -935,6 +935,49 @@ openerp.base.Database = openerp.base.Controller.extend({
|
||||
self.$option_id.html(QWeb.render("CreateDB", self));
|
||||
|
||||
$("form[name=create_db_form]").validate();
|
||||
|
||||
$("input[name=create_confirm_pwd]").rules("add", {
|
||||
equalTo: 'input[name=create_admin_pwd]',
|
||||
messages: {
|
||||
required: "Password did not match !"
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name=super_admin_pwd]").focus();
|
||||
|
||||
self.$option_id.find('form[name=create_db_form]').submit(function(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
var super_admin_pwd = self.$option_id.find("input[name=super_admin_pwd]").val();
|
||||
var db = self.$option_id.find("input[name=db_name]").val();
|
||||
var demo_data = self.$option_id.find("input[name=demo_data]:checked");
|
||||
var db_lang = self.$option_id.find("select[name=db_lang]").val();
|
||||
var admin_pwd = self.$option_id.find("input[name=create_admin_pwd]").val();
|
||||
var confirm_pwd = self.$option_id.find("input[name=create_confirm_pwd]").val();
|
||||
|
||||
if (demo_data.length)
|
||||
demo_data = 'True';
|
||||
else
|
||||
demo_data = 'False';
|
||||
|
||||
self.rpc("/base/session/db_operation", {
|
||||
'flag': 'create',
|
||||
'super_admin_pwd': super_admin_pwd,
|
||||
'db': db,
|
||||
'demo_data': demo_data,
|
||||
'db_lang': db_lang,
|
||||
'admin_pwd': admin_pwd,
|
||||
'confirm_pwd': confirm_pwd
|
||||
},
|
||||
function(result) {
|
||||
if (result && !result.error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
self.$element.find('#db-drop').click(function() {
|
||||
@@ -1015,21 +1058,18 @@ openerp.base.Database = openerp.base.Controller.extend({
|
||||
$("form[name=change_pwd_form]").validate();
|
||||
|
||||
$("input[name=old_pwd]").rules("add", {
|
||||
required: true,
|
||||
minlength: 1,
|
||||
messages: {
|
||||
required: "Please enter password !"
|
||||
}
|
||||
});
|
||||
$("input[name=new_pwd]").rules("add", {
|
||||
required: true,
|
||||
minlength: 1,
|
||||
messages: {
|
||||
required: "Please enter password !"
|
||||
}
|
||||
});
|
||||
$("input[name=confirm_pwd]").rules("add", {
|
||||
required: true,
|
||||
equalTo: 'input[name=new_pwd]',
|
||||
messages: {
|
||||
required: "Password did not match !"
|
||||
|
||||
@@ -80,15 +80,15 @@
|
||||
<table align="center" class="db_option_table">
|
||||
<tr>
|
||||
<td><label for="super_admin_pwd">Super admin password:</label></td>
|
||||
<td><input type="text" name="super_admin_pwd" autofocus="true"/></td>
|
||||
<td><input type="password" name="super_admin_pwd" class="required"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="db_name">New database name:</label></td>
|
||||
<td><input type="text" name="db_name"/></td>
|
||||
<td><input type="text" name="db_name" class="required"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="demo_data">Load Demonstration data:</label></td>
|
||||
<td><input type="checkbox" name="demo_data"/></td>
|
||||
<td><input type="checkbox" name="demo_data" checked='checked'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="db_lang">Default language:</label></td>
|
||||
@@ -103,12 +103,12 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="admin_pwd">Super admin password:</label></td>
|
||||
<td><input type="text" name="super_admin_pwd"/></td>
|
||||
<td><label for="create_admin_pwd">Super admin password:</label></td>
|
||||
<td><input type="password" name="create_admin_pwd" class="required"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="confirm_pwd">Confirm password:</label></td>
|
||||
<td><input type="text" name="confirm_pwd"/></td>
|
||||
<td><label for="create_confirm_pwd">Confirm password:</label></td>
|
||||
<td><input type="password" name="create_confirm_pwd" class="required"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><input type="submit" value="Create"/></td>
|
||||
@@ -218,15 +218,15 @@
|
||||
<table align="center" class="db_option_table">
|
||||
<tr>
|
||||
<td><label for="old_pwd">Old password:</label></td>
|
||||
<td><input type="password" name="old_pwd"/></td>
|
||||
<td><input type="password" name="old_pwd" class="required"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="new_pwd">New password:</label></td>
|
||||
<td><input type="password" name="new_pwd"/></td>
|
||||
<td><input type="password" name="new_pwd" class="required"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="confirm_pwd">Confirm password:</label></td>
|
||||
<td><input type="password" name="confirm_pwd"/></td>
|
||||
<td><input type="password" name="confirm_pwd" class="required"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><input type="submit" value="Change Password"/></td>
|
||||
|
||||
Reference in New Issue
Block a user