From 78f9202ee447cc5fe6efd5c72d17aefe20b55c69 Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Wed, 27 Aug 2014 19:03:02 -0300 Subject: [PATCH] minor fixes --- app/controllers/my_profile/profile_editor_controller.rb | 5 ++++- app/views/profile_editor/_person_form.html.erb | 22 ++++++++++++++-------- public/javascripts/manage-custom-fields.js | 10 ++++++---- public/stylesheets/application.css | 10 ++++++++++ 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 3ee21a3..6726aae 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -14,7 +14,10 @@ class ProfileEditorController < MyProfileController @profile_data = profile @possible_domains = profile.possible_domains if request.post? - params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash) + if profile.person? && params[:profile_data].is_a?(Hash) + params[:profile_data][:fields_privacy] ||= {} + params[:profile_data][:custom_fields] ||= {} + end Profile.transaction do Image.transaction do if @profile_data.update_attributes(params[:profile_data]) diff --git a/app/views/profile_editor/_person_form.html.erb b/app/views/profile_editor/_person_form.html.erb index 1ffd150..507b7c4 100644 --- a/app/views/profile_editor/_person_form.html.erb +++ b/app/views/profile_editor/_person_form.html.erb @@ -67,21 +67,21 @@
-

<%= _('Custom fields') %>

-
+

<%= _('Custom fields') %>

+ <% if @person.is_template? %> <%= javascript_include_tag "manage-custom-fields.js" %> - +
- - - - - + + + + + <% @person.custom_fields.each { |key,value| %> @@ -106,6 +106,12 @@
<%= _('Field name') %><%= _('Active') %><%= _('Required') %><%= _('Display on signup?') %> <%= _('Field name') %><%= _('Active') %><%= _('Required') %><%= _('Display on signup?') %> 
+ <% if @person.custom_fields.length > 0 %> + + <% end %> + <%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %> diff --git a/public/javascripts/manage-custom-fields.js b/public/javascripts/manage-custom-fields.js index eb68371..24e619a 100644 --- a/public/javascripts/manage-custom-fields.js +++ b/public/javascripts/manage-custom-fields.js @@ -36,8 +36,9 @@ function signup_action(name_active, name_required, name_signup) { function remove_custom_field(element) { jQuery(element).parent().parent().remove(); - //field = jQuery(element).parent().parent(); - //console.log( field ); + if ( (jQuery('#custom-fields-container tr').length) == 1 ) { + jQuery('#custom-fields-container table').hide(); + } return false; } @@ -45,13 +46,15 @@ function add_new_field() { var next_custom_field_id; var re = /\d+/g; - if ( (jQuery('#custom-fields-container tr').length - 1) == 0 ) { + if ( (jQuery('#custom-fields-container tr').length) == 1 ) { next_custom_field_id = 1; } else { next_custom_field_id = parseInt(re.exec( jQuery('#custom-fields-container input').last().attr('id') )[0]) + 1; } + jQuery('#custom-fields-container table').show(); + new_custom_field = '' + '' + '' + @@ -72,7 +75,6 @@ function add_new_field() { '' jQuery('#custom-fields-container tbody').append(new_custom_field); - } /** diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 34d7d74..6f056c0 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -6609,6 +6609,16 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { color: #c00; } +#custom-fields-container table { + margin-bottom: 5px; + border-bottom: 1px solid #c0c0c0; +} + +#custom-fields-container th { + border-top: 1px solid #c0c0c0; + border-bottom: 1px solid #c0c0c0; +} + #profile_change_picture { clear: both; margin-top: 20px; -- libgit2 0.21.2