admin users: Fix email sort.

The email sort now works correctly for admins in
realms with hidden emails.  (We want to sort on
delivery email.)
This commit is contained in:
Steve Howell 2020-04-15 13:09:23 +00:00 committed by Tim Abbott
parent cf741e9a11
commit 0b71b092b3
2 changed files with 14 additions and 2 deletions

View File

@ -20,6 +20,15 @@ function compare_a_b(a, b) {
return -1;
}
function sort_email(a, b) {
const email_a = settings_data.email_for_user_settings(a) || '';
const email_b = settings_data.email_for_user_settings(b) || '';
return compare_a_b(
email_a.toLowerCase(),
email_b.toLowerCase()
);
}
function sort_role(a, b) {
function role(user) {
if (user.is_admin) { return 0; }
@ -193,6 +202,7 @@ function populate_users(realm_people_data) {
parent_container: $("#admin-bot-list").expectOne(),
init_sort: ['alphabetic', 'full_name'],
sort_fields: {
email: sort_email,
bot_owner: sort_bot_owner,
},
});
@ -226,8 +236,9 @@ function populate_users(realm_people_data) {
parent_container: $("#admin-user-list").expectOne(),
init_sort: ['alphabetic', 'full_name'],
sort_fields: {
role: sort_role,
email: sort_email,
last_active: sort_last_active,
role: sort_role,
},
});
@ -249,6 +260,7 @@ function populate_users(realm_people_data) {
parent_container: $("#admin-deactivated-users-list").expectOne(),
init_sort: ['alphabetic', 'full_name'],
sort_fields: {
email: sort_email,
role: sort_role,
},
});

View File

@ -10,7 +10,7 @@
<thead>
<th class="active" data-sort="alphabetic" data-sort-prop="full_name">{{t "Name" }}</th>
{{#if show_email}}
<th data-sort="alphabetic" data-sort-prop="email">{{t "Email" }}</th>
<th data-sort="email">{{t "Email" }}</th>
{{/if}}
<th class="user_role" data-sort="role">{{t "Role" }}</th>
<th class="last_active" data-sort="last_active">{{t "Last active" }}</th>