Commit 2c5e70be authored by Clement Ho's avatar Clement Ho

Fix conflict on users_select

parent 28ebd706
......@@ -5,15 +5,10 @@
// TODO: remove eventHub hack after code splitting refactor
window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
(function() {
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; },
slice = [].slice;
this.UsersSelect = (function() {
function UsersSelect(currentUser, els) {
function UsersSelect(currentUser, els) {
var $els;
this.users = bind(this.users, this);
this.user = bind(this.user, this);
this.users = this.users.bind(this);
this.user = this.user.bind(this);
this.usersPath = "/autocomplete/users.json";
this.userPath = "/autocomplete/users/:id.json";
if (currentUser != null) {
......@@ -566,17 +561,17 @@ window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
},
initSelection: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.initSelection.apply(_this, args);
},
formatResult: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.formatResult.apply(_this, args);
},
formatSelection: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.formatSelection.apply(_this, args);
},
dropdownCssClass: "ajax-users-dropdown",
......@@ -587,9 +582,9 @@ window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
});
};
})(this));
}
}
UsersSelect.prototype.initSelection = function(element, callback) {
UsersSelect.prototype.initSelection = function(element, callback) {
var id, nullUser;
id = $(element).val();
if (id === "0") {
......@@ -600,9 +595,9 @@ window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
} else if (id !== "") {
return this.user(id, callback);
}
};
};
UsersSelect.prototype.formatResult = function(user) {
UsersSelect.prototype.formatResult = function(user) {
var avatar;
if (user.avatar_url) {
avatar = user.avatar_url;
......@@ -610,13 +605,13 @@ window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
avatar = gon.default_avatar_url;
}
return "<div class='user-result " + (!user.username ? 'no-username' : void 0) + "'> <div class='user-image'><img class='avatar s24' src='" + avatar + "'></div> <div class='user-name'>" + user.name + "</div> <div class='user-username'>" + (user.username || "") + "</div> </div>";
};
};
UsersSelect.prototype.formatSelection = function(user) {
UsersSelect.prototype.formatSelection = function(user) {
return user.name;
};
};
UsersSelect.prototype.user = function(user_id, callback) {
UsersSelect.prototype.user = function(user_id, callback) {
if (!/^\d+$/.test(user_id)) {
return false;
}
......@@ -630,11 +625,11 @@ window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
}).done(function(user) {
return callback(user);
});
};
};
// Return users list. Filtered by query
// Only active users retrieved
UsersSelect.prototype.users = function(query, options, callback) {
// Return users list. Filtered by query
// Only active users retrieved
UsersSelect.prototype.users = function(query, options, callback) {
var url;
url = this.buildUrl(this.usersPath);
return $.ajax({
......@@ -657,15 +652,13 @@ window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
}).done(function(users) {
return callback(users);
});
};
};
UsersSelect.prototype.buildUrl = function(url) {
UsersSelect.prototype.buildUrl = function(url) {
if (gon.relative_url_root != null) {
url = gon.relative_url_root.replace(/\/$/, '') + url;
}
return url;
};
};
return UsersSelect;
})();
}).call(window);
export default UsersSelect;
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