Improve empty user filter handling for stream creates.

If we blank out the user filter for users (by hitting backspace,
for example), then we now have short-circuit logic to display all
the user checkboxes.  (The user-facing behavior doesn't change here,
but now we don't have to process all the strings.)
This commit is contained in:
Steve Howell 2017-01-26 05:21:44 -08:00 committed by Tim Abbott
parent 88870c316f
commit 5c091437da
1 changed files with 25 additions and 17 deletions

View File

@ -925,24 +925,32 @@ $(function () {
} }
}); });
var users = people.get_rest_of_realm(); (function filter_user_checkboxes() {
var filtered_users = people.filter_people_by_search_terms(users, search_terms); var user_labels = $("#user-checkboxes label.add-user-label");
var user_labels = $("#user-checkboxes label.add-user-label");
// Be careful about modifying the follow code. A naive implementation if (search_term === '') {
// will work very poorly with a large user population (~1000 users). user_labels.css({display: 'block'});
// return;
// I tested using: `./manage.py populate_db --extra-users 3500` }
//
// This would break the previous implementation, whereas the new var users = people.get_rest_of_realm();
// implementation is merely sluggish. var filtered_users = people.filter_people_by_search_terms(users, search_terms);
user_labels.each(function () {
var elem = $(this); // Be careful about modifying the follow code. A naive implementation
var user_id = elem.attr('data-user-id'); // will work very poorly with a large user population (~1000 users).
var user_checked = filtered_users.has(user_id); //
var display = user_checked ? "block" : "none"; // I tested using: `./manage.py populate_db --extra-users 3500`
elem.css({display: display}); //
}); // This would break the previous implementation, whereas the new
// implementation is merely sluggish.
user_labels.each(function () {
var elem = $(this);
var user_id = elem.attr('data-user-id');
var user_checked = filtered_users.has(user_id);
var display = user_checked ? "block" : "none";
elem.css({display: display});
});
}());
update_announce_stream_state(); update_announce_stream_state();
e.preventDefault(); e.preventDefault();