diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index b79ee9c..b458401 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -40,4 +40,27 @@ module ProfileHelper end end + def display_custom_field(title, profile, field, force = false) + unless force || profile.may_display_field_to?(field, user) + return + end + value = profile.custom_fields[field][:value] + if !value.blank? + if block_given? + value = yield(value) + end + content_tag('tr', content_tag('td', title, :class => 'field-name') + content_tag('td', value)) + else + '' + end + end + + def display_custom_fields(profile) + fields = [] + profile.custom_fields.each { |key,value| + fields << display_custom_field(value[:label], profile, key) + } + content_tag('tr', content_tag('th', _('Custom Fields'), { :colspan => 2 })) + fields.join.html_safe + end + end diff --git a/app/views/profile/_person_profile.html.erb b/app/views/profile/_person_profile.html.erb index 981b329..41ab9df 100644 --- a/app/views/profile/_person_profile.html.erb +++ b/app/views/profile/_person_profile.html.erb @@ -18,6 +18,8 @@ <% cache_timeout(profile.relationships_cache_key, 4.hours) do %> <%= display_work_info profile %> + <%= display_custom_fields(profile) %> + <%= _('Network')%> @@ -40,4 +42,3 @@ <% end %> - diff --git a/app/views/profile_editor/_person_form.html.erb b/app/views/profile_editor/_person_form.html.erb index efa82cf..30db7b8 100644 --- a/app/views/profile_editor/_person_form.html.erb +++ b/app/views/profile_editor/_person_form.html.erb @@ -116,67 +116,29 @@ <% template_custom_fields = Profile.find(@person.template_id).custom_fields %> - <% @person.custom_fields.each { |key,value| %> - - <% if template_custom_fields.include?(key) || !value[:value].empty? %> - - <% if value[:active] %> -
-
- - - <% if value[:required] %> - <%= label_tag value[:label] + ' (*)', nil, class: 'required' %> - <% else %> - <%= label_tag value[:label] %> - <% end %> - - -
- <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %> - <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %> -
- -
- - <%= profile_field_privacy_selector @person, key %> - -
- <% end %> - - <% end %> - - <% } %> - <% template_custom_fields.each { |key,value| %> - <% unless @person.custom_fields.include?(key) %> +
+
- <% if value['active'] %> -
-
- - - <% if value['required'] %> - <%= label_tag value[:label] + ' (*)', nil, class: 'required' %> - <% else %> - <%= label_tag value[:label] %> - <% end %> - - -
- <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %> - <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %> -
+ + <% if value[:required] %> + <%= label_tag value[:label] + ' (*)', nil, class: 'required' %> + <% else %> + <%= label_tag value[:label] %> + <% end %> + +
+ <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %> + <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>
- <%= profile_field_privacy_selector @person, key %> -
- <% end %> - <% end %> + <%= profile_field_privacy_selector @person, key %> + +
<% } %> -- libgit2 0.21.2