From 17bfc818c716c7d08d447a15a867ba58f17b2d08 Mon Sep 17 00:00:00 2001 From: maebeale Date: Sat, 6 Jun 2026 23:02:37 -0400 Subject: [PATCH] Widen registrants list and slim states card on event dashboard The four headcount cards were equal width, leaving the registrants list cramped while the short states list had room to spare. Give registrants more horizontal room (and slim states) so longer names fit, and annotate each registrant with their organization names so affiliation is visible at a glance without opening each profile. Co-Authored-By: Claude Opus 4.8 --- app/services/event_dashboard.rb | 17 +++++++++-------- app/views/events/dashboard.html.erb | 17 +++++++++-------- spec/services/event_dashboard_spec.rb | 9 +++++---- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/services/event_dashboard.rb b/app/services/event_dashboard.rb index 37463e6b0..ff9023b56 100644 --- a/app/services/event_dashboard.rb +++ b/app/services/event_dashboard.rb @@ -221,17 +221,18 @@ def organization_registrant_ids @organization_registrant_ids ||= organization_registrant_ids_by_org.values.flat_map(&:to_a).uniq end - # Organization names per registrant id (Person id), for registrant tooltips. - # Built from the same snapshot + active-affiliation data as the organizations - # breakdown, so the names match the Organizations count. + # Organization names per registrant id (Person id), for labeling and tooltips + # in the registrant list. Built from the same snapshot + active-affiliation data + # as the organizations breakdown, so the names match the Organizations count. + # Names are deduped and sorted; registrants with multiple orgs get all of them. def organization_names_by_registrant @organization_names_by_registrant ||= begin - names_by_id = organizations.index_by(&:id) + names_by_org = organizations.index_by(&:id) organization_registrant_ids_by_org.each_with_object(Hash.new { |hash, key| hash[key] = [] }) do |(organization_id, person_ids), map| - organization = names_by_id[organization_id] - next unless organization - person_ids.each { |person_id| map[person_id] << organization.name } - end + name = names_by_org[organization_id]&.name + next unless name + person_ids.each { |person_id| map[person_id] << name } + end.transform_values { |names| names.uniq.sort } end end diff --git a/app/views/events/dashboard.html.erb b/app/views/events/dashboard.html.erb index 1d3829444..d8c155024 100644 --- a/app/views/events/dashboard.html.erb +++ b/app/views/events/dashboard.html.erb @@ -219,8 +219,8 @@ <% end %> <%# Headcount cards — each expands to reveal its full list %> -
-
+
+

@@ -238,10 +238,11 @@ <% if @dashboard.registrants.any? %>
    <% @dashboard.registrants.each do |registrant| %> + <% org_names = @dashboard.organization_names_by_registrant[registrant.id] %>
  • - <%= link_to registrant.name, manage_event_path(@event, registrant_ids: registrant.id), - title: [ registrant.name, *@dashboard.organization_names_by_registrant[registrant.id] ].join(" · "), - class: "block truncate rounded px-1 -mx-1 py-0.5 hover:bg-gray-50" %> + <%= link_to manage_event_path(@event, registrant_ids: registrant.id), class: "block truncate rounded px-1 -mx-1 py-0.5 hover:bg-gray-50", title: [ registrant.name, org_names.present? ? "(#{org_names.join(", ")})" : nil ].compact.join(" ") do %> + <%= registrant.name %><% if org_names.present? %> (<%= org_names.join(", ") %>)<% end %> + <% end %>
  • <% end %>
@@ -251,7 +252,7 @@

-
+

@@ -286,7 +287,7 @@

-
+

@@ -318,7 +319,7 @@

-
+

diff --git a/spec/services/event_dashboard_spec.rb b/spec/services/event_dashboard_spec.rb index df07ed995..a93649311 100644 --- a/spec/services/event_dashboard_spec.rb +++ b/spec/services/event_dashboard_spec.rb @@ -150,10 +150,11 @@ expect(map[org_c.id].to_a).to contain_exactly(person2.id) end - it "maps each registrant id to its organization names (for tooltips)" do - map = dashboard.organization_names_by_registrant - expect(map[person1.id]).to contain_exactly("Alpha Org", "Beta Org") - expect(map[person2.id]).to contain_exactly("Gamma Org") + it "maps each registrant to its organization names, deduped and sorted" do + names = dashboard.organization_names_by_registrant + expect(names[person1.id]).to eq([ "Alpha Org", "Beta Org" ]) + expect(names[person2.id]).to eq([ "Gamma Org" ]) + expect(names).not_to have_key(cancelled_person.id) end end