22
33module BetterTogether
44 module ContactDetailsHelper # rubocop:todo Style/Documentation
5- def render_contact_details ( contactable , options = { } )
5+ # rubocop:todo Metrics/MethodLength
6+ def render_contact_details ( contactable , options = { } ) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
67 # Options
78 include_private = options . fetch ( :include_private , false )
89
@@ -23,6 +24,7 @@ def render_contact_details(contactable, options = {})
2324 content << render_addresses ( contact_detail , include_private :)
2425 content
2526 end
27+ # rubocop:enable Metrics/MethodLength
2628
2729 def render_contacts ( contactable , options = { } )
2830 # Options
@@ -34,25 +36,31 @@ def render_contacts(contactable, options = {})
3436
3537 # Render partials for each contact type
3638 content = contacts . map do |contact |
37- content_tag ( :div , class : 'contact mb-3 col' ) do
38- name_and_role = content_tag ( :div , class : 'name-and-role mb-3' ) do
39- name = contact . name . present? ? content_tag ( :strong , contact . name ) : '' . html_safe
40- role = contact . role . present? ? ", #{ content_tag ( :strong , contact . role ) } " . html_safe : '' . html_safe
41- name + role
42- end
43-
44- name_and_role +
45- render_social_media_accounts ( contact , include_private :) +
46- render_website_links ( contact , include_private :) +
47- render_phone_numbers ( contact , include_private :) +
48- render_email_addresses ( contact , include_private :) +
49- render_addresses ( contact , include_private :)
50- end
39+ render_contact ( contact , include_private :)
5140 end
5241
5342 safe_join ( content )
5443 end
5544
45+ # rubocop:todo Metrics/MethodLength
46+ def render_contact ( contact , include_private ) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
47+ content_tag ( :div , class : 'contact mb-3 col' ) do
48+ name_and_role = content_tag ( :div , class : 'name-and-role mb-3' ) do
49+ name = contact . name . present? ? content_tag ( :strong , contact . name ) : '' . html_safe
50+ role = contact . role . present? ? ", #{ content_tag ( :strong , contact . role ) } " . html_safe : '' . html_safe
51+ name + role
52+ end
53+
54+ name_and_role +
55+ render_social_media_accounts ( contact , include_private :) +
56+ render_website_links ( contact , include_private :) +
57+ render_phone_numbers ( contact , include_private :) +
58+ render_email_addresses ( contact , include_private :) +
59+ render_addresses ( contact , include_private :)
60+ end
61+ end
62+ # rubocop:enable Metrics/MethodLength
63+
5664 def render_phone_numbers ( contact_detail , options = { } )
5765 include_private = options . fetch ( :include_private , false )
5866 phone_numbers = contact_detail . phone_numbers
@@ -109,25 +117,18 @@ def render_host_community_social_media_accounts(include_private: false)
109117 end
110118
111119 # rubocop:todo Metrics/MethodLength
112- def social_media_icon_class ( platform ) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength
113- case platform
114- when 'Facebook'
115- 'fab fa-facebook-f'
116- when 'Instagram'
117- 'fab fa-instagram'
118- when 'Bluesky'
119- 'fab fa-bluesky'
120- when 'LinkedIn'
121- 'fab fa-linkedin-in'
122- when 'YouTube'
123- 'fab fa-youtube'
124- when 'TikTok'
125- 'fab fa-tiktok'
126- when 'Reddit'
127- 'fab fa-reddit-alien'
128- when 'WhatsApp'
129- 'fab fa-whatsapp'
130- end
120+ def social_media_icon_class ( platform )
121+ icon_classes = {
122+ 'Facebook' => 'fab fa-facebook-f' ,
123+ 'Instagram' => 'fab fa-instagram' ,
124+ 'Bluesky' => 'fab fa-bluesky' ,
125+ 'LinkedIn' => 'fab fa-linkedin-in' ,
126+ 'YouTube' => 'fab fa-youtube' ,
127+ 'TikTok' => 'fab fa-tiktok' ,
128+ 'Reddit' => 'fab fa-reddit-alien' ,
129+ 'WhatsApp' => 'fab fa-whatsapp'
130+ }
131+ icon_classes [ platform ]
131132 end
132133 # rubocop:enable Metrics/MethodLength
133134
0 commit comments