summaryrefslogtreecommitdiffstats
path: root/app/helpers/sort_helper.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-03-27 16:55:20 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-03-27 16:55:20 +0000
commit4524bc04e9627e93317a7fa6e6af6252f1276a0f (patch)
treefabcfa8d6df85b785f336878ec5e313ef7cace63 /app/helpers/sort_helper.rb
parent06d2c3fd4e4a39ae036444127a99ef0db9d7b00e (diff)
downloadredmine-4524bc04e9627e93317a7fa6e6af6252f1276a0f.tar.gz
redmine-4524bc04e9627e93317a7fa6e6af6252f1276a0f.zip
Issue list improvements for subtasking (#5196):
* makes the parent task column available * display the issue hierarchy when list is sorted by parent git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3618 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/sort_helper.rb')
-rw-r--r--app/helpers/sort_helper.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index 4ea7b87b0..c1a89db5a 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -81,7 +81,7 @@ module SortHelper
def to_sql
sql = @criteria.collect do |k,o|
if s = @available_criteria[k]
- (o ? s.to_a : s.to_a.collect {|c| "#{c} DESC"}).join(', ')
+ (o ? s.to_a : s.to_a.collect {|c| append_desc(c)}).join(', ')
end
end.compact.join(', ')
sql.blank? ? nil : sql
@@ -120,6 +120,15 @@ module SortHelper
@criteria.slice!(3)
self
end
+
+ # Appends DESC to the sort criterion unless it has a fixed order
+ def append_desc(criterion)
+ if criterion =~ / (asc|desc)$/i
+ criterion
+ else
+ "#{criterion} DESC"
+ end
+ end
end
def sort_name