From ba5a0c94208d2777818152278b072fbacf336cce Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Tue, 5 Jan 2021 20:16:11 +0100 Subject: [PATCH 1/3] Add post ID to offers/inquiries reports Co-authored-by: @dataf3l --- app/decorators/post_report_decorator.rb | 4 +++- app/views/reports/post_list.html.erb | 4 +++- app/views/reports/user_list.html.erb | 3 --- spec/decorators/post_report_decorator_spec.rb | 5 +++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/decorators/post_report_decorator.rb b/app/decorators/post_report_decorator.rb index b1c4fcce4..3ebb3985f 100644 --- a/app/decorators/post_report_decorator.rb +++ b/app/decorators/post_report_decorator.rb @@ -14,6 +14,7 @@ def name(extension) def headers [ + "", @type.model_name.human, User.model_name.human ] @@ -23,10 +24,11 @@ def rows grouped_rows = [] @collection.each do |category, posts| - grouped_rows << [category.try(:name) || "-", ""] + grouped_rows << ["", category.try(:name) || "-", ""] posts.each do |post| grouped_rows << [ + post.id, post.title, "#{post.user} (#{post.member_uid})" ] diff --git a/app/views/reports/post_list.html.erb b/app/views/reports/post_list.html.erb index 786bac8b5..8eff5134c 100644 --- a/app/views/reports/post_list.html.erb +++ b/app/views/reports/post_list.html.erb @@ -6,6 +6,7 @@ + <%= @post_type.model_name.human %> <%= User.model_name.human %> @@ -13,10 +14,11 @@ <% @posts.each do |cat, ps| %> -

<%= cat || '—' %>

+

<%= cat || '—' %>

<% ps.each do |post| %> + <%= post.id %> <%= post.title %> <%= "#{post.user} (#{post.member_uid})" %> diff --git a/app/views/reports/user_list.html.erb b/app/views/reports/user_list.html.erb index 9dca6fb06..ef533012c 100644 --- a/app/views/reports/user_list.html.erb +++ b/app/views/reports/user_list.html.erb @@ -2,8 +2,6 @@ - @@ -22,6 +20,5 @@ <% end %> -
N <%= User.human_attribute_name :username %> <%= User.human_attribute_name :email %>
diff --git a/spec/decorators/post_report_decorator_spec.rb b/spec/decorators/post_report_decorator_spec.rb index a515b2fbc..f3d429d9d 100644 --- a/spec/decorators/post_report_decorator_spec.rb +++ b/spec/decorators/post_report_decorator_spec.rb @@ -24,6 +24,7 @@ it "#headers" do expect(decorator.headers).to eq([ + "", Offer.model_name.human, User.model_name.human ]) @@ -34,8 +35,8 @@ offer = org.offers.of_active_members.active.first expect(decorator.rows).to eq([ - [category.name, ""], - [offer.title, "#{offer.user} (#{offer.member_uid})"] + ["", category.name, ""], + [offer.id, offer.title, "#{offer.user} (#{offer.member_uid})"] ]) end end From 6d8db8e745818fa54ee7037df64caef0e2330397 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Wed, 6 Jan 2021 19:05:51 +0100 Subject: [PATCH 2/3] refactor navbar: too much nested partials hurt view rendering performance --- app/views/application/_navbar.html.erb | 28 ++++++++++++++++--- .../menus/_inquiries_list_link.html.erb | 6 ---- .../menus/_offers_by_tag_link.html.erb | 6 ---- .../menus/_offers_list_link.html.erb | 6 ---- .../menus/_organization_switcher.html.erb | 11 -------- .../menus/_user_admin_menu_items.html.erb | 13 ++++++++- .../menus/_user_list_link.html.erb | 6 ---- app/views/reports/post_list.html.erb | 2 +- 8 files changed, 37 insertions(+), 41 deletions(-) delete mode 100644 app/views/application/menus/_inquiries_list_link.html.erb delete mode 100644 app/views/application/menus/_offers_by_tag_link.html.erb delete mode 100644 app/views/application/menus/_offers_list_link.html.erb delete mode 100644 app/views/application/menus/_organization_switcher.html.erb delete mode 100644 app/views/application/menus/_user_list_link.html.erb diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index 840f9b003..4f41013a3 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -52,11 +52,31 @@