mirror of
https://github.com/silentsakky/zarafa-webapp-passwd
synced 2026-07-27 10:30:56 +02:00
added most of the basic functionalities
This commit is contained in:
parent
b434706684
commit
5064cf5742
7 changed files with 365 additions and 57 deletions
|
|
@ -10,6 +10,8 @@ Zarafa.plugins.passwd.PasswdPanel = Ext.extend(Ext.form.FormPanel, {
|
|||
/**
|
||||
* @property
|
||||
* @type Ext.LoadMask
|
||||
* Save mask that will be displayed when request has been sent to server for password change
|
||||
* and waiting for the response.
|
||||
*/
|
||||
saveMask : undefined,
|
||||
|
||||
|
|
@ -63,6 +65,10 @@ Zarafa.plugins.passwd.PasswdPanel = Ext.extend(Ext.form.FormPanel, {
|
|||
this.on('afterrender', this.initialize, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Function will initialize this dialog with some default values and will
|
||||
* also create object of {@link #saveMask}.
|
||||
*/
|
||||
initialize : function()
|
||||
{
|
||||
this.userNameField.setValue(container.getUser().getUserName());
|
||||
|
|
@ -72,24 +78,51 @@ Zarafa.plugins.passwd.PasswdPanel = Ext.extend(Ext.form.FormPanel, {
|
|||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler function that will be called when user presses ok button
|
||||
* to change password.
|
||||
*/
|
||||
onOk : function()
|
||||
{
|
||||
// send request
|
||||
|
||||
// show load mask
|
||||
this.saveMask.show();
|
||||
|
||||
// send request
|
||||
container.getRequest().singleRequest('passwdmodule', 'save', {
|
||||
username : this.userNameField.getValue(),
|
||||
current_password : this.oldPasswdField.getValue(),
|
||||
new_password : this.newPasswdField.getValue(),
|
||||
new_password_repeat : this.newPasswdRepeatField.getValue()
|
||||
//}, new Zarafa.plugins.sugarcrm.data.SugarCRMResponseHandler());
|
||||
});
|
||||
}, new Zarafa.plugins.passwd.data.PasswdResponseHandler({
|
||||
callbackFn : this.callbackFn,
|
||||
scope : this
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler function that will be called when user presses cancel button
|
||||
* to close the dialog.
|
||||
*/
|
||||
onCancel : function()
|
||||
{
|
||||
// close the dialog
|
||||
this.dialog.close();
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback function that will be executed after response is received from server.
|
||||
* @param {Boolean} success boolean to indicate response contains success/failure data.
|
||||
* @param {Object} response response sent by server.
|
||||
*/
|
||||
callbackFn : function(success, response)
|
||||
{
|
||||
// hide load mask
|
||||
this.saveMask.hide();
|
||||
|
||||
// close the dialog
|
||||
if(success) {
|
||||
this.dialog.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
54
js/data/PasswdResponseHandler.js
Normal file
54
js/data/PasswdResponseHandler.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
Ext.namespace('Zarafa.plugins.passwd.data');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.passwd.data.ResponseHandler
|
||||
* @extends Zarafa.core.data.AbstractResponseHandler
|
||||
*
|
||||
* Passwd plugin specific response handler.
|
||||
*/
|
||||
Zarafa.plugins.passwd.data.PasswdResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, {
|
||||
|
||||
/**
|
||||
* @cfg {Function} callbackFn The function which will be called after success/failure response.
|
||||
*/
|
||||
callbackFn : undefined,
|
||||
|
||||
/**
|
||||
* @cfg {Object} scope The function scope that will be used when calling {@link #callbackFn}.
|
||||
*/
|
||||
scope : undefined,
|
||||
|
||||
/**
|
||||
* In case exception happened on server, server will return exception response with the display message.
|
||||
* @param {Object} response Object contained the response data.
|
||||
*/
|
||||
doError : function(response)
|
||||
{
|
||||
var displayMessage = _('An unknown error occurred while changing password.');
|
||||
|
||||
if(response.info) {
|
||||
displayMessage = response.info.display_message;
|
||||
}
|
||||
|
||||
Ext.MessageBox.alert(_('Error'), displayMessage);
|
||||
|
||||
this.callbackFn.apply(this.scope || this, [ false, response ]);
|
||||
},
|
||||
|
||||
/**
|
||||
* When password change is successfull server will send a success response including display message.
|
||||
* @param {Object} response Object contained the response data.
|
||||
*/
|
||||
doSuccess : function(response)
|
||||
{
|
||||
var displayMessage = _('Password is changed successfully.');
|
||||
|
||||
if(response.info) {
|
||||
displayMessage = response.info.display_message;
|
||||
}
|
||||
|
||||
Ext.MessageBox.alert(_('Success'), displayMessage);
|
||||
|
||||
this.callbackFn.apply(this.scope || this, [ true, response ]);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue