Skip to content

Commit

Permalink
Adds helper routine note_description
Browse files Browse the repository at this point in the history
Adds new helper routine note_description for retrieving note's description. Helper routine returns "deleted" if author is deleted, first comment's body if data-migration is not done or note's description record if data-migration is done.
  • Loading branch information
nenad-vujicic committed Jan 28, 2025
1 parent 9c25018 commit b8be249
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/helpers/note_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
module NoteHelper
include ActionView::Helpers::TranslationHelper

def note_description(note)
if note.author_deleted?
RichText.new("text", t("notes.show.description_when_author_is_deleted"))
else
note.description
end
end

def note_event(event, at, by)
if by.nil?
t("notes.show.event_#{event}_by_anonymous_html",
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3067,6 +3067,7 @@ en:
open_title: "Unresolved note #%{note_name}"
closed_title: "Resolved note #%{note_name}"
hidden_title: "Hidden note #%{note_name}"
description_when_author_is_deleted: "deleted"
event_opened_by_html: "Created by %{user} %{time_ago}"
event_opened_by_anonymous_html: "Created by anonymous %{time_ago}"
event_commented_by_html: "Comment from %{user} %{time_ago}"
Expand Down

0 comments on commit b8be249

Please sign in to comment.