add save button for setting LDAP Agent DN and Password

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-06-30 11:30:43 +02:00 committed by Morris Jobke
parent 52b1b97c58
commit 5c05a9327c
No known key found for this signature in database
GPG key ID: FE03C3A163FEDE68
3 changed files with 48 additions and 4 deletions

View file

@ -43,11 +43,15 @@ OCA = OCA || {};
},
ldap_dn: {
$element: $('#ldap_dn'),
setMethod: 'setAgentDN'
setMethod: 'setAgentDN',
preventAutoSave: true,
$saveButton: $('.ldapSaveAgentCredentials')
},
ldap_agent_password: {
$element: $('#ldap_agent_password'),
setMethod: 'setAgentPwd'
setMethod: 'setAgentPwd',
preventAutoSave: true,
$saveButton: $('.ldapSaveAgentCredentials')
},
ldap_base: {
$element: $('#ldap_base'),
@ -65,7 +69,11 @@ OCA = OCA || {};
}
};
this.setManagedItems(items);
_.bindAll(this, 'onPortButtonClick', 'onBaseDNButtonClick', 'onBaseDNTestButtonClick');
_.bindAll(this,
'onPortButtonClick',
'onBaseDNButtonClick',
'onBaseDNTestButtonClick'
);
this.managedItems.ldap_port.$relatedElements.click(this.onPortButtonClick);
this.managedItems.ldap_base.$detectButton.click(this.onBaseDNButtonClick);
this.managedItems.ldap_base.$testButton.click(this.onBaseDNTestButtonClick);

View file

@ -53,6 +53,7 @@ OCA = OCA || {};
setManagedItems: function(managedItems) {
this.managedItems = managedItems;
this._enableAutoSave();
this._enableSaveButton();
},
/**
@ -319,7 +320,10 @@ OCA = OCA || {};
for(var id in this.managedItems) {
if(_.isUndefined(this.managedItems[id].$element)
|| _.isUndefined(this.managedItems[id].setMethod)) {
|| _.isUndefined(this.managedItems[id].setMethod)
|| (!_.isUndefined(this.managedItems[id].preventAutoSave)
&& this.managedItems[id].preventAutoSave === true)
) {
continue;
}
var $element = this.managedItems[id].$element;
@ -331,6 +335,35 @@ OCA = OCA || {};
}
},
/**
* set's up save-button behavior (essentially used for agent dn and pwd)
*
* @private
*/
_enableSaveButton: function() {
var view = this;
// TODO: this is not nice, because it fires one request per change
// in the scenario this happens twice, causes detectors to run
// duplicated etc. To have this work properly, the wizard endpoint
// must accept setting multiple changes. Instead of messing around
// with old ajax/wizard.php use this opportunity and create a
// Controller
for(var id in this.managedItems) {
if(_.isUndefined(this.managedItems[id].$element)
|| _.isUndefined(this.managedItems[id].$saveButton)
) {
continue;
}
(function (item) {
item.$saveButton.click(function(event) {
event.preventDefault();
view._requestSave(item.$element);
});
})(this.managedItems[id]);
}
},
/**
* initializes a multiSelect element
*

View file

@ -61,6 +61,9 @@
placeholder="<?php p($l->t('Password'));?>" autocomplete="off"
title="<?php p($l->t('For anonymous access, leave DN and Password empty.'));?>"
/>
<button class="ldapSaveAgentCredentials" name="ldapSaveAgentCredentials" type="button">
<?php p($l->t('Save Credentials'));?>
</button>
</div>
<div class="tablerow">