From: Harry Wood Date: Fri, 9 Apr 2021 17:06:05 +0000 (+0100) Subject: Display no diary comments message when empty X-Git-Tag: live~2115^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/95d682119ae4e72dd97af38268297c20845bc362 Display no diary comments message when empty Display a 'No diary comments' message when there are no diary comments to display, rather than an empty table. --- diff --git a/app/views/diary_entries/comments.html.erb b/app/views/diary_entries/comments.html.erb index 78f16eb8c..290fba35e 100644 --- a/app/views/diary_entries/comments.html.erb +++ b/app/views/diary_entries/comments.html.erb @@ -2,24 +2,30 @@

<%= t(".has_commented_on", :display_name => @user.display_name) %>

<% end %> - - - - - - +<% if @comments.empty? %> +

<%= t ".no_comments" %>

+ +<% else %> +
<%= t ".post" %><%= t ".when" %><%= t ".comment" %>
+ + + + + + + + <% @comments.each do |comment| -%> + "> + + + - - <% @comments.each do |comment| -%> - "> - - - - - <% end -%> -
<%= t ".post" %><%= t ".when" %><%= t ".comment" %>
<%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %><%= time_ago_in_words(comment.created_at, :scope => :'datetime.distance_in_words_ago') %><%= comment.body.to_html %>
<%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %><%= time_ago_in_words(comment.created_at, :scope => :'datetime.distance_in_words_ago') %><%= comment.body.to_html %>
+ <% end -%> + + +
+ <%= link_to t(".older_comments"), :page => @comment_pages.current.next if @comment_pages.current.next %> + <%= link_to t(".newer_comments"), :page => @comment_pages.current.previous if @comment_pages.current.previous %> +
-
- <%= link_to t(".older_comments"), :page => @comment_pages.current.next if @comment_pages.current.next %> - <%= link_to t(".newer_comments"), :page => @comment_pages.current.previous if @comment_pages.current.previous %> -
+<% end -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 4e8385e26..b07536c27 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -474,6 +474,7 @@ en: description: "Recent diary entries from users of OpenStreetMap" comments: has_commented_on: "%{display_name} has commented on the following diary entries" + no_comments: "No diary comments" post: Post when: When comment: Comment diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index 45fe4add1..255b43997 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -848,9 +848,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest get diary_comments_path(:display_name => user.display_name) assert_response :success assert_template :comments - assert_select "table.table-striped" do - assert_select "tr", :count => 1 # header, no comments - end + assert_select "h4", :html => "No diary comments" # Test a user with a comment create(:diary_comment, :user => other_user)