summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-29 14:22:56 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-29 14:22:56 +0000
commit945ec8942a4c43ed41aa4302cbe74ad45f1ff08c (patch)
tree2e2f45b48ee4277e6e1920d094c337a7b7191738 /app/helpers
parent32d4378198b83a10bab53c8e7cee2e4ec8adb818 (diff)
downloadredmine-945ec8942a4c43ed41aa4302cbe74ad45f1ff08c.tar.gz
redmine-945ec8942a4c43ed41aa4302cbe74ad45f1ff08c.zip
Adds projects association on tracker form (#2578).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2335 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3f92d8d4b..3bdb6e2eb 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -195,6 +195,30 @@ module ApplicationHelper
ancestors << project
end
end
+
+ def project_nested_ul(projects, &block)
+ s = ''
+ if projects.any?
+ ancestors = []
+ projects.sort_by(&:lft).each do |project|
+ if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
+ s << "<ul>\n"
+ else
+ ancestors.pop
+ s << "</li>"
+ while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
+ ancestors.pop
+ s << "</ul></li>\n"
+ end
+ end
+ s << "<li>"
+ s << yield(project).to_s
+ ancestors << project
+ end
+ s << ("</li></ul>\n" * ancestors.size)
+ end
+ s
+ end
# Truncates and returns the string as a single line
def truncate_single_line(string, *args)