From 4dc584421a2ac26d67816d32e9d51b30d71eb550 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 17 Mar 2021 17:57:18 +0000 Subject: [PATCH] Refactor traces list display Ideas taken from #3036 --- app/views/traces/_trace.html.erb | 59 +++++++++++++++------- app/views/traces/index.html.erb | 2 +- config/locales/en.yml | 2 - test/controllers/traces_controller_test.rb | 2 +- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/app/views/traces/_trace.html.erb b/app/views/traces/_trace.html.erb index c2f4183eb4..b7325dc54e 100644 --- a/app/views/traces/_trace.html.erb +++ b/app/views/traces/_trace.html.erb @@ -8,28 +8,49 @@ <% end %> <% end %> - <%= link_to trace.name, :controller => "traces", :action => "show", :display_name => trace.user.display_name, :id => trace.id %> - ... - <% if trace.inserted %> - (<%= t ".count_points", :count => trace.size %>) - <% end %> - ... <%= time_ago_in_words(trace.timestamp, :scope => :'datetime.distance_in_words_ago') %> - <%= link_to_if trace.inserted?, t(".map"), { :controller => "site", :action => "index", :mlat => trace.latitude, :mlon => trace.longitude, :anchor => "map=14/#{trace.latitude}/#{trace.longitude}" }, { :title => t(".view_map") } %> / - <%= link_to t(".edit"), { :controller => "site", :action => "edit", :gpx => trace.id }, { :title => t(".edit_map") } %> + + + <%= link_to trace.name, :controller => "traces", :action => "show", :display_name => trace.user.display_name, :id => trace.id %> + - <% badge_class = case trace.visibility - when "public", "identifiable" then "success" - else "danger" - end %> - <%= t(".#{trace.visibility}") %> + <% if trace.inserted? %> + + <%= t ".count_points", :count => trace.size %> + + <% end %> + + <% badge_class = case trace.visibility + when "public", "identifiable" then "success" + else "danger" + end %> + <%= t(".#{trace.visibility}") %> -
- <%= trace.description %>
- <%= t ".by" %> <%= link_to trace.user.display_name, user_path(trace.user) %> - <% if !trace.tags.empty? %> - <%= t ".in" %> - <%= safe_join(trace.tags.collect { |tag| link_to_tag tag.tag }, ", ") %> + + + <%= time_ago_in_words(trace.timestamp, :scope => :'datetime.distance_in_words_ago') %> + + <%= t ".by" %> <%= link_to trace.user.display_name, user_path(trace.user) %> + <% if !trace.tags.empty? %> + <%= t ".in" %> + <%= safe_join(trace.tags.collect { |tag| link_to_tag tag.tag }, ", ") %> + <% end %> + +
+

+ <%= trace.description %> +

+ + + <% if trace.inserted? %> + <% end %> diff --git a/app/views/traces/index.html.erb b/app/views/traces/index.html.erb index fa69c48a2a..b38436c0a4 100644 --- a/app/views/traces/index.html.erb +++ b/app/views/traces/index.html.erb @@ -27,7 +27,7 @@ - <%= render @traces unless @traces.nil? %> + <%= render @traces %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index a2b8ab4426..ec4c2adf2f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2109,7 +2109,6 @@ en: more: "more" trace_details: "View Trace Details" view_map: "View Map" - edit: "edit" edit_map: "Edit Map" public: "PUBLIC" identifiable: "IDENTIFIABLE" @@ -2117,7 +2116,6 @@ en: trackable: "TRACKABLE" by: "by" in: "in" - map: "map" index: public_traces: "Public GPS traces" my_traces: "My GPS traces" diff --git a/test/controllers/traces_controller_test.rb b/test/controllers/traces_controller_test.rb index 9ced73414e..16a4741a07 100644 --- a/test/controllers/traces_controller_test.rb +++ b/test/controllers/traces_controller_test.rb @@ -768,7 +768,7 @@ def check_trace_index(traces) assert_select "tr", :count => traces.length do |rows| traces.zip(rows).each do |trace, row| assert_select row, "a", Regexp.new(Regexp.escape(trace.name)) - assert_select row, "span", Regexp.new(Regexp.escape("(#{trace.size} points)")) if trace.inserted? + assert_select row, "span", Regexp.new(Regexp.escape("#{trace.size} points")) if trace.inserted? assert_select row, "td", Regexp.new(Regexp.escape(trace.description)) assert_select row, "td", Regexp.new(Regexp.escape("by #{trace.user.display_name}")) end