init: function($select, $textInput) {
this.$select = $select;
this.$textInput = $textInput;
- this.updateOptions();
this.lastSearch = '';
var fity = this;
});
},
- /**
- * the options will be read in again. Should be called after a
- * configuration switch.
- */
- updateOptions: function() {
- var options = [];
- this.$select.find('option').each(function() {
- options.push({
- value: $(this).val(),
- normalized: $(this).val().toLowerCase()
- }
- );
- });
- this._options = options;
- },
-
/**
* the actual search or filter method
*
return;
}
fity.lastSearch = filterVal;
- fity.$select.empty();
- $.each(fity._options, function() {
- if(!filterVal || this.normalized.indexOf(filterVal) > -1) {
- fity.$select.append($('<option>').val(this.value).text(this.value));
+
+ fity.$select.find('option').each(function() {
+ if(!filterVal || $(this).val().toLowerCase().indexOf(filterVal) > -1) {
+ $(this).removeAttr('hidden')
+ } else {
+ $(this).attr('hidden', 'hidden');
}
});
delete(fity.runID);
} else {
var $element = $(this.tabID).find('.ldapGroupListSelected');
this.equipMultiSelect($element, groups);
- this.updateFilterOnType('selected');
+ this.updateFilterOnType();
}
},
/**
* updates (creates, if necessary) filterOnType instances
- *
- * @param {string} [only] - if only one search index should be updated
*/
- updateFilterOnType: function(only) {
+ updateFilterOnType: function() {
if(_.isUndefined(this.filterOnType)) {
this.filterOnType = [];
this.filterOnType.push(this.foTFactory.get(
$selectedGroups, $(this.tabID).find('.ldapManyGroupsSearch')
));
- } else {
- if(_.isUndefined(only) || only.toLowerCase() === 'available') {
- this.filterOnType[0].updateOptions();
- }
- if(_.isUndefined(only) || only.toLowerCase() === 'selected') {
- this.filterOnType[1].updateOptions();
- }
}
},
// we reimplement it here to update the filter index
// for groups. Maybe we can isolate it?
if(methodName === 'setGroups') {
- view.updateFilterOnType('selected');
+ view.updateFilterOnType();
}
}
}
var selected = view.configModel.configuration[view.getGroupsItem().keyName];
var available = $(payload.data).not(selected).get();
view.equipMultiSelect($element, available);
- view.updateFilterOnType('available');
$(view.tabID).find(".ldapManyGroupsSupport").removeClass('hidden');
view.getGroupsItem().$element.multiselect({classes: view.multiSelectPluginClass + ' forceHidden'});
view.isComplexGroupChooser = true;
*/
onSelectGroup: function() {
var $available = $(this.tabID).find('.ldapGroupListAvailable');
+ if(!$available.val()) {
+ return; // no selection – nothing to do
+ }
+
var $selected = $(this.tabID).find('.ldapGroupListSelected');
var selected = $.map($selected.find('option'), function(e) { return e.value; });
- this._saveGroups(selected.concat($available.val()));
- $available.find('option:selected').prependTo($selected);
- this.updateFilterOnType('available'); // selected groups are not updated yet
+ let selectedGroups = [];
+ $available.find('option:selected:visible').each(function() {
+ selectedGroups.push($(this).val());
+ });
+
+ this._saveGroups(selected.concat(selectedGroups));
+ $available.find('option:selected:visible').prependTo($selected);
+ this.updateFilterOnType(); // selected groups are not updated yet
+ $available.find('option:selected').prop("selected", false);
},
/**
onDeselectGroup: function() {
var $available = $(this.tabID).find('.ldapGroupListAvailable');
var $selected = $(this.tabID).find('.ldapGroupListSelected');
- var selected = $.map($selected.find('option:not(:selected)'), function(e) { return e.value; });
+ var selected = $.map($selected.find('option:not(:selected:visible)'), function(e) { return e.value; });
this._saveGroups(selected);
- $selected.find('option:selected').appendTo($available);
- this.updateFilterOnType('available'); // selected groups are not updated yet
+ $selected.find('option:selected:visible').appendTo($available);
+ this.updateFilterOnType(); // selected groups are not updated yet
+ $selected.find('option:selected').prop("selected", false);
}
});