summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-11-16 19:45:35 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-16 20:28:38 -0200
commit7783267d6cc41b6a5ced907316aefbc71f2a8e7e (patch)
treea764d6cb35c16fbf030cd069d266c03e54dc373c
parent59d43bea80b56faff54630934694b317cda9f899 (diff)
downloadgitlab-ce-7783267d6cc41b6a5ced907316aefbc71f2a8e7e.tar.gz
Add option to sort group/project members by access level
-rw-r--r--app/helpers/sorting_helper.rb18
-rw-r--r--app/models/member.rb2
2 files changed, 20 insertions, 0 deletions
diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb
index 9c6f9f741ed..f03c4627050 100644
--- a/app/helpers/sorting_helper.rb
+++ b/app/helpers/sorting_helper.rb
@@ -37,6 +37,8 @@ module SortingHelper
def member_sort_options_hash
{
+ sort_value_access_level_asc => sort_title_access_level_asc,
+ sort_value_access_level_desc => sort_title_access_level_desc,
sort_value_last_joined => sort_title_last_joined,
sort_value_oldest_joined => sort_title_oldest_joined,
sort_value_name => sort_title_name_asc,
@@ -114,6 +116,14 @@ module SortingHelper
'Oldest joined'
end
+ def sort_title_access_level_asc
+ 'Access level, ascending'
+ end
+
+ def sort_title_access_level_desc
+ 'Access level, descending'
+ end
+
def sort_title_name_asc
'Name, ascending'
end
@@ -130,6 +140,14 @@ module SortingHelper
'oldest_joined'
end
+ def sort_value_access_level_asc
+ 'access_level_asc'
+ end
+
+ def sort_value_access_level_desc
+ 'access_level_desc'
+ end
+
def sort_value_name_desc
'name_desc'
end
diff --git a/app/models/member.rb b/app/models/member.rb
index b82b16e6f33..8c36a631ac4 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -83,6 +83,8 @@ class Member < ActiveRecord::Base
def sort(method)
case method.to_s
+ when 'access_level_asc' then reorder(access_level: :asc)
+ when 'access_level_desc' then reorder(access_level: :desc)
when 'recent_sign_in' then order_recent_sign_in
when 'oldest_sign_in' then order_oldest_sign_in
when 'last_joined' then order_created_desc