0
1
Fork 0
hedera-web-mindshore/forms/account/conf/conf.js

78 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
Hedera.Conf = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Hedera.Form
,activate: function ()
{
this.$('user-model').setInfo ('c', 'customer_view', 'hedera');
this.$('addresses').setInfo ('a', 'address_view', 'hedera');
}
2016-10-11 14:45:10 +00:00
,onPassChangeClick: function ()
{
this.$('old-password').value = '';
this.$('new-password').value = '';
this.$('repeat-password').value = '';
2016-10-11 14:45:10 +00:00
var hasPassword = this.$('user-form').get ('hasPassword');
this.$('old-password').style.display = hasPassword ? 'block' : 'none';
this.$('change-password').show ();
if (hasPassword)
this.$('old-password').focus ();
else
this.$('new-password').focus ();
}
,onPassModifyClick: function ()
2015-03-06 23:33:54 +00:00
{
2016-10-11 14:45:10 +00:00
try {
var oldPassword = this.$('old-password').value;
var newPassword = this.$('new-password').value;
var repeatedPassword = this.$('repeat-password').value;
if (newPassword == '' && repeatedPassword == '')
throw new Error (_('Passwords empty'));
if (newPassword !== repeatedPassword)
throw new Error (_('Passwords doesn\'t match'));
var batch = new Sql.Batch ();
batch.addValue ('oldPassword', oldPassword);
batch.addValue ('newPassword', newPassword);
2016-10-11 14:45:10 +00:00
var query = 'CALL account.userChangePassword (#oldPassword, #newPassword)';
this.conn.execQuery (query, this.onPasswordUpdate.bind (this), batch);
}
catch (e)
{
2016-10-11 14:45:10 +00:00
Htk.Toast.showError (e.message);
}
}
2015-03-06 23:33:54 +00:00
,onPasswordUpdate: function (resultSet)
{
2016-10-11 14:45:10 +00:00
try {
resultSet.fetchResult ();
this.$('change-password').hide ();
Htk.Toast.showMessage (_('Password changed!'));
}
catch (e)
{
Htk.Toast.showError (_('Password doesn\'t meet the requirements'));
this.$('old-password').select ();
}
2015-03-06 23:33:54 +00:00
}
2016-10-11 14:45:10 +00:00
,onPassInfoClick: function ()
2015-03-06 23:33:54 +00:00
{
2016-10-11 14:45:10 +00:00
this.$('password-info').show ();
}
2015-07-23 15:58:48 +00:00
,onAddressesClick: function ()
{
2015-07-23 15:58:48 +00:00
this.hash.set ({'form': 'account/address-list'});
}
});