]> git.openstreetmap.org Git - rails.git/blob - app/helpers/note_helper.rb
Merge remote-tracking branch 'upstream/pull/5725'
[rails.git] / app / helpers / note_helper.rb
1 module NoteHelper
2   include ActionView::Helpers::TranslationHelper
3
4   def note_description(author, description, first_comment)
5     if !author.nil? && author.status == "deleted"
6       RichText.new("text", t("notes.show.description_when_author_is_deleted"))
7     elsif first_comment&.event != "opened"
8       RichText.new("text", t("notes.show.description_when_there_is_no_opening_comment"))
9     else
10       description
11     end
12   end
13
14   def note_event(event, at, by)
15     if by.nil?
16       t("notes.show.event_#{event}_by_anonymous_html",
17         :time_ago => friendly_date_ago(at))
18     else
19       t("notes.show.event_#{event}_by_html",
20         :time_ago => friendly_date_ago(at),
21         :user => note_author(by))
22     end
23   end
24
25   def note_author(author, link_options = {})
26     if author.nil?
27       ""
28     elsif author.status == "deleted"
29       t("users.no_such_user.deleted")
30     else
31       link_to h(author.display_name), link_options.merge(:controller => "/users", :action => "show", :display_name => author.display_name),
32               :class => "mw-100 d-inline-block align-bottom text-truncate text-wrap", :dir => "auto"
33     end
34   end
35 end