Merged r14165 and r14166 (#19544).

git-svn-id: http://svn.redmine.org/redmine/branches/3.0-stable@14207 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2015-04-25 07:37:46 +00:00
parent 94910b1e09
commit 873dff0d36
3 changed files with 19 additions and 6 deletions

View File

@@ -85,7 +85,7 @@ module SortHelper
sql = @criteria.collect do |k,o|
if s = @available_criteria[k]
s = [s] unless s.is_a?(Array)
(o ? s : s.collect {|c| append_desc(c)})
s.collect {|c| append_order(c, o ? "ASC" : "DESC")}
end
end.flatten.compact
sql.blank? ? nil : sql
@@ -129,14 +129,19 @@ module SortHelper
self
end
# Appends DESC to the sort criterion unless it has a fixed order
def append_desc(criterion)
# Appends ASC/DESC to the sort criterion unless it has a fixed order
def append_order(criterion, order)
if criterion =~ / (asc|desc)$/i
criterion
else
"#{criterion} DESC"
"#{criterion} #{order}"
end
end
# Appends DESC to the sort criterion unless it has a fixed order
def append_desc(criterion)
append_order(criterion, "DESC")
end
end
def sort_name