Move contact ident description to helper method

This commit is contained in:
Thiago Youssef 2022-03-14 14:46:31 +02:00
parent dd513b6313
commit fd41d77390
8 changed files with 15 additions and 7 deletions

View file

@ -9,6 +9,14 @@ module ApplicationHelper
"background-image: url(#{image_path("#{unstable_env}.png")});" "background-image: url(#{image_path("#{unstable_env}.png")});"
end end
def ident_for(contact)
ident = contact.ident
description = "[#{contact.ident_country_code} #{contact.ident_type}]"
description.prepend("#{ident} ") if ident.present?
description
end
def current_commit_link def current_commit_link
hash = `git rev-parse --short HEAD` hash = `git rev-parse --short HEAD`
current_repo = `git remote get-url origin`.gsub('com:', 'com/') current_repo = `git remote get-url origin`.gsub('com:', 'com/')

View file

@ -69,7 +69,7 @@
%tr %tr
%td= link_to(contact.name, admin_contact_version_path(version.id)) %td= link_to(contact.name, admin_contact_version_path(version.id))
%td= contact.code %td= contact.code
%td= contact.ident_human_description %td= ident_for(contact)
%td %td
- if contact.registrar - if contact.registrar
= link_to(contact.registrar, admin_registrar_path(contact.registrar)) = link_to(contact.registrar, admin_registrar_path(contact.registrar))

View file

@ -22,7 +22,7 @@
%dt= t(:ident) %dt= t(:ident)
%dd{class: changing_css_class(@version,"ident_country_code", "ident_type", "ident")} %dd{class: changing_css_class(@version,"ident_country_code", "ident_type", "ident")}
= contact.ident_human_description = ident_for(contact)
- if contact.email.present? - if contact.email.present?
%dt= t(:email) %dt= t(:email)

View file

@ -100,7 +100,7 @@
%tr %tr
%td= link_to(contact, admin_contact_path(contact)) %td= link_to(contact, admin_contact_path(contact))
%td= contact.code %td= contact.code
%td= contact.ident_human_description %td= ident_for(contact)
%td= contact.email %td= contact.email
%td= l(contact.created_at, format: :short) %td= l(contact.created_at, format: :short)
%td %td

View file

@ -14,7 +14,7 @@
%br %br
%dt.left_25= t(:ident) %dt.left_25= t(:ident)
%dd.left_25= @contact.ident_human_description %dd.left_25= ident_for(@contact)
%dt.left_25= t(:email) %dt.left_25= t(:email)
%dd.left_25= @contact.email %dd.left_25= @contact.email

View file

@ -44,7 +44,7 @@
<%= contact.code %> <%= contact.code %>
</td> </td>
<td> <td>
<%= contact.ident_human_description %> <%= ident_for(contact) %>
</td> </td>
<td> <td>
<%= l(contact.created_at, format: :short) %> <%= l(contact.created_at, format: :short) %>

View file

@ -20,7 +20,7 @@
<tr> <tr>
<td><%= contact %></td> <td><%= contact %></td>
<td><%= contact.code %></td> <td><%= contact.code %></td>
<td><%= contact.ident_human_description %></td> <td><%= ident_for(contact) %></td>
<td><%= l(contact.created_at, format: :short) %></td> <td><%= l(contact.created_at, format: :short) %></td>
<td><%= contact.registrar %></td> <td><%= contact.registrar %></td>
</tr> </tr>

View file

@ -14,7 +14,7 @@
%br %br
%dt= t(:ident) %dt= t(:ident)
%dd= @contact.ident_human_description %dd= ident_for(@contact)
%dt= t(:email) %dt= t(:email)
%dd= @contact.email %dd= @contact.email