1
0
Fork 0

Add helper method RegionalOfficesHelper#regional_office_link_or_none

This commit is contained in:
Alex Kotov 2019-08-14 17:14:05 +05:00
parent a8e4d46a2e
commit 3db59dee2f
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 15 additions and 10 deletions

View file

@ -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

View file

@ -22,16 +22,7 @@
<dd><%= staff_account_link_or_none @person.account %></dd> <dd><%= staff_account_link_or_none @person.account %></dd>
<dt><%= Person.human_attribute_name :current_regional_office %></dt> <dt><%= Person.human_attribute_name :current_regional_office %></dt>
<dd> <dd><%= regional_office_link_or_none @person.current_regional_office %></dd>
<% 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 %>
</dd>
<dt><%= Person.human_attribute_name :last_name %></dt> <dt><%= Person.human_attribute_name :last_name %></dt>
<dd><%= truncate @person.last_name %></dd> <dd><%= truncate @person.last_name %></dd>