Improves notes_description helper routine
Improves notes_description helper routine to return "unknown" for cases when first note's comment doesn't have event set to "opened" or note doesn't have comments. Added new argument (note's first comment), also updated helper routines usages.
This commit is contained in:
parent
bdf3abeb07
commit
f8fb850e8c
4 changed files with 6 additions and 3 deletions
|
@ -1,9 +1,11 @@
|
||||||
module NoteHelper
|
module NoteHelper
|
||||||
include ActionView::Helpers::TranslationHelper
|
include ActionView::Helpers::TranslationHelper
|
||||||
|
|
||||||
def note_description(author, description)
|
def note_description(author, description, first_comment)
|
||||||
if !author.nil? && author.status == "deleted"
|
if !author.nil? && author.status == "deleted"
|
||||||
RichText.new("text", t("notes.show.description_when_author_is_deleted"))
|
RichText.new("text", t("notes.show.description_when_author_is_deleted"))
|
||||||
|
elsif first_comment&.event != "opened"
|
||||||
|
RichText.new("text", t("notes.show.description_when_there_is_no_opening_comment"))
|
||||||
else
|
else
|
||||||
description
|
description
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td><%= link_to note.id, note %></td>
|
<td><%= link_to note.id, note %></td>
|
||||||
<td><%= note_author(note.author) %></td>
|
<td><%= note_author(note.author) %></td>
|
||||||
<td><%= note_description(note.author, note.description).to_html %></td>
|
<td><%= note_description(note.author, note.description, current_user&.moderator? ? note.comments.unscope(:where => :visible).first : note.comments.first).to_html %></td>
|
||||||
<td><%= friendly_date_ago(note.created_at) %></td>
|
<td><%= friendly_date_ago(note.created_at) %></td>
|
||||||
<td><%= friendly_date_ago(note.updated_at) %></td>
|
<td><%= friendly_date_ago(note.updated_at) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div>
|
<div>
|
||||||
<h4><%= t(".description") %></h4>
|
<h4><%= t(".description") %></h4>
|
||||||
<div class="overflow-hidden ms-2">
|
<div class="overflow-hidden ms-2">
|
||||||
<%= note_description(@note.author, @note.description).to_html %>
|
<%= note_description(@note.author, @note.description, current_user&.moderator? ? @note.comments.unscope(:where => :visible).first : @note.comments.first).to_html %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="details" data-coordinates="<%= @note.lat %>,<%= @note.lon %>" data-status="<%= @note.status %>">
|
<div class="details" data-coordinates="<%= @note.lat %>,<%= @note.lon %>" data-status="<%= @note.status %>">
|
||||||
|
|
|
@ -3095,6 +3095,7 @@ en:
|
||||||
closed_title: "Resolved note #%{note_name}"
|
closed_title: "Resolved note #%{note_name}"
|
||||||
hidden_title: "Hidden note #%{note_name}"
|
hidden_title: "Hidden note #%{note_name}"
|
||||||
description_when_author_is_deleted: "deleted"
|
description_when_author_is_deleted: "deleted"
|
||||||
|
description_when_there_is_no_opening_comment: "unknown"
|
||||||
event_opened_by_html: "Created by %{user} %{time_ago}"
|
event_opened_by_html: "Created by %{user} %{time_ago}"
|
||||||
event_opened_by_anonymous_html: "Created by anonymous %{time_ago}"
|
event_opened_by_anonymous_html: "Created by anonymous %{time_ago}"
|
||||||
event_commented_by_html: "Comment from %{user} %{time_ago}"
|
event_commented_by_html: "Comment from %{user} %{time_ago}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue