From d777bb98540783870471e6bb2c165cc264b35d47 Mon Sep 17 00:00:00 2001
From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com>
Date: Mon, 7 Oct 2024 19:16:08 -0400
Subject: [PATCH 1/5] feat: Add profile option to always view full names in
event view
Created migration to add :prefers_full_name to member. Added the option to edit it. Made it change the way names are displayed by event_role.
---
app/helpers/events_helper.rb | 2 +-
app/models/event_role.rb | 6 +++++-
app/views/members/_form.html.erb | 7 ++++++-
app/views/members/show.html.erb | 6 ++++++
.../20241007223900_add_profile_option_view_full_name.rb | 6 ++++++
db/schema.rb | 3 ++-
6 files changed, 26 insertions(+), 4 deletions(-)
create mode 100644 db/migrate/20241007223900_add_profile_option_view_full_name.rb
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
index 0331cb2d..bf8f2c28 100644
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -150,7 +150,7 @@ def show_run_position(er, hover)
return link_to("you?", new_application_url(er.event, event_role_id: er.id, format: :js), :remote => true) unless hover
"you?" if hover
elsif !hover and current_member
- er.assigned_to use_display_name: true
+ er.assigned_to use_display_name: true, use_both_names: current_member.prefers_full_name
else
er.assigned_to
end
diff --git a/app/models/event_role.rb b/app/models/event_role.rb
index 9d8e039a..ae9ed96b 100644
--- a/app/models/event_role.rb
+++ b/app/models/event_role.rb
@@ -115,7 +115,11 @@ def to_s
def assigned_to(options = {})
if assigned?
if options[:use_display_name]
- member.display_name
+ if options[:use_both_names]
+ "#{member.display_name} (#{member.fullname})"
+ else
+ member.display_name
+ end
else
member.fullname
end
diff --git a/app/views/members/_form.html.erb b/app/views/members/_form.html.erb
index 08de230a..8e7bafec 100755
--- a/app/views/members/_form.html.erb
+++ b/app/views/members/_form.html.erb
@@ -98,11 +98,16 @@
<%= f.text_field :interests, class: "wide-input" %>
+
+ - <%= f.label :prefers_full_name, "Prefer full name:" %>
+ - <%= f.check_box :prefers_full_name %>
+
+