Add method ApplicationHelper#maybe_or_none
This commit is contained in:
parent
ecbcd29338
commit
5a3f8d2a6e
2 changed files with 10 additions and 18 deletions
|
@ -61,6 +61,10 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def maybe_or_none(cond)
|
||||||
|
cond ? yield : none
|
||||||
|
end
|
||||||
|
|
||||||
def bool_badge(value)
|
def bool_badge(value)
|
||||||
if value
|
if value
|
||||||
tag.span class: 'badge badge-pill badge-success' do
|
tag.span class: 'badge badge-pill badge-success' do
|
||||||
|
|
|
@ -13,55 +13,43 @@
|
||||||
<dl>
|
<dl>
|
||||||
<dt><%= Person.human_attribute_name :last_name %></dt>
|
<dt><%= Person.human_attribute_name :last_name %></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<% if @account.person.last_name %>
|
<%= maybe_or_none @account.person.last_name.present? do %>
|
||||||
<%= truncate @account.person.last_name %>
|
<%= truncate @account.person.last_name %>
|
||||||
<% else %>
|
|
||||||
<%= none %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= Person.human_attribute_name :first_name %></dt>
|
<dt><%= Person.human_attribute_name :first_name %></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<% if @account.person.first_name.present? %>
|
<%= maybe_or_none @account.person.first_name.present? do %>
|
||||||
<%= truncate @account.person.first_name %>
|
<%= truncate @account.person.first_name %>
|
||||||
<% else %>
|
|
||||||
<%= none %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= Person.human_attribute_name :middle_name %></dt>
|
<dt><%= Person.human_attribute_name :middle_name %></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<% if @account.person.middle_name.present? %>
|
<%= maybe_or_none @account.person.middle_name.present? do %>
|
||||||
<%= truncate @account.person.middle_name %>
|
<%= truncate @account.person.middle_name %>
|
||||||
<% else %>
|
|
||||||
<%= none %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= Person.human_attribute_name :sex %></dt>
|
<dt><%= Person.human_attribute_name :sex %></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<% if @account.person.sex.present? %>
|
<%= maybe_or_none @account.person.sex.present? do %>
|
||||||
<%= translate_enum :sex, @account.person.sex %>
|
<%= translate_enum :sex, @account.person.sex %>
|
||||||
<% else %>
|
|
||||||
<%= none %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= Person.human_attribute_name :date_of_birth %></dt>
|
<dt><%= Person.human_attribute_name :date_of_birth %></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<% if @account.person.date_of_birth.present? %>
|
<%= maybe_or_none @account.person.date_of_birth.present? do %>
|
||||||
<%= localize @account.person.date_of_birth %>
|
<%= localize @account.person.date_of_birth %>
|
||||||
<% else %>
|
|
||||||
<%= none %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= Person.human_attribute_name :place_of_birth %></dt>
|
<dt><%= Person.human_attribute_name :place_of_birth %></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<% if @account.person.place_of_birth.present? %>
|
<%= maybe_or_none @account.person.place_of_birth.present? do %>
|
||||||
<%= truncate @account.person.place_of_birth %>
|
<%= truncate @account.person.place_of_birth %>
|
||||||
<% else %>
|
|
||||||
<%= none %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
Reference in a new issue