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.
This commit is contained in:
Tarun Kumar
2018-03-14 14:31:14 +05:30
committed by Tim Abbott
parent bea9b6a748
commit 81a1612cbd

View File

@@ -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) {