Commit d53d8b6993b16282a29ca2e1573023261f8b4858
1 parent
268df602
Exists in
master
and in
29 other branches
profile-helper: refactor display_contact and add html-safe to string concatenation
Also removing trailing whitespaces
Showing
2 changed files
with
10 additions
and
9 deletions
Show diff stats
app/helpers/profile_helper.rb
@@ -16,16 +16,17 @@ module ProfileHelper | @@ -16,16 +16,17 @@ module ProfileHelper | ||
16 | end | 16 | end |
17 | 17 | ||
18 | def display_contact(profile) | 18 | def display_contact(profile) |
19 | - address = display_field(_('Address:'), profile, :address) | ||
20 | - zip = display_field(_('ZIP code:'), profile, :zip_code) | ||
21 | - phone = display_field(_('Contact phone:'), profile, :contact_phone) | ||
22 | - email = display_field(_('e-Mail:'), profile, :email) { |email| link_to_email(email) } | ||
23 | - personal_website = display_field(_('Personal website:'), profile, :personal_website) | ||
24 | - jabber = display_field(_('Jabber:'), profile, :jabber_id) | ||
25 | - if address.blank? && zip.blank? && phone.blank? && email.blank? && personal_website.blank? && jabber.blank? | 19 | + fields = [] |
20 | + fields << display_field(_('Address:'), profile, :address).html_safe | ||
21 | + fields << display_field(_('ZIP code:'), profile, :zip_code).html_safe | ||
22 | + fields << display_field(_('Contact phone:'), profile, :contact_phone).html_safe | ||
23 | + fields << display_field(_('e-Mail:'), profile, :email) { |email| link_to_email(email) }.html_safe | ||
24 | + fields << display_field(_('Personal website:'), profile, :personal_website).html_safe | ||
25 | + fields << display_field(_('Jabber:'), profile, :jabber_id).html_safe | ||
26 | + if fields.reject!(&:blank?).empty? | ||
26 | '' | 27 | '' |
27 | else | 28 | else |
28 | - content_tag('tr', content_tag('th', _('Contact'), { :colspan => 2 })) + address + zip + phone + email + personal_website + jabber | 29 | + content_tag('tr', content_tag('th', _('Contact'), { :colspan => 2 })) + fields.join.html_safe |
29 | end | 30 | end |
30 | end | 31 | end |
31 | 32 |
app/models/person.rb
@@ -158,7 +158,7 @@ class Person < Profile | @@ -158,7 +158,7 @@ class Person < Profile | ||
158 | district | 158 | district |
159 | zip_code | 159 | zip_code |
160 | address | 160 | address |
161 | - address_reference | 161 | + address_reference |
162 | cell_phone | 162 | cell_phone |
163 | comercial_phone | 163 | comercial_phone |
164 | personal_website | 164 | personal_website |