Commit ca97d7f7 authored by Nick Thomas's avatar Nick Thomas

Fix the users method in api.js

parent f35a5bba
...@@ -24,18 +24,6 @@ const Api = { ...@@ -24,18 +24,6 @@ const Api = {
.done(group => callback(group)); .done(group => callback(group));
}, },
users: function(search, options, callback = $.noop) {
var url = Api.buildUrl('/autocomplete/users.json');
return $.ajax({
url,
data: $.extend({
search,
per_page: 20
}, options),
dataType: 'json'
}).done(callback);
},
// Return groups list. Filtered by query // Return groups list. Filtered by query
groups(query, options, callback) { groups(query, options, callback) {
const url = Api.buildUrl(Api.groupsPath); const url = Api.buildUrl(Api.groupsPath);
...@@ -161,29 +149,29 @@ const Api = { ...@@ -161,29 +149,29 @@ const Api = {
}); });
}, },
buildUrl(url) {
let urlRoot = '';
if (gon.relative_url_root != null) {
urlRoot = gon.relative_url_root;
}
return urlRoot + url.replace(':version', gon.api_version);
},
ldap_groups(query, provider, callback) { ldap_groups(query, provider, callback) {
const url = Api.buildUrl(this.ldapGroupsPath).replace(':provider', provider); const url = Api.buildUrl(this.ldapGroupsPath).replace(':provider', provider);
return Api.wrapAjaxCall({ return Api.wrapAjaxCall({
url: url, url,
data: Object.assign({ data: Object.assign({
private_token: gon.api_token, private_token: gon.api_token,
search: query, search: query,
per_page: 20, per_page: 20,
active: true active: true,
}), }),
dataType: 'json' dataType: 'json',
}) })
.done(groups => callback(groups)); .done(groups => callback(groups));
}, },
buildUrl(url) {
let urlRoot = '';
if (gon.relative_url_root != null) {
urlRoot = gon.relative_url_root;
}
return urlRoot + url.replace(':version', gon.api_version);
},
wrapAjaxCall(options) { wrapAjaxCall(options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// jQuery 2 is not Promises/A+ compatible (missing catch) // jQuery 2 is not Promises/A+ compatible (missing catch)
......
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