Commit 78f9202ee447cc5fe6efd5c72d17aefe20b55c69

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

minor fixes

app/controllers/my_profile/profile_editor_controller.rb
... ... @@ -14,7 +14,10 @@ class ProfileEditorController < MyProfileController
14 14 @profile_data = profile
15 15 @possible_domains = profile.possible_domains
16 16 if request.post?
17   - params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash)
  17 + if profile.person? && params[:profile_data].is_a?(Hash)
  18 + params[:profile_data][:fields_privacy] ||= {}
  19 + params[:profile_data][:custom_fields] ||= {}
  20 + end
18 21 Profile.transaction do
19 22 Image.transaction do
20 23 if @profile_data.update_attributes(params[:profile_data])
... ...
app/views/profile_editor/_person_form.html.erb
... ... @@ -67,21 +67,21 @@
67 67  
68 68 <br />
69 69  
70   -<h2><%= _('Custom fields') %></h2>
71   -
72 70 <div id="custom-fields-container">
73 71  
  72 + <h2><%= _('Custom fields') %></h2>
  73 +
74 74 <% if @person.is_template? %>
75 75  
76 76 <%= javascript_include_tag "manage-custom-fields.js" %>
77 77  
78   - <table border="0">
  78 + <table border="0" style="display: none;">
79 79 <tr>
80   - <th style="border-top: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;"><%= _('Field name') %></th>
81   - <th style="border-top: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;"><%= _('Active') %></th>
82   - <th style="border-top: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;"><%= _('Required') %></th>
83   - <th style="border-top: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;"><%= _('Display on signup?') %></th>
84   - <th style="border-top: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;">&nbsp;</th>
  80 + <th><%= _('Field name') %></th>
  81 + <th><%= _('Active') %></th>
  82 + <th><%= _('Required') %></th>
  83 + <th><%= _('Display on signup?') %></th>
  84 + <th>&nbsp;</th>
85 85 </tr>
86 86  
87 87 <% @person.custom_fields.each { |key,value| %>
... ... @@ -106,6 +106,12 @@
106 106  
107 107 </table>
108 108  
  109 + <% if @person.custom_fields.length > 0 %>
  110 + <script>
  111 + jQuery('#custom-fields-container table').css('display', 'table');
  112 + </script>
  113 + <% end %>
  114 +
109 115 <span>
110 116 <%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %>
111 117 </span>
... ...
public/javascripts/manage-custom-fields.js
... ... @@ -36,8 +36,9 @@ function signup_action(name_active, name_required, name_signup) {
36 36  
37 37 function remove_custom_field(element) {
38 38 jQuery(element).parent().parent().remove();
39   - //field = jQuery(element).parent().parent();
40   - //console.log( field );
  39 + if ( (jQuery('#custom-fields-container tr').length) == 1 ) {
  40 + jQuery('#custom-fields-container table').hide();
  41 + }
41 42 return false;
42 43 }
43 44  
... ... @@ -45,13 +46,15 @@ function add_new_field() {
45 46 var next_custom_field_id;
46 47 var re = /\d+/g;
47 48  
48   - if ( (jQuery('#custom-fields-container tr').length - 1) == 0 ) {
  49 + if ( (jQuery('#custom-fields-container tr').length) == 1 ) {
49 50 next_custom_field_id = 1;
50 51 }
51 52 else {
52 53 next_custom_field_id = parseInt(re.exec( jQuery('#custom-fields-container input').last().attr('id') )[0]) + 1;
53 54 }
54 55  
  56 + jQuery('#custom-fields-container table').show();
  57 +
55 58 new_custom_field = '' +
56 59 '<tr>' +
57 60 '<td>' +
... ... @@ -72,7 +75,6 @@ function add_new_field() {
72 75 '</tr>'
73 76  
74 77 jQuery('#custom-fields-container tbody').append(new_custom_field);
75   -
76 78 }
77 79  
78 80 /**
... ...
public/stylesheets/application.css
... ... @@ -6609,6 +6609,16 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img {
6609 6609 color: #c00;
6610 6610 }
6611 6611  
  6612 +#custom-fields-container table {
  6613 + margin-bottom: 5px;
  6614 + border-bottom: 1px solid #c0c0c0;
  6615 +}
  6616 +
  6617 +#custom-fields-container th {
  6618 + border-top: 1px solid #c0c0c0;
  6619 + border-bottom: 1px solid #c0c0c0;
  6620 +}
  6621 +
6612 6622 #profile_change_picture {
6613 6623 clear: both;
6614 6624 margin-top: 20px;
... ...