Skip to content

Commit

Permalink
Patch for #1841 (Include both first and last name when sorting by use…
Browse files Browse the repository at this point in the history
…rs).

The part for issue list sorting is very rude hack, it will hardly become official patch.
  • Loading branch information
Artem Vasiliev committed Sep 4, 2008
1 parent c5f25ba commit 3246d2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions app/helpers/sort_helper.rb
Expand Up @@ -83,7 +83,11 @@ def sort_update()
# Use this to sort the controller's table items collection.
#
def sort_clause()
session[@sort_name][:key] + ' ' + (session[@sort_name][:order] || 'ASC')
order = session[@sort_name][:order] || 'ASC'
if (session[@sort_name][:key] == "users.lastname")
return "users.firstname %s, users.lastname %s" % [order, order]
end
session[@sort_name][:key] + ' ' + order
end

# Returns a link which sorts by the named column.
Expand Down Expand Up @@ -117,7 +121,7 @@ def sort_link(column, caption, default_order)
{:href => url_for(url_options)}) +
(icon ? nbsp(2) + image_tag(icon) : '')
end

# Returns a table header <th> tag with a sort link for the named column
# attribute.
#
Expand Down
8 changes: 5 additions & 3 deletions app/models/user.rb
Expand Up @@ -182,13 +182,15 @@ def self.find_by_autologin_key(key)
def <=>(user)
if user.nil?
-1
elsif lastname.to_s.downcase == user.lastname.to_s.downcase
firstname.to_s.downcase <=> user.firstname.to_s.downcase
else
lastname.to_s.downcase <=> user.lastname.to_s.downcase
self.fullname.downcase <=> user.fullname.downcase
end
end

def fullname
"#{firstname} #{lastname}"
end

def to_s
name
end
Expand Down

0 comments on commit 3246d2b

Please sign in to comment.