Commit b55b0cd580a5a8d8065bcbb3d5d66b58e0daf319

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

fixes

app/views/account/_signup_form.html.erb
@@ -117,6 +117,7 @@ @@ -117,6 +117,7 @@
117 data.custom_fields.each(function(field) { 117 data.custom_fields.each(function(field) {
118 html = '<div class="formfieldline">' + 118 html = '<div class="formfieldline">' +
119 '<label class="formlabel" for="profile_data_custom_fields_{#CUSTOM_FIELD_ID#}">{#CUSTOM_FIELD_NAME#}</label>' + 119 '<label class="formlabel" for="profile_data_custom_fields_{#CUSTOM_FIELD_ID#}">{#CUSTOM_FIELD_NAME#}</label>' +
  120 + '<input type="hidden" name="profile_data[custom_fields][{#CUSTOM_FIELD_ID#}[required]" id="profile_data_custom_fields_{#CUSTOM_FIELD_ID#}_required" value="on" />' +
120 '<input type="hidden" name="profile_data[custom_fields][{#CUSTOM_FIELD_ID#}][label]" id="profile_data_custom_fields_{#CUSTOM_FIELD_ID#}_label" value="{#CUSTOM_FIELD_NAME#}" />' + 121 '<input type="hidden" name="profile_data[custom_fields][{#CUSTOM_FIELD_ID#}][label]" id="profile_data_custom_fields_{#CUSTOM_FIELD_ID#}_label" value="{#CUSTOM_FIELD_NAME#}" />' +
121 '<div class="formfield type-text">' + 122 '<div class="formfield type-text">' +
122 '<input type="text" name="profile_data[custom_fields][{#CUSTOM_FIELD_ID#}][value]" id="profile_data_custom_fields_{#CUSTOM_FIELD_ID#}_value" />' + 123 '<input type="text" name="profile_data[custom_fields][{#CUSTOM_FIELD_ID#}][value]" id="profile_data_custom_fields_{#CUSTOM_FIELD_ID#}_value" />' +
app/views/profile_editor/_person_form.html.erb
@@ -78,7 +78,6 @@ @@ -78,7 +78,6 @@
78 <table border="0" style="display: none;"> 78 <table border="0" style="display: none;">
79 <tr> 79 <tr>
80 <th><%= _('Field name') %></th> 80 <th><%= _('Field name') %></th>
81 - <th><%= _('Active') %></th>  
82 <th><%= _('Required') %></th> 81 <th><%= _('Required') %></th>
83 <th><%= _('Display on signup?') %></th> 82 <th><%= _('Display on signup?') %></th>
84 <th>&nbsp;</th> 83 <th>&nbsp;</th>
@@ -90,9 +89,6 @@ @@ -90,9 +89,6 @@
90 <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %> 89 <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %>
91 </td> 90 </td>
92 <td align="center"> 91 <td align="center">
93 - <%= check_box_tag "profile_data[custom_fields][#{key}][active]", value['active'], value['active'], :onclick => "active_action(this, 'profile_data[custom_fields][#{key}][required]', 'profile_data[custom_fields][#{key}][signup]')" %>  
94 - </td>  
95 - <td align="center">  
96 <%= 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]')" %> 92 <%= 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]')" %>
97 </td> 93 </td>
98 <td align="center"> 94 <td align="center">
@@ -118,30 +114,68 @@ @@ -118,30 +114,68 @@
118 114
119 <% else %> 115 <% else %>
120 116
121 - <% Profile.find(@person.template_id).custom_fields.each { |key,value| %> 117 + <% template_custom_fields = Profile.find(@person.template_id).custom_fields %>
  118 +
  119 + <% @person.custom_fields.each { |key,value| %>
  120 +
  121 + <% if template_custom_fields.include?(key) || !value[:value].empty? %>
122 122
123 - <% if value['active'] %>  
124 - <div class="field-with-privacy-selector">  
125 - <div class="formfieldline"> 123 + <% if value[:active] %>
  124 + <div class="field-with-privacy-selector">
  125 + <div class="formfieldline">
126 126
127 - <span style="display: block;">  
128 - <% if value['required'] %>  
129 - <%= label_tag value[:label] + ' (*)', nil, class: 'required' %>  
130 - <% else %>  
131 - <%= label_tag value[:label] %>  
132 - <% end %>  
133 - </span> 127 + <span style="display: block;">
  128 + <% if value[:required] %>
  129 + <%= label_tag value[:label] + ' (*)', nil, class: 'required' %>
  130 + <% else %>
  131 + <%= label_tag value[:label] %>
  132 + <% end %>
  133 + </span>
  134 +
  135 + <div class="formfield type-text" style="display: inline-block;">
  136 + <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %>
  137 + <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>
  138 + </div>
134 139
135 - <div class="formfield type-text" style="display: inline-block;">  
136 - <% valor = @person.custom_fields[key] ? @person.custom_fields[key][value] : "" %>  
137 - <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>  
138 </div> 140 </div>
139 141
  142 + <%= profile_field_privacy_selector @person, key %>
  143 +
140 </div> 144 </div>
  145 + <% end %>
  146 +
  147 + <% end %>
  148 +
  149 + <% } %>
  150 +
  151 + <% template_custom_fields.each { |key,value| %>
  152 +
  153 + <% unless @person.custom_fields.include?(key) %>
  154 +
  155 + <% if value['active'] %>
  156 + <div class="field-with-privacy-selector">
  157 + <div class="formfieldline">
  158 +
  159 + <span style="display: block;">
  160 + <% if value['required'] %>
  161 + <%= label_tag value[:label] + ' (*)', nil, class: 'required' %>
  162 + <% else %>
  163 + <%= label_tag value[:label] %>
  164 + <% end %>
  165 + </span>
141 166
142 - <%= profile_field_privacy_selector @person, key %> 167 + <div class="formfield type-text" style="display: inline-block;">
  168 + <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %>
  169 + <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %>
  170 + </div>
  171 +
  172 + </div>
  173 +
  174 + <%= profile_field_privacy_selector @person, key %>
  175 +
  176 + </div>
  177 + <% end %>
143 178
144 - </div>  
145 <% end %> 179 <% end %>
146 180
147 <% } %> 181 <% } %>
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 + '_active" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][active]" onclick="active_action(this, "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 + '_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">' + 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">' +
68 '</td>' + 65 '</td>' +
69 '<td align="center">' + 66 '<td align="center">' +