org settings: Make emoji list sortable.

This commit is contained in:
Thomas Ip
2019-08-16 17:03:10 +08:00
committed by Tim Abbott
parent d851e2dafc
commit 936366ffaa
2 changed files with 14 additions and 3 deletions

View File

@@ -62,7 +62,7 @@ exports.populate_emoji = function (emoji_data) {
}
var emoji_table = $('#admin_emoji_table').expectOne();
list_render.create(emoji_table, Object.values(emoji_data), {
var emoji_list = list_render.create(emoji_table, Object.values(emoji_data), {
name: "emoji_list",
modifier: function (item) {
if (item.deactivated !== true) {
@@ -90,6 +90,17 @@ exports.populate_emoji = function (emoji_data) {
parent_container: $("#emoji-settings").expectOne(),
}).init();
emoji_list.sort("alphabetic", "name");
emoji_list.add_sort_function("author_full_name", function (a, b) {
if (a.author.full_name > b.author.full_name) {
return 1;
} else if (a.author.full_name === b.author.full_name) {
return 0;
}
return -1;
});
loading.destroy_indicator($('#admin_page_emoji_loading_indicator'));
};

View File

@@ -31,9 +31,9 @@
aria-label="{{t 'Filter linkifiers' }}"/>
<table class="table table-condensed table-striped wrapped-table admin_emoji_table">
<thead>
<th>{{t "Name" }}</th>
<th class="active" data-sort="alphabetic" data-sort-prop="name">{{t "Name" }}</th>
<th class="image">{{t "Image" }}</th>
<th class="image">{{t "Author" }}</th>
<th class="image" data-sort="author_full_name">{{t "Author" }}</th>
<th class="actions">{{t "Actions" }}</th>
</thead>
</table>