]> git.openstreetmap.org Git - rails.git/blob - app/helpers/issues_helper.rb
Add some more tests, better error handling for dates
[rails.git] / app / helpers / issues_helper.rb
1 module IssuesHelper
2   def reportable_url(reportable)
3     case reportable
4     when DiaryEntry
5       url_for(:controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.user.display_name, :id => reportable.id)
6     when User
7       url_for(:controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.display_name)
8     when DiaryComment
9       url_for(:controller => reportable.diary_entry.class.name.underscore, :action => :view, :display_name => reportable.diary_entry.user.display_name, :id => reportable.diary_entry.id, :anchor => "comment#{reportable.id}")
10     when Note
11       url_for(:controller => :browse, :action => :note, :id => reportable.id)
12     end
13   end
14
15   def reportable_title(reportable)
16     case reportable
17     when DiaryEntry
18       reportable.title
19     when User
20       reportable.display_name
21     when DiaryComment
22       I18n.t("issues.helper.reportable_title.diary_comment", :entry_title => reportable.diary_entry.title, :comment_id => reportable.id)
23     when Note
24       I18n.t("issues.helper.reportable_title.note", :note_id => reportable.id)
25     end
26   end
27
28   def open_issues_count
29     count = Issue.visible_to(current_user).open.limit(100).size
30     if count > 99
31       content_tag(:span, "99+", :class => "count-number")
32     elsif count > 0
33       content_tag(:span, count, :class => "count-number")
34     end
35   end
36 end