From 81a1612cbd3dff977ed9aaab6a1957d4dec22e72 Mon Sep 17 00:00:00 2001 From: Tarun Kumar Date: Wed, 14 Mar 2018 14:31:14 +0530 Subject: [PATCH] user-groups: Fix reordering when name/description is edited. The edited group iswas going to the bottom, it is not staying at its position, so to fix this we sort by ids of the groups to maintain proper relative order. (Original commit also fixed another issue, but Tim replaced that with the previous commit for a better solution). Fixes #8692. --- static/js/user_groups.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/js/user_groups.js b/static/js/user_groups.js index 31a9931b32..266abc055c 100644 --- a/static/js/user_groups.js +++ b/static/js/user_groups.js @@ -18,7 +18,6 @@ exports.init(); exports.add = function (user_group) { // Reformat the user group members structure to be a dict. user_group.members = Dict.from_array(user_group.members); - user_group_name_dict.set(user_group.name, user_group); user_group_by_id_dict.set(user_group.id, user_group); }; @@ -51,7 +50,9 @@ exports.get_user_group_from_name = function (name) { }; exports.get_realm_user_groups = function () { - return user_group_name_dict.values(); + return user_group_by_id_dict.values().sort(function (a, b) { + return (a.id - b.id); + }); }; exports.is_member_of = function (user_group_id, user_id) {