mirror of https://github.com/zulip/zulip.git
Add search filter for user list.
Whatever text is entered into the search box under users is used to filter users by their full names. You can use commas to search for multiple users. Search terms must be at the start of names, so "st,fr" would match "Steve Howell" and "Leo Franchi" but not "jesstess." Names are case insensitive. (imported from commit 822b72883928d3c941d38e9798774d71b0689f30)
This commit is contained in:
parent
0a574eeefa
commit
cb6438234a
|
@ -150,12 +150,45 @@ function focus_lost() {
|
|||
exports.has_focus = false;
|
||||
}
|
||||
|
||||
function filter_users_by_search(users) {
|
||||
var search_term = $(".user-list-filter").expectOne().val().trim();
|
||||
|
||||
if (search_term === '') {
|
||||
return users;
|
||||
}
|
||||
|
||||
var search_terms = search_term.toLowerCase().split(",");
|
||||
search_terms = _.map(search_terms, function (s) {
|
||||
return s.trim();
|
||||
});
|
||||
|
||||
var filtered_users = _.filter(users, function (user) {
|
||||
var person = people_dict.get(user);
|
||||
if (!person || !person.full_name) {
|
||||
return false;
|
||||
}
|
||||
var names = person.full_name.toLowerCase().split();
|
||||
names = _.map(names, function (s) {
|
||||
return s.trim();
|
||||
});
|
||||
return _.any(search_terms, function (search_term) {
|
||||
return _.any(names, function (name) {
|
||||
return name.indexOf(search_term) === 0;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return filtered_users;
|
||||
}
|
||||
|
||||
function actually_update_users() {
|
||||
if (page_params.domain === 'mit.edu') {
|
||||
return; // MIT realm doesn't have a presence list
|
||||
}
|
||||
|
||||
var users = sort_users(Object.keys(presence_info), presence_info);
|
||||
var users = Object.keys(presence_info);
|
||||
users = filter_users_by_search(users);
|
||||
users = sort_users(users, presence_info);
|
||||
|
||||
function get_num_unread(email) {
|
||||
if (suppress_unread_counts) {
|
||||
|
@ -204,6 +237,14 @@ function actually_update_users() {
|
|||
// seconds to update user activity.
|
||||
var update_users = _.throttle(actually_update_users, 5000);
|
||||
|
||||
|
||||
function actually_update_users_for_search() {
|
||||
actually_update_users();
|
||||
ui.resize_page_components();
|
||||
}
|
||||
|
||||
var update_users_for_search = _.throttle(actually_update_users_for_search, 50);
|
||||
|
||||
exports.update_huddles = function () {
|
||||
if (page_params.domain === 'mit.edu') {
|
||||
return; // MIT realm doesn't have a presence list
|
||||
|
@ -322,6 +363,12 @@ exports.set_user_statuses = function (users, server_time) {
|
|||
exports.update_huddles();
|
||||
};
|
||||
|
||||
|
||||
$(function () {
|
||||
$(".user-list-filter").expectOne().on('input', update_users_for_search);
|
||||
});
|
||||
|
||||
|
||||
return exports;
|
||||
|
||||
}());
|
||||
|
|
|
@ -3730,3 +3730,6 @@ li.show-more-topics a {
|
|||
display: none;
|
||||
}
|
||||
|
||||
.user-list-filter {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<div id="userlist-header">
|
||||
<h4 class='sidebar-title' id='userlist-title'>USERS</h4>
|
||||
</div>
|
||||
<input class="user-list-filter" type="text" placeholder="filter users" />
|
||||
<ul id="user_presences" class="filters scrolling_list"></ul>
|
||||
{% if show_invites %}
|
||||
<a id="invite-user-link" href="#invite-user" data-toggle="modal"><i class="icon-vector-plus-sign"></i>Invite coworkers</a>
|
||||
|
|
Loading…
Reference in New Issue