Commit e01734c7a7ff944f128a995b89e7ce709ede05e8

Authored by Francisco Marcelo de Araújo Lima Júnior
1 parent adc5c4e7

fixes

app/helpers/profile_helper.rb
@@ -51,9 +51,10 @@ module ProfileHelper @@ -51,9 +51,10 @@ module ProfileHelper
51 def display_custom_fields(profile) 51 def display_custom_fields(profile)
52 fields = [] 52 fields = []
53 profile.custom_fields.each { |custom_field_key,custom_field_data| 53 profile.custom_fields.each { |custom_field_key,custom_field_data|
54 - fields << display_custom_field(custom_field_data[:title], profile, custom_field_key) 54 + if !profile.fields_privacy.blank? && profile.fields_privacy.include?(custom_field_key)
  55 + fields << display_custom_field(custom_field_data[:title], profile, custom_field_key) if profile.fields_privacy[custom_field_key] == 'public'
  56 + end
55 } 57 }
56 - fields.reject!(&:blank?)  
57 fields.size >= 1 ? content_tag('tr', content_tag('th', _('Custom Fields'), { :colspan => 2 })) + fields.join.html_safe : '' 58 fields.size >= 1 ? content_tag('tr', content_tag('th', _('Custom Fields'), { :colspan => 2 })) + fields.join.html_safe : ''
58 end 59 end
59 60
app/views/profile_editor/_person_form.html.erb
@@ -114,24 +114,50 @@ @@ -114,24 +114,50 @@
114 114
115 <% template_custom_fields.each { |key,value| %> 115 <% template_custom_fields.each { |key,value| %>
116 116
117 - <div class="field-with-privacy-selector">  
118 - <div class="formfieldline"> 117 + <% if @person.custom_fields.include?(key) %>
119 118
120 - <span style="display: block;">  
121 - <%= label_tag value[:label] %>  
122 - </span> 119 + <div class="field-with-privacy-selector">
  120 + <div class="formfieldline">
  121 +
  122 + <span style="display: block;">
  123 + <%= label_tag value[:label] %>
  124 + </span>
  125 +
  126 + <div class="formfield type-text" style="display: inline-block;">
  127 + <%= hidden_field_tag "profile_data[custom_fields][#{key}[title]", @person.custom_fields[key][:title] %>
  128 + <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %>
  129 + <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>
  130 + </div>
  131 +
  132 + </div>
  133 +
  134 + <%= profile_field_privacy_selector @person, key %>
  135 +
  136 + </div>
  137 +
  138 + <% else %>
  139 +
  140 + <div class="field-with-privacy-selector">
  141 + <div class="formfieldline">
  142 +
  143 + <span style="display: block;">
  144 + <%= label_tag value[:label] %>
  145 + </span>
  146 +
  147 + <div class="formfield type-text" style="display: inline-block;">
  148 + <%= hidden_field_tag "profile_data[custom_fields][#{key}[title]", value[:label] %>
  149 + <% valor = key ? value[:value] : "" %>
  150 + <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>
  151 + </div>
123 152
124 - <div class="formfield type-text" style="display: inline-block;">  
125 - <%= hidden_field_tag "profile_data[custom_fields][#{key}[title]", @person.custom_fields[key][:title] %>  
126 - <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %>  
127 - <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>  
128 </div> 153 </div>
129 154
  155 + <%= profile_field_privacy_selector @person, key %>
  156 +
130 </div> 157 </div>
131 158
132 - <%= profile_field_privacy_selector @person, key %>  
133 159
134 - </div> 160 + <% end %>
135 161
136 <% } %> 162 <% } %>
137 163
public/javascripts/manage-custom-fields.js
@@ -61,9 +61,6 @@ function add_new_field() { @@ -61,9 +61,6 @@ function add_new_field() {
61 '<input id="profile_data_custom_fields_custom_field_' + next_custom_field_id + '_label" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][label]" style="display:block" type="text" value="">' + 61 '<input id="profile_data_custom_fields_custom_field_' + next_custom_field_id + '_label" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][label]" style="display:block" type="text" value="">' +
62 '</td>' + 62 '</td>' +
63 '<td align="center">' + 63 '<td align="center">' +
64 - '<input id="profile_data_custom_fields_custom_field_' + next_custom_field_id + '_required" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][required]" onclick="required_action("profile_data[custom_fields][custom_field_' + next_custom_field_id + '][active]","profile_data[custom_fields][custom_field_' + next_custom_field_id + '][required]", "profile_data[custom_fields][custom_field_' + next_custom_field_id + '][signup]")" type="checkbox">' +  
65 - '</td>' +  
66 - '<td align="center">' +  
67 '<input id="profile_data_custom_fields_custom_field_' + next_custom_field_id + '_signup" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][signup]" onclick="signup_action("profile_data[custom_fields][custom_field_' + next_custom_field_id + '][active]","profile_data[custom_fields][custom_field_' + next_custom_field_id + '][required]", "profile_data[custom_fields][custom_field_' + next_custom_field_id + '][signup]")" type="checkbox">' + 64 '<input id="profile_data_custom_fields_custom_field_' + next_custom_field_id + '_signup" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][signup]" onclick="signup_action("profile_data[custom_fields][custom_field_' + next_custom_field_id + '][active]","profile_data[custom_fields][custom_field_' + next_custom_field_id + '][required]", "profile_data[custom_fields][custom_field_' + next_custom_field_id + '][signup]")" type="checkbox">' +
68 '</td>' + 65 '</td>' +
69 '<td align="center">' + 66 '<td align="center">' +