More UI tweaks and sorting

This commit is contained in:
2013-01-25 11:11:39 -07:00
parent 0b6975a655
commit 2327340b71
7 changed files with 71 additions and 49 deletions

View File

@@ -20,7 +20,7 @@ class CertificationsController < ApplicationController
@certification_users = []
#TODO: make a better SQL query for this
@certification.users.each do |user|
@certification.users.sort_by(&:name).each do |user|
@certification_users.push user if can? :read, user
end

View File

@@ -13,7 +13,7 @@ class UserCertificationsController < ApplicationController
# GET /user_certifications
# GET /user_certifications.json
def index
@grouped_user_certs = @user_certifications.group_by { |u| u.user.name }
@grouped_user_certs = @user_certifications.group_by { |uc| uc.certification }
respond_to do |format|
format.html # index.html.erb

View File

@@ -5,7 +5,27 @@ class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
@users = @users.sort_by(&:name)
case params[:sort]
when "name"
@users = @users.sort_by(&:name)
when "certifications"
@users = @users.sort_by{ |u| [-u.certifications.count,u.name] }
when "orientation"
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
when "waiver"
@users = @users.sort_by{ |u| [-u.waiver.to_i,u.name] }
when "member"
@users = @users.sort_by{ |u| [-u.member.to_i,u.name] }
when "card"
@users = @users.sort_by{ |u| [-u.cards.count,u.name] }
when "instructor"
@users = @users.sort{ |a,b| [b.instructor.to_s,a.name] <=> [a.instructor.to_s,b.name] }
when "admin"
@users = @users.sort{ |a,b| [b.admin.to_s,a.name] <=> [a.admin.to_s,b.name] }
else
@users = @users.sort_by(&:name)
end
respond_to do |format|
format.html # index.html.erb