Commit 5d6ae4ae86f9898c1091f3cf2f2482b3568ed41c
1 parent
e01734c7
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
fixes
Showing
5 changed files
with
37 additions
and
95 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -67,7 +67,7 @@ class AccountController < ApplicationController |
67 | 67 | |
68 | 68 | def custom_fields_for_template |
69 | 69 | custom_fields ||= environment.people.templates.find(params[:template_id]).custom_fields.map { |k,v| |
70 | - { :name => k, :label => v[:label] } if v['signup'] | |
70 | + { :name => k, :title => v[:title] } if v['signup'] | |
71 | 71 | }.compact |
72 | 72 | render :text => {:ok => true, :custom_fields => custom_fields}.to_json |
73 | 73 | end | ... | ... |
app/models/profile.rb
... | ... | @@ -25,8 +25,26 @@ class Profile < ActiveRecord::Base |
25 | 25 | |
26 | 26 | settings_items :custom_fields, :default => {} |
27 | 27 | |
28 | - def custom_field_value(key) | |
29 | - self.custom_fields[key] | |
28 | + def custom_field_value(field) | |
29 | + self.custom_fields[field][:value] | |
30 | + end | |
31 | + | |
32 | + def custom_field_title(field) | |
33 | + if !self.custom_fields.blank? | |
34 | + self.custom_fields[field][:title] | |
35 | + else | |
36 | + '' | |
37 | + end | |
38 | + end | |
39 | + | |
40 | + def custom_fields_template | |
41 | + fields = {} | |
42 | + fields = self.template.custom_fields unless self.template.blank? | |
43 | + fields | |
44 | + end | |
45 | + | |
46 | + def custom_fields_template_title(field) | |
47 | + self.template.custom_fields[field][:title] | |
30 | 48 | end |
31 | 49 | |
32 | 50 | def self.default_search_display | ... | ... |
app/views/account/_signup_form.html.erb
... | ... | @@ -124,7 +124,7 @@ |
124 | 124 | '</div>'; |
125 | 125 | |
126 | 126 | html = html.replace( /{#CUSTOM_FIELD_ID#}/g, field.name ); |
127 | - html = html.replace( /{#CUSTOM_FIELD_NAME#}/g, field.label ); | |
127 | + html = html.replace( /{#CUSTOM_FIELD_NAME#}/g, field.title ); | |
128 | 128 | jQuery('div#signup-form-profile').append(html); |
129 | 129 | }); |
130 | 130 | }; | ... | ... |
app/views/profile_editor/_person_form.html.erb
... | ... | @@ -82,13 +82,13 @@ |
82 | 82 | <th> </th> |
83 | 83 | </tr> |
84 | 84 | |
85 | - <% @person.custom_fields.each { |key,value| %> | |
85 | + <% @person.custom_fields.each { |field,value| %> | |
86 | 86 | <tr> |
87 | 87 | <td> |
88 | - <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %> | |
88 | + <%= text_field_tag( "profile_data[custom_fields][#{field}][title]", value[:title], :style => "display:block") %> | |
89 | 89 | </td> |
90 | 90 | <td align="center"> |
91 | - <%= 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]')" %> | |
91 | + <%= check_box_tag "profile_data[custom_fields][#{field}][signup]", value['signup'], value['signup'], :onclick => "signup_action('profile_data[custom_fields][#{field}][active]','profile_data[custom_fields][#{field}][required]', 'profile_data[custom_fields][#{field}][signup]')" %> | |
92 | 92 | </td> |
93 | 93 | <td align="center"> |
94 | 94 | <%= link_to content_tag(:span, _('Delete')), '#', onclick: "return remove_custom_field(this);", title: "Delete", class: "button icon-delete" %> |
... | ... | @@ -110,54 +110,25 @@ |
110 | 110 | |
111 | 111 | <% else %> |
112 | 112 | |
113 | - <% template_custom_fields = Profile.find(@person.template_id).custom_fields %> | |
113 | + <% @person.custom_fields_template.each { |field,value| %> | |
114 | 114 | |
115 | - <% template_custom_fields.each { |key,value| %> | |
115 | + <div class="field-with-privacy-selector"> | |
116 | + <div class="formfieldline"> | |
116 | 117 | |
117 | - <% if @person.custom_fields.include?(key) %> | |
118 | - | |
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> | |
118 | + <span style="display: block;"> | |
119 | + <%= label_tag @person.custom_fields_template_title(field) %> | |
120 | + </span> | |
131 | 121 | |
122 | + <div class="formfield type-text" style="display: inline-block;"> | |
123 | + <%= hidden_field_tag "profile_data[custom_fields][#{field}[title]", @person.custom_fields_template_title(field) %> | |
124 | + <%= text_field_tag( "profile_data[custom_fields][#{field}][value]", @person.custom_field_value(field), :size => 30 ) %> | |
132 | 125 | </div> |
133 | 126 | |
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> | |
152 | - | |
153 | - </div> | |
154 | - | |
155 | - <%= profile_field_privacy_selector @person, key %> | |
156 | - | |
157 | 127 | </div> |
158 | 128 | |
129 | + <%= profile_field_privacy_selector @person, field %> | |
159 | 130 | |
160 | - <% end %> | |
131 | + </div> | |
161 | 132 | |
162 | 133 | <% } %> |
163 | 134 | ... | ... |
public/javascripts/manage-custom-fields.js
... | ... | @@ -58,7 +58,7 @@ function add_new_field() { |
58 | 58 | new_custom_field = '' + |
59 | 59 | '<tr>' + |
60 | 60 | '<td>' + |
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 + '_title" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][title]" style="display:block" type="text" value="">' + | |
62 | 62 | '</td>' + |
63 | 63 | '<td align="center">' + |
64 | 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">' + |
... | ... | @@ -70,50 +70,3 @@ function add_new_field() { |
70 | 70 | |
71 | 71 | jQuery('#custom-fields-container tbody').append(new_custom_field); |
72 | 72 | } |
73 | - | |
74 | -/** | |
75 | -jQuery(document).ready(function(){ | |
76 | - function check_fields(check, table_id, start) { | |
77 | - var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") | |
78 | - for (var i = start; i < checkboxes.length; i+=3) { | |
79 | - checkboxes[i].checked = check | |
80 | - } | |
81 | - } | |
82 | - | |
83 | - function verify_checked(fields_id){ | |
84 | - var checkboxes = jQuery("#" + fields_id + "_fields_conf tbody tr td input[type='checkbox']") | |
85 | - for (var i = 2; i >= 0; i--) { | |
86 | - var allchecked = true | |
87 | - for (var j = i+3; j < checkboxes.length; j+=3) { | |
88 | - if(!checkboxes[j].checked) { | |
89 | - allchecked = false | |
90 | - break | |
91 | - } | |
92 | - } | |
93 | - | |
94 | - var checkbox = jQuery(checkboxes[i+3]).attr("id").split("_") | |
95 | - jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", allchecked) | |
96 | - } | |
97 | - } | |
98 | - | |
99 | - function check_all(fields_id) { | |
100 | - jQuery("#" + fields_id + "_active").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 0)}) | |
101 | - jQuery("#" + fields_id + "_required").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 1)}) | |
102 | - jQuery("#" + fields_id +"_signup").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 2)}) | |
103 | - verify_checked(fields_id) | |
104 | - } | |
105 | - | |
106 | - //check_all("person") | |
107 | - //check_all("enterprise") | |
108 | - //check_all("community") | |
109 | - | |
110 | - jQuery("input[type='checkbox']").click(function (){ | |
111 | - var checkbox = jQuery(this).attr("id").split("_") | |
112 | - verify_checked(checkbox.first()) | |
113 | - | |
114 | - if(this.checked == false) { | |
115 | - jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false) | |
116 | - } | |
117 | - }) | |
118 | -}) | |
119 | -**/ | ... | ... |