mirror of
https://github.com/dducret/kopano-webapp-passwd
synced 2026-07-27 18:42:47 +02:00
simplify code
This commit is contained in:
parent
227bb4a886
commit
0d77ec5564
3 changed files with 13 additions and 136 deletions
|
|
@ -62,22 +62,7 @@ Zarafa.plugins.passwd.settings.PasswdPanel = Ext.extend(Ext.form.FormPanel, {
|
|||
* @event userchange
|
||||
* Fires when a field is modified in the form panel
|
||||
*/
|
||||
'userchange',
|
||||
/**
|
||||
* @event beforesave
|
||||
* Fires when this form panel about to send request to server
|
||||
*/
|
||||
'beforesave',
|
||||
/**
|
||||
* @event save
|
||||
* Fires when this form panel has successfully changed password
|
||||
*/
|
||||
'save',
|
||||
/**
|
||||
* @event exception
|
||||
* Fires when this form panel was not able to change password
|
||||
*/
|
||||
'exception'
|
||||
'userchange'
|
||||
);
|
||||
|
||||
Zarafa.plugins.passwd.settings.PasswdPanel.superclass.constructor.apply(this, arguments);
|
||||
|
|
@ -104,46 +89,6 @@ Zarafa.plugins.passwd.settings.PasswdPanel = Ext.extend(Ext.form.FormPanel, {
|
|||
onFieldChange : function(field, newValue, oldValue)
|
||||
{
|
||||
this.fireEvent('userchange', this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Function will be called when user presses apply to change password.
|
||||
*/
|
||||
saveChanges : function()
|
||||
{
|
||||
this.fireEvent('beforesave', this);
|
||||
|
||||
var data = this.getForm().getFieldValues();
|
||||
|
||||
// send request
|
||||
container.getRequest().singleRequest('passwdmodule', 'save', data, new Zarafa.plugins.passwd.data.PasswdResponseHandler({
|
||||
callbackFn : this.callbackFn,
|
||||
scope : this
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
* Function will be called when user presses discard button to reset
|
||||
* fields.
|
||||
*/
|
||||
discardChanges : function()
|
||||
{
|
||||
// reset user changes
|
||||
this.getForm().reset();
|
||||
},
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if(success) {
|
||||
this.fireEvent('save', this);
|
||||
} else {
|
||||
this.fireEvent('exception', this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -27,82 +27,6 @@ Zarafa.plugins.passwd.settings.SettingsPasswdCategory = Ext.extend(Zarafa.settin
|
|||
});
|
||||
|
||||
Zarafa.plugins.passwd.settings.SettingsPasswdCategory.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called by superclass when the Category has been deselected and is hidden from the user,
|
||||
* this will unregister the {@link #onBeforeSaveRules} event handler.
|
||||
* @private
|
||||
*/
|
||||
onHide : function()
|
||||
{
|
||||
Zarafa.common.settings.SettingsRuleCategory.superclass.onHide.apply(this, arguments);
|
||||
|
||||
// Unregister the 'beforesave' event. This could be lingering when
|
||||
// 'savesettings' was fired but it was cancelled by one of the
|
||||
// event handlers.
|
||||
var panel = this.get(0).passwdPanel;
|
||||
this.mun(panel, 'beforesave', this.onBeforeSavePasswd, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Event handler for the
|
||||
* {@link Zarafa.settings.SettingsContextModel ContextModel}#{@link Zarafa.settings.SettingsContextModel#beforesavesettings beforesavesettings}
|
||||
* event. It will reset the {@link #savingElCounter} and his will register the event handler for
|
||||
* {@link Zarafa.settings.SettingsModel#beforesave beforesave} event.
|
||||
* @private
|
||||
*/
|
||||
onBeforeSaveSettingsModel : function()
|
||||
{
|
||||
Zarafa.common.settings.SettingsRuleCategory.superclass.onBeforeSaveSettingsModel.apply(this, arguments);
|
||||
|
||||
var panel = this.get(0).passwdPanel;
|
||||
this.mon(panel, 'beforesave', this.onBeforeSavePasswd, this, { single : true });
|
||||
},
|
||||
|
||||
/**
|
||||
* Event handler which is fired when the {@link Zarafa.plugins.passwd.settings.PasswdPanel Passwd Panel}
|
||||
* fires the 'beforesave' event. This will {@link #displaySavingMask show a notification} and register the
|
||||
* event handlers for the completion of the save.
|
||||
* @private
|
||||
*/
|
||||
onBeforeSavePasswd : function()
|
||||
{
|
||||
this.displaySavingMask();
|
||||
|
||||
var panel = this.get(0).passwdPanel;
|
||||
this.mon(panel, 'save', this.onPasswdSave, this);
|
||||
this.mon(panel, 'exception', this.onPasswdException, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Event handler which is fired when the {@link Zarafa.common.rules.data.RulesStore Rules Store}
|
||||
* fires the 'save' event indicating the successfull save of the rules. This will
|
||||
* {@link #hideSavingMask hide the notification}.
|
||||
* @private
|
||||
*/
|
||||
onPasswdSave : function()
|
||||
{
|
||||
this.hideSavingMask(true);
|
||||
|
||||
var panel = this.get(0).passwdPanel;
|
||||
this.mun(panel, 'save', this.onPasswdSave, this);
|
||||
this.mun(panel, 'exception', this.onPasswdException, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Event handler which is fired when the {@link Zarafa.common.rules.data.RulesStore Rules Store}
|
||||
* fires the 'exception' event indicating a failing save of the rules. This will
|
||||
* {@link #hideSavingMask hide the notification}.
|
||||
* @private
|
||||
*/
|
||||
onPasswdException : function()
|
||||
{
|
||||
this.hideSavingMask(false);
|
||||
|
||||
var panel = this.get(0).passwdPanel;
|
||||
this.mun(panel, 'save', this.onPasswdSave, this);
|
||||
this.mun(panel, 'exception', this.onPasswdException, this);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ Zarafa.plugins.passwd.settings.SettingsPasswdWidget = Ext.extend(Zarafa.settings
|
|||
ref : 'passwdPanel',
|
||||
listeners : {
|
||||
userchange : this.setModelDirty,
|
||||
beforesave : this.onBeforeSave,
|
||||
|
||||
scope : this
|
||||
}
|
||||
}]
|
||||
|
|
@ -67,7 +65,17 @@ Zarafa.plugins.passwd.settings.SettingsPasswdWidget = Ext.extend(Zarafa.settings
|
|||
{
|
||||
// only save when this category is visible on screen
|
||||
if(this.ownerCt.isVisible()) {
|
||||
this.passwdPanel.saveChanges();
|
||||
this.ownerCt.displaySavingMask();
|
||||
|
||||
var data = this.passwdPanel.getForm().getFieldValues();
|
||||
|
||||
// send request
|
||||
container.getRequest().singleRequest('passwdmodule', 'save', data, new Zarafa.plugins.passwd.data.PasswdResponseHandler({
|
||||
callbackFn : function(success, response) {
|
||||
this.ownerCt.hideSavingMask(success);
|
||||
},
|
||||
scope : this
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -79,7 +87,7 @@ Zarafa.plugins.passwd.settings.SettingsPasswdWidget = Ext.extend(Zarafa.settings
|
|||
*/
|
||||
onDiscardSettings : function()
|
||||
{
|
||||
this.passwdPanel.discardChanges();
|
||||
this.passwdPanel.getForm().reset();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue