diff --git a/app/helpers/regional_offices_helper.rb b/app/helpers/regional_offices_helper.rb new file mode 100644 index 0000000..8567902 --- /dev/null +++ b/app/helpers/regional_offices_helper.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module RegionalOfficesHelper + def regional_office_link_or_none(regional_office) + if regional_office.nil? + translate :none + elsif policy(regional_office.federal_subject).show? + link_to regional_office.federal_subject.display_name, + regional_office.federal_subject + else + regional_office.federal_subject.display_name + end + end +end diff --git a/app/views/staffs/people/show.html.erb b/app/views/staffs/people/show.html.erb index 9a2453e..18ab878 100644 --- a/app/views/staffs/people/show.html.erb +++ b/app/views/staffs/people/show.html.erb @@ -22,16 +22,7 @@
<%= staff_account_link_or_none @person.account %>
<%= Person.human_attribute_name :current_regional_office %>
-
- <% if @person.current_regional_office %> - <%= link_to( - @person.current_regional_office.federal_subject.display_name, - @person.current_regional_office.federal_subject, - ) %> - <% else %> - <%= translate :none %> - <% end %> -
+
<%= regional_office_link_or_none @person.current_regional_office %>
<%= Person.human_attribute_name :last_name %>
<%= truncate @person.last_name %>