diff --git a/static/js/attachments_ui.js b/static/js/attachments_ui.js index 75c3317c26..545835c86b 100644 --- a/static/js/attachments_ui.js +++ b/static/js/attachments_ui.js @@ -30,14 +30,15 @@ exports.set_up_attachments = function () { var attachments = page_params.attachments; _.each(attachments, function (attachment) { - attachment.create_time = timerender.absolute_time(attachment.create_time); - attachment.size = exports.bytes_to_size(attachment.size); + + attachment.create_time_str = timerender.absolute_time(attachment.create_time); + attachment.size_str = exports.bytes_to_size(attachment.size); }); var uploaded_files_table = $("#uploaded_files_table").expectOne(); var $search_input = $("#upload_file_search"); - list_render(uploaded_files_table, attachments, { + var list = list_render(uploaded_files_table, attachments, { name: "uploaded-files-list", modifier: function (attachment) { return templates.render("uploaded_files_list", { attachment: attachment }); @@ -53,6 +54,24 @@ exports.set_up_attachments = function () { }, }).init(); + list.add_sort_function("mentioned-in", function (a, b) { + var a_m = a.messages[0]; + var b_m = b.messages[0]; + + if (!a_m) { return 1; } + if (!b_m) { return -1; } + + if (a_m.id > b_m.id) { + return 1; + } else if (a_m.id === b_m.id) { + return 0; + } + + return -1; + }); + + + ui.set_up_scrollbar(uploaded_files_table.closest(".progressive-table-wrapper")); uploaded_files_table.empty(); diff --git a/static/templates/settings/attachments-settings.handlebars b/static/templates/settings/attachments-settings.handlebars index 0abf880fc4..41d4e7f13c 100644 --- a/static/templates/settings/attachments-settings.handlebars +++ b/static/templates/settings/attachments-settings.handlebars @@ -2,13 +2,13 @@
{{t "File" }} | -{{t "Date uploaded" }} | -{{t "Mentioned in" }} | -{{t "Size" }} | +{{t "File" }} | +{{t "Date uploaded" }} | +{{t "Mentioned in" }} | +{{t "Size" }} | {{t "Actions" }} | -{{ create_time }} | +{{ create_time_str }} | {{#if messages }} | - {{/if}}{{ size }} | +{{ size_str }} |
---|