From: Harry Wood Date: Fri, 9 Apr 2021 02:53:53 +0000 (+0100) Subject: Display no notes message when empty X-Git-Tag: live~2176^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/de8ee536b1e6d511f6d943b2e9afabf778979e6b Display no notes message when empty Display a 'No notes' message when there are no notes to display, rather than an empty table with pagination features. --- diff --git a/app/views/notes/index.html.erb b/app/views/notes/index.html.erb index 50059625d..b5af25321 100644 --- a/app/views/notes/index.html.erb +++ b/app/views/notes/index.html.erb @@ -3,35 +3,41 @@

<%= t ".subheading_html", :user => link_to(@user.display_name, user_path(@user)) %>

<% end %> -<%= render :partial => "notes_paging_nav" %> +<% if @notes.empty? %> +

<%= t ".no_notes" %>

- - - - - - - - - +<% else %> + <%= render :partial => "notes_paging_nav" %> + +
<%= t ".id" %><%= t ".creator" %><%= t ".description" %><%= t ".created_at" %><%= t ".last_changed" %>
+ + + + + + + + + + + <% @notes.each do |note| -%> + class="creator"<% end %>> + + + + + + - -<% @notes.each do |note| -%> - class="creator"<% end %>> - - - - - - - -<% end -%> -
<%= t ".id" %><%= t ".creator" %><%= t ".description" %><%= t ".created_at" %><%= t ".last_changed" %>
+ <% if note.closed? %> + <%= image_tag("closed_note_marker.png", :alt => "closed", :size => "25x40") %> + <% else %> + <%= image_tag("open_note_marker.png", :alt => "open", :size => "25x40") %> + <% end %> + <%= link_to note.id, browse_note_path(note) %><%= note_author(note.author) %><%= note.comments.first.body.to_html %><%= friendly_date_ago(note.created_at) %><%= friendly_date_ago(note.updated_at) %>
- <% if note.closed? %> - <%= image_tag("closed_note_marker.png", :alt => "closed", :size => "25x40") %> - <% else %> - <%= image_tag("open_note_marker.png", :alt => "open", :size => "25x40") %> - <% end %> - <%= link_to note.id, browse_note_path(note) %><%= note_author(note.author) %><%= note.comments.first.body.to_html %><%= friendly_date_ago(note.created_at) %><%= friendly_date_ago(note.updated_at) %>
+ <% end -%> + -<%= render :partial => "notes_paging_nav" %> + <%= render :partial => "notes_paging_nav" %> + +<% end -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 4cfdf5754..4e8385e26 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2638,6 +2638,7 @@ en: title: "Notes submitted or commented on by %{user}" heading: "%{user}'s notes" subheading_html: "Notes submitted or commented on by %{user}" + no_notes: No notes id: "Id" creator: "Creator" description: "Description" diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 1450aced8..50e7ae833 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -73,4 +73,11 @@ class NotesControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_select "table.note_list tr", :count => 11 end + + def test_empty_page + user = create(:user) + get user_notes_path(:display_name => user.display_name) + assert_response :success + assert_select "h4", :html => "No notes" + end end