Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-06-21 15:09:31 +0300
committerBackportbot <backportbot-noreply@rullzer.com>2019-06-24 09:13:32 +0300
commitdb873a6efceb412f86da4ea3668540e48f07fcb1 (patch)
tree09b2a8f0abcb3a15b81b6f81974540a504443929 /apps/user_ldap
parent06c1e0ca2ab727f516ec440423d8cd8206bbe677 (diff)
fixes LDAP Wizard forgetting groups on select with search
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/js/wizard/wizardFilterOnType.js27
-rw-r--r--apps/user_ldap/js/wizard/wizardTabAbstractFilter.js39
-rw-r--r--apps/user_ldap/js/wizard/wizardTabGeneric.js10
3 files changed, 32 insertions, 44 deletions
diff --git a/apps/user_ldap/js/wizard/wizardFilterOnType.js b/apps/user_ldap/js/wizard/wizardFilterOnType.js
index bb1871023a2..f792b1a99a2 100644
--- a/apps/user_ldap/js/wizard/wizardFilterOnType.js
+++ b/apps/user_ldap/js/wizard/wizardFilterOnType.js
@@ -21,7 +21,6 @@ OCA = OCA || {};
init: function($select, $textInput) {
this.$select = $select;
this.$textInput = $textInput;
- this.updateOptions();
this.lastSearch = '';
var fity = this;
@@ -36,22 +35,6 @@ OCA = OCA || {};
},
/**
- * 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
*
* @param {FilterOnType} fity
@@ -62,10 +45,12 @@ OCA = OCA || {};
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);
diff --git a/apps/user_ldap/js/wizard/wizardTabAbstractFilter.js b/apps/user_ldap/js/wizard/wizardTabAbstractFilter.js
index 0131816e4ee..8312ad909ec 100644
--- a/apps/user_ldap/js/wizard/wizardTabAbstractFilter.js
+++ b/apps/user_ldap/js/wizard/wizardTabAbstractFilter.js
@@ -170,7 +170,7 @@ OCA = OCA || {};
} else {
var $element = $(this.tabID).find('.ldapGroupListSelected');
this.equipMultiSelect($element, groups);
- this.updateFilterOnType('selected');
+ this.updateFilterOnType();
}
},
@@ -212,10 +212,8 @@ OCA = OCA || {};
/**
* 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 = [];
@@ -227,13 +225,6 @@ OCA = OCA || {};
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();
- }
}
},
@@ -282,7 +273,7 @@ OCA = OCA || {};
// we reimplement it here to update the filter index
// for groups. Maybe we can isolate it?
if(methodName === 'setGroups') {
- view.updateFilterOnType('selected');
+ view.updateFilterOnType();
}
}
}
@@ -312,7 +303,6 @@ OCA = OCA || {};
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;
@@ -356,12 +346,22 @@ OCA = OCA || {};
*/
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);
},
/**
@@ -370,11 +370,12 @@ OCA = OCA || {};
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);
}
});
diff --git a/apps/user_ldap/js/wizard/wizardTabGeneric.js b/apps/user_ldap/js/wizard/wizardTabGeneric.js
index 9997d6e1b04..7b0df4992d6 100644
--- a/apps/user_ldap/js/wizard/wizardTabGeneric.js
+++ b/apps/user_ldap/js/wizard/wizardTabGeneric.js
@@ -228,10 +228,12 @@ OCA = OCA || {};
* @param {Array} options
*/
equipMultiSelect: function($element, options) {
- $element.empty();
- for (var i in options) {
- var name = options[i];
- $element.append($('<option>').val(name).text(name).attr('title', name));
+ if($element.find('option').length === 0) {
+ $element.empty();
+ for (var i in options) {
+ var name = options[i];
+ $element.append($('<option>').val(name).text(name).attr('title', name));
+ }
}
if(!$element.hasClass('ldapGroupList')) {
$element.multiselect('refresh');