Skip to content

Commit cedcc19

Browse files
maebealeclaude
andcommitted
Show primary sector as a starred chip on person profile and search
The person profile split sectors into "Primary sector" / "Additional sectors" columns; the people search table listed them flat. Both now render a single primary-first list reusing the recipients-page chip — the primary sector leads as a darker-green starred chip — so the primary reads the same way everywhere it appears. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 41456c9 commit cedcc19

2 files changed

Lines changed: 19 additions & 35 deletions

File tree

app/views/people/people_results.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@
3737
</td>
3838
<!-- Sectors -->
3939
<td class="px-4 py-2 text-sm text-gray-800">
40-
<% sectors = person.sectorable_items.to_a %>
40+
<% sectors = person.sectorable_items.sort_by { |si| [ si.is_primary? ? 0 : 1, si.sector&.name.to_s.downcase ] } %>
4141
<% if sectors.any? %>
4242
<div class="flex flex-wrap gap-2">
4343
<% sectors.each do |si| %>
4444
<%= render "sectors/tagging_label",
4545
sector: si.sector,
46+
is_primary: si.is_primary?,
4647
display_leader: true,
4748
is_leader: si.is_leader %>
4849
<% end %>

app/views/people/show.html.erb

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -124,44 +124,27 @@
124124
<% end %>
125125
<!-- Sectors -->
126126
<% if @person.profile_show_sectors? %>
127-
<% sectorable_items = @person.sectorable_items.includes(:sector).order("sectors.name") %>
128-
<% primary_sector_items = sectorable_items.select(&:is_primary?) %>
129-
<% additional_sector_items = sectorable_items.reject(&:is_primary?) %>
127+
<%# One combined list: the primary sector leads as a darker-green starred
128+
chip, followed by the additional sectors alphabetically and any
129+
free-text "Other" responses. %>
130+
<% sectorable_items = @person.sectorable_items.includes(:sector).sort_by { |si| [ si.is_primary? ? 0 : 1, si.sector&.name.to_s.downcase ] } %>
130131
<% other_service_areas = @person.other_service_area_responses %>
131132
<div class="md:col-span-2 p-3">
132-
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
133-
<div>
134-
<h2 class="text-lg font-semibold text-gray-800 mb-3">Primary sector</h2>
135-
<% if primary_sector_items.any? || other_service_areas.any? %>
136-
<div class="flex flex-wrap gap-2">
137-
<% primary_sector_items.each do |si| %>
138-
<%= render "sectors/tagging_label",
139-
sector: si.sector,
140-
display_leader: true,
141-
is_leader: si.is_leader %>
142-
<% end %>
143-
<%= render "people/other_responses", responses: other_service_areas %>
144-
</div>
145-
<% else %>
146-
<p class="text-gray-500 italic">None selected.</p>
133+
<h2 class="text-lg font-semibold text-gray-800 mb-3">Sectors</h2>
134+
<% if sectorable_items.any? || other_service_areas.any? %>
135+
<div class="flex flex-wrap gap-2">
136+
<% sectorable_items.each do |si| %>
137+
<%= render "sectors/tagging_label",
138+
sector: si.sector,
139+
is_primary: si.is_primary?,
140+
display_leader: true,
141+
is_leader: si.is_leader %>
147142
<% end %>
143+
<%= render "people/other_responses", responses: other_service_areas %>
148144
</div>
149-
<div>
150-
<h2 class="text-lg font-semibold text-gray-800 mb-3">Additional sectors</h2>
151-
<% if additional_sector_items.any? %>
152-
<div class="flex flex-wrap gap-2">
153-
<% additional_sector_items.each do |si| %>
154-
<%= render "sectors/tagging_label",
155-
sector: si.sector,
156-
display_leader: true,
157-
is_leader: si.is_leader %>
158-
<% end %>
159-
</div>
160-
<% else %>
161-
<p class="text-gray-500 italic">None selected.</p>
162-
<% end %>
163-
</div>
164-
</div>
145+
<% else %>
146+
<p class="text-gray-500 italic">None selected.</p>
147+
<% end %>
165148
</div>
166149
<% end %>
167150
</div>

0 commit comments

Comments
 (0)