Commit a24518abb0e6ad2ce63ac03f859a241058351223
1 parent
b55b0cd5
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
fixes
Showing
3 changed files
with
40 additions
and
54 deletions
Show diff stats
app/helpers/profile_helper.rb
@@ -40,4 +40,27 @@ module ProfileHelper | @@ -40,4 +40,27 @@ module ProfileHelper | ||
40 | end | 40 | end |
41 | end | 41 | end |
42 | 42 | ||
43 | + def display_custom_field(title, profile, field, force = false) | ||
44 | + unless force || profile.may_display_field_to?(field, user) | ||
45 | + return | ||
46 | + end | ||
47 | + value = profile.custom_fields[field][:value] | ||
48 | + if !value.blank? | ||
49 | + if block_given? | ||
50 | + value = yield(value) | ||
51 | + end | ||
52 | + content_tag('tr', content_tag('td', title, :class => 'field-name') + content_tag('td', value)) | ||
53 | + else | ||
54 | + '' | ||
55 | + end | ||
56 | + end | ||
57 | + | ||
58 | + def display_custom_fields(profile) | ||
59 | + fields = [] | ||
60 | + profile.custom_fields.each { |key,value| | ||
61 | + fields << display_custom_field(value[:label], profile, key) | ||
62 | + } | ||
63 | + content_tag('tr', content_tag('th', _('Custom Fields'), { :colspan => 2 })) + fields.join.html_safe | ||
64 | + end | ||
65 | + | ||
43 | end | 66 | end |
app/views/profile/_person_profile.html.erb
@@ -18,6 +18,8 @@ | @@ -18,6 +18,8 @@ | ||
18 | <% cache_timeout(profile.relationships_cache_key, 4.hours) do %> | 18 | <% cache_timeout(profile.relationships_cache_key, 4.hours) do %> |
19 | <%= display_work_info profile %> | 19 | <%= display_work_info profile %> |
20 | 20 | ||
21 | + <%= display_custom_fields(profile) %> | ||
22 | + | ||
21 | <tr> | 23 | <tr> |
22 | <th colspan='2'><%= _('Network')%></th> | 24 | <th colspan='2'><%= _('Network')%></th> |
23 | </tr> | 25 | </tr> |
@@ -40,4 +42,3 @@ | @@ -40,4 +42,3 @@ | ||
40 | 42 | ||
41 | <% end %> | 43 | <% end %> |
42 | </table> | 44 | </table> |
43 | - |
app/views/profile_editor/_person_form.html.erb
@@ -116,67 +116,29 @@ | @@ -116,67 +116,29 @@ | ||
116 | 116 | ||
117 | <% template_custom_fields = Profile.find(@person.template_id).custom_fields %> | 117 | <% template_custom_fields = Profile.find(@person.template_id).custom_fields %> |
118 | 118 | ||
119 | - <% @person.custom_fields.each { |key,value| %> | ||
120 | - | ||
121 | - <% if template_custom_fields.include?(key) || !value[:value].empty? %> | ||
122 | - | ||
123 | - <% if value[:active] %> | ||
124 | - <div class="field-with-privacy-selector"> | ||
125 | - <div class="formfieldline"> | ||
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> | ||
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> | ||
139 | - | ||
140 | - </div> | ||
141 | - | ||
142 | - <%= profile_field_privacy_selector @person, key %> | ||
143 | - | ||
144 | - </div> | ||
145 | - <% end %> | ||
146 | - | ||
147 | - <% end %> | ||
148 | - | ||
149 | - <% } %> | ||
150 | - | ||
151 | <% template_custom_fields.each { |key,value| %> | 119 | <% template_custom_fields.each { |key,value| %> |
152 | 120 | ||
153 | - <% unless @person.custom_fields.include?(key) %> | 121 | + <div class="field-with-privacy-selector"> |
122 | + <div class="formfieldline"> | ||
154 | 123 | ||
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> | ||
166 | - | ||
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> | 124 | + <span style="display: block;"> |
125 | + <% if value[:required] %> | ||
126 | + <%= label_tag value[:label] + ' (*)', nil, class: 'required' %> | ||
127 | + <% else %> | ||
128 | + <%= label_tag value[:label] %> | ||
129 | + <% end %> | ||
130 | + </span> | ||
171 | 131 | ||
132 | + <div class="formfield type-text" style="display: inline-block;"> | ||
133 | + <% valor = @person.custom_fields[key] ? @person.custom_fields[key][:value] : "" %> | ||
134 | + <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", valor, :size => 30 ) %> | ||
172 | </div> | 135 | </div> |
173 | 136 | ||
174 | - <%= profile_field_privacy_selector @person, key %> | ||
175 | - | ||
176 | </div> | 137 | </div> |
177 | - <% end %> | ||
178 | 138 | ||
179 | - <% end %> | 139 | + <%= profile_field_privacy_selector @person, key %> |
140 | + | ||
141 | + </div> | ||
180 | 142 | ||
181 | <% } %> | 143 | <% } %> |
182 | 144 |