update user or group count only, when the multiselect is closed

This commit is contained in:
Arthur Schiwon 2015-01-14 17:31:20 +01:00
parent 672bc28715
commit 3d94aa8953
1 changed files with 34 additions and 4 deletions

View File

@ -819,15 +819,33 @@ var LdapWizard = {
LdapWizard._save(inputObj, val); LdapWizard._save(inputObj, val);
}, },
/**
* updates user or group count on multiSelect close. Resets the event
* function subsequently.
*
* @param {LdapFilter} filter
* @param {Object} $multiSelectObj
*/
onMultiSelectClose: function(filter, $multiSelectObj) {
filter.updateCount();
$multiSelectObj.multiselect({close: function(){}});
},
saveMultiSelect: function(originalObj, resultObj) { saveMultiSelect: function(originalObj, resultObj) {
values = ''; var values = '';
for(i = 0; i < resultObj.length; i++) { for(var i = 0; i < resultObj.length; i++) {
values = values + "\n" + resultObj[i].value; values = values + "\n" + resultObj[i].value;
} }
LdapWizard._save($('#'+originalObj)[0], $.trim(values)); LdapWizard._save($('#'+originalObj)[0], $.trim(values));
var $multiSelectObj = $('#'+originalObj);
var updateCount = !$multiSelectObj.multiselect("isOpen");
var applyUpdateOnCloseToFilter;
if(originalObj === 'ldap_userfilter_objectclass' if(originalObj === 'ldap_userfilter_objectclass'
|| originalObj === 'ldap_userfilter_groups') { || originalObj === 'ldap_userfilter_groups') {
LdapWizard.userFilter.compose(true); LdapWizard.userFilter.compose(updateCount);
if(!updateCount) {
applyUpdateOnCloseToFilter = LdapWizard.userFilter;
}
//when user filter is changed afterwards, login filter needs to //when user filter is changed afterwards, login filter needs to
//be adjusted, too //be adjusted, too
if(!LdapWizard.loginFilter) { if(!LdapWizard.loginFilter) {
@ -838,7 +856,19 @@ var LdapWizard = {
LdapWizard.loginFilter.compose(); LdapWizard.loginFilter.compose();
} else if(originalObj === 'ldap_groupfilter_objectclass' } else if(originalObj === 'ldap_groupfilter_objectclass'
|| originalObj === 'ldap_groupfilter_groups') { || originalObj === 'ldap_groupfilter_groups') {
LdapWizard.groupFilter.compose(true); LdapWizard.groupFilter.compose(updateCount);
if(!updateCount) {
applyUpdateOnCloseToFilter = LdapWizard.groupFilter;
}
}
if(applyUpdateOnCloseToFilter instanceof LdapFilter) {
$multiSelectObj.multiselect({
close: function () {
LdapWizard.onMultiSelectClose(
applyUpdateOnCloseToFilter, $multiSelectObj);
}
});
} }
}, },