Add option to sort group/project members by access level

This commit is contained in:
Douglas Barbosa Alexandre 2016-11-16 19:45:35 -02:00
parent 59d43bea80
commit 7783267d6c
2 changed files with 20 additions and 0 deletions

View file

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

View file

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