org settings: Make bot list sortable.

This commit is contained in:
Thomas Ip
2019-08-15 13:33:31 +08:00
committed by Tim Abbott
parent 5c49133754
commit 444ce74a8e
2 changed files with 21 additions and 6 deletions

View File

@@ -148,7 +148,7 @@ function populate_users(realm_people_data) {
};
var $bots_table = $("#admin_bots_table");
list_render.create($bots_table, bots, {
var bot_list = list_render.create($bots_table, bots, {
name: "admin_bot_list",
modifier: function (item) {
return render_admin_user_list({
@@ -168,8 +168,23 @@ function populate_users(realm_people_data) {
},
onupdate: reset_scrollbar($bots_table),
},
parent_container: $("#admin-bot-list").expectOne(),
}).init();
bot_list.sort("alphabetic", "full_name");
bot_list.add_sort_function("bot_owner", function (a, b) {
if (!a.bot_owner) { return 1; }
if (!b.bot_owner) { return -1; }
if (a.bot_owner === b.bot_owner) {
return 0;
} else if (a.bot_owner > b.bot_owner) {
return 1;
}
return -1;
});
function get_rendered_last_activity(item) {
var today = new XDate();
if (item.last_active === LAST_ACTIVE_UNKNOWN) {