From adc5c4e7cb5b80a7fb0882265aa8b369eab2020c Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Tue, 2 Sep 2014 19:35:21 -0300 Subject: [PATCH] fixes --- app/helpers/profile_helper.rb | 16 +++++----------- app/views/account/_signup_form.html.erb | 3 +-- app/views/profile_editor/_person_form.html.erb | 13 +++---------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index b458401..014968d 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -45,22 +45,16 @@ module ProfileHelper 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 + !value.blank? ? content_tag('tr', content_tag('td', title) + content_tag('td', value)) : '' end def display_custom_fields(profile) fields = [] - profile.custom_fields.each { |key,value| - fields << display_custom_field(value[:label], profile, key) + profile.custom_fields.each { |custom_field_key,custom_field_data| + fields << display_custom_field(custom_field_data[:title], profile, custom_field_key) } - content_tag('tr', content_tag('th', _('Custom Fields'), { :colspan => 2 })) + fields.join.html_safe + fields.reject!(&:blank?) + fields.size >= 1 ? content_tag('tr', content_tag('th', _('Custom Fields'), { :colspan => 2 })) + fields.join.html_safe : '' end end diff --git a/app/views/account/_signup_form.html.erb b/app/views/account/_signup_form.html.erb index 6817d1e..dd6c426 100644 --- a/app/views/account/_signup_form.html.erb +++ b/app/views/account/_signup_form.html.erb @@ -117,8 +117,7 @@ data.custom_fields.each(function(field) { html = '
' + '' + - '' + - '' + + '' + '
' + '' + '
' + diff --git a/app/views/profile_editor/_person_form.html.erb b/app/views/profile_editor/_person_form.html.erb index 30db7b8..39f66a9 100644 --- a/app/views/profile_editor/_person_form.html.erb +++ b/app/views/profile_editor/_person_form.html.erb @@ -77,8 +77,7 @@ - - + @@ -89,9 +88,6 @@ <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %> -
<%= _('Field name') %><%= _('Required') %><%= _('Field name') %> <%= _('Display on signup?') %>  
- <%= check_box_tag "profile_data[custom_fields][#{key}][required]", value['required'], value['required'], :onclick => "required_action('profile_data[custom_fields][#{key}][active]','profile_data[custom_fields][#{key}][required]', 'profile_data[custom_fields][#{key}][signup]')" %> - <%= check_box_tag "profile_data[custom_fields][#{key}][signup]", value['signup'], value['signup'], :onclick => "signup_action('profile_data[custom_fields][#{key}][active]','profile_data[custom_fields][#{key}][required]', 'profile_data[custom_fields][#{key}][signup]')" %> @@ -122,14 +118,11 @@
- <% if value[:required] %> - <%= label_tag value[:label] + ' (*)', nil, class: 'required' %> - <% else %> - <%= label_tag value[:label] %> - <% end %> + <%= label_tag value[:label] %>
+ <%= hidden_field_tag "profile_data[custom_fields][#{key}[title]", @person.custom_fields[key][:title] %> <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %> <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>
-- libgit2 0.21.2