Commit ff7419b3 authored by Clement Ho's avatar Clement Ho

[skip ci] remove unnecessary ajax request

parent ea048763
......@@ -255,7 +255,8 @@ GitLabDropdown = (function() {
}
};
// Remote data
})(this)
})(this),
instance: this,
});
}
}
......@@ -269,6 +270,7 @@ GitLabDropdown = (function() {
remote: this.options.filterRemote,
query: this.options.data,
keys: searchFields,
instance: this,
elements: (function(_this) {
return function() {
selector = '.dropdown-content li:not(' + NON_SELECTABLE_CLASSES + ')';
......
......@@ -131,6 +131,11 @@
var isAuthorFilter;
isAuthorFilter = $('.js-author-search');
return _this.users(term, options, function(users) {
const glDropdown = this.instance || this.options.instance;
glDropdown.options.processData(term, users, callback);
}.bind(this));
},
processData: function(term, users, callback) {
var anyUser, index, j, len, name, obj, showDivider;
if (term.length === 0) {
showDivider = 0;
......@@ -171,7 +176,6 @@
users.splice(showDivider, 0, "divider");
}
if ($dropdown.hasClass('js-multiselect')) {
const selected = $selectbox
.find('input[name="' + $dropdown.data('field-name') + '"]')
......@@ -181,8 +185,6 @@
.get()
.filter((i) => i !== 0);
// const unassignedSelected = selected.length === 1 && selected[0] === 0;
// && !unassignedSelected
if (selected.length > 0) {
const selectedUsers = users
.filter((u) => selected.indexOf(u.id) !== -1)
......@@ -205,7 +207,6 @@
if (showMenuAbove) {
$dropdown.data('glDropdown').positionMenuAbove();
}
});
},
filterable: true,
filterRemote: true,
......@@ -216,10 +217,16 @@
fieldName: $dropdown.data('field-name'),
toggleLabel: function(selected, el, glDropdown) {
if (this.multiSelect) {
// debugger
const inputValue = glDropdown.filterInput.val();
const users = glDropdown.fullData.filter((r) => {
return typeof r === 'object' && !Object.prototype.hasOwnProperty.call(r, 'beforeDivider');
});
const callback = glDropdown.parseData.bind(glDropdown);
// Update the data model
// debugger
this.data(glDropdown.filterInput.val(), glDropdown.parseData.bind(glDropdown));
this.processData(inputValue, users, callback);
}
if (selected && 'id' in selected && $(el).hasClass('is-active')) {
......@@ -309,7 +316,7 @@
}
updateIssueBoardsIssue();
} else {
} else if (!$dropdown.hasClass('js-multiselect')) {
selected = $dropdown.closest('.selectbox').find("input[name='" + ($dropdown.data('field-name')) + "']").val();
return assignTo(selected);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment