diff --git a/app/controllers/admin/features_controller.rb b/app/controllers/admin/features_controller.rb index fc48752..8de1440 100644 --- a/app/controllers/admin/features_controller.rb +++ b/app/controllers/admin/features_controller.rb @@ -17,24 +17,17 @@ class FeaturesController < AdminController def manage_fields @person_fields = Person.fields - @custom_person_fields = (@environment.settings[:custom_person_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } - @enterprise_fields = Enterprise.fields - @custom_enterprise_fields = (@environment.settings[:custom_enterprise_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } - @community_fields = Community.fields - @custom_community_fields = (@environment.settings[:custom_community_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } end def manage_person_fields environment.custom_person_fields = params[:person_fields] - if environment.save! session[:notice] = _('Person fields updated successfully.') else flash[:error] = _('Person fields not updated successfully.') end - redirect_to :action => 'manage_fields' end diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 0ee1bec..3ee21a3 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -11,9 +11,6 @@ class ProfileEditorController < MyProfileController # edits the profile info (posts back) def edit - - #raise params.inspect - @profile_data = profile @possible_domains = profile.possible_domains if request.post? diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 946a626..25d15f8 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -66,10 +66,9 @@ class AccountController < ApplicationController end def custom_fields_for_template - custom_fields ||= environment.people.templates.find(params[:template_id]).custom_fields.map {|k,v| - { :name => k, :label => v[:label] } - } - + custom_fields ||= environment.people.templates.find(params[:template_id]).custom_fields.map { |k,v| + { :name => k, :label => v[:label] } if v['signup'] + }.compact render :text => {:ok => true, :custom_fields => custom_fields}.to_json end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0d41a64..5a9e7b2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -809,12 +809,6 @@ module ApplicationHelper form_for(name, { :builder => NoosferoFormBuilder }.merge(options), &proc) end - def optional_custom_field(profile) - result = "" - - result - end - def optional_field(profile, name, field_html = nil, only_required = false, &block) result = "" diff --git a/app/models/environment.rb b/app/models/environment.rb index 23642ce..50061c8 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -429,9 +429,7 @@ class Environment < ActiveRecord::Base schooling_status = values['schooling'] end - self.settings[:custom_person_fields] = values.delete_if { |key, value| - ! ( Person.fields.include?(key) || key =~ /^custom_field/ ) - } + self.settings[:custom_person_fields] = values.delete_if { |key, value| ! Person.fields.include?(key)} self.settings[:custom_person_fields].each_pair do |key, value| if value['required'] == 'true' self.settings[:custom_person_fields][key]['active'] = 'true' @@ -447,16 +445,6 @@ class Environment < ActiveRecord::Base end end - def custom_person_fields_customs() - custom_fields = [] - self.settings[:custom_person_fields].each{ |k,v| custom_fields << k if k =~ /^custom_field/ } - custom_fields - end - - def custom_person_field_name(field) - self.settings[:custom_person_fields][field]['name'] - end - def custom_person_field(field, status) if (custom_person_fields[field] && custom_person_fields[field][status] == 'true') return true @@ -497,7 +485,7 @@ class Environment < ActiveRecord::Base end def custom_enterprise_fields=(values) - self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! ( Enterprise.fields.include?(key) || key =~ /^custom_field/ ) } + self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! Enterprise.fields.include?(key)} self.settings[:custom_enterprise_fields].each_pair do |key, value| if value['required'] == 'true' self.settings[:custom_enterprise_fields][key]['active'] = 'true' @@ -509,16 +497,6 @@ class Environment < ActiveRecord::Base end end - def custom_enterprise_fields_customs() - custom_fields = [] - self.settings[:custom_enterprise_fields].each{ |k,v| custom_fields << k if k =~ /^custom_field/ } - custom_fields - end - - def custom_enterprise_field_name(field) - self.settings[:custom_enterprise_fields][field]['name'] - end - def custom_enterprise_field(field, status) if (custom_enterprise_fields[field] && custom_enterprise_fields[field][status] == 'true') return true @@ -549,13 +527,8 @@ class Environment < ActiveRecord::Base def custom_community_fields self.settings[:custom_community_fields].nil? ? {} : self.settings[:custom_community_fields] end - def custom_community_fields=(values) - self.settings[:custom_community_fields] = values.delete_if { |key, value| - ! ( Community.fields.include?(key) || key =~ /^custom_field/ ) - } - - + self.settings[:custom_community_fields] = values.delete_if { |key, value| ! Community.fields.include?(key) } self.settings[:custom_community_fields].each_pair do |key, value| if value['required'] == 'true' self.settings[:custom_community_fields][key]['active'] = 'true' @@ -567,16 +540,6 @@ class Environment < ActiveRecord::Base end end - def custom_community_fields_customs() - custom_fields = [] - self.settings[:custom_community_fields].each{ |k,v| custom_fields << k if k =~ /^custom_field/ } - custom_fields - end - - def custom_community_field_name(field) - self.settings[:custom_community_fields][field]['name'] - end - def custom_community_field(field, status) if (custom_community_fields[field] && custom_community_fields[field][status] == 'true') return true diff --git a/app/models/organization.rb b/app/models/organization.rb index d1d6558..e0a3eb1 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,7 +1,7 @@ # Represents any organization of the system class Organization < Profile - attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name, :enable_contact_us #, :custom_fields + attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name, :enable_contact_us SEARCH_FILTERS += %w[ more_popular @@ -13,12 +13,6 @@ class Organization < Profile closed end - #settings_items :custom_fields - - #def custom_field_value(field) - # self.custom_fields[field] - #end - before_save do |organization| organization.closed = true if !organization.public_profile? end diff --git a/app/models/person.rb b/app/models/person.rb index 5851379..6e534d0 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,7 +1,7 @@ # A person is the profile of an user holding all relationships with the rest of the system class Person < Profile - attr_accessible :organization, :contact_information, :sex, :birth_date, :cell_phone, :comercial_phone, :jabber_id, :personal_website, :nationality, :address_reference, :district, :schooling, :schooling_status, :formation, :custom_formation, :area_of_study, :custom_area_of_study, :professional_activity, :organization_website #, :custom_fields + attr_accessible :organization, :contact_information, :sex, :birth_date, :cell_phone, :comercial_phone, :jabber_id, :personal_website, :nationality, :address_reference, :district, :schooling, :schooling_status, :formation, :custom_formation, :area_of_study, :custom_area_of_study, :professional_activity, :organization_website SEARCH_FILTERS += %w[ more_popular @@ -205,12 +205,6 @@ class Person < Profile N_('Contact information'); N_('City'); N_('State'); N_('Country'); N_('Sex'); N_('Zip code'); N_('District'); N_('Address reference') settings_items :photo, :contact_information, :sex, :city, :state, :country, :zip_code, :district, :address_reference - #settings_items :custom_fields - - #def custom_field_value(field) - # self.custom_fields[field] - #end - extend SetProfileRegionFromCityState::ClassMethods set_profile_region_from_city_state diff --git a/app/views/features/_manage_community_fields.html.erb b/app/views/features/_manage_community_fields.html.erb index 5c5d24f..9cb0ebe 100644 --- a/app/views/features/_manage_community_fields.html.erb +++ b/app/views/features/_manage_community_fields.html.erb @@ -12,73 +12,46 @@ <%= _("Check/Uncheck All")%> - + - + - + -   <% @community_fields.each do |field| %> - - <%= hidden_field_tag "community_fields[#{field}][active]", false %> - <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "active_action(this, 'community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> - - - <%= hidden_field_tag "community_fields[#{field}][required]", false %> - <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "required_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> - - - <%= hidden_field_tag "community_fields[#{field}][signup]", false %> - <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "signup_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> - - - <% end %> - <% @custom_community_fields.each do |field| %> - - <%= text_field_tag "community_fields[#{field}][name]", environment.custom_community_field_name(field) %> - - <%= hidden_field_tag "community_fields[#{field}][active]", false %> <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "active_action(this, 'community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> - + <%= hidden_field_tag "community_fields[#{field}][required]", false %> <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "required_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> - - <%= hidden_field_tag "community_fields[#{field}][signup]", false %> - <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "required_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> - - Delete + <%= hidden_field_tag "community_fields[#{field}][signup]", false %> + <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "signup_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %> + <% end %> - -
- -<%= link_to_function(_('Add field'), "add_new_field('community');", :class => 'button icon-add with-text') %> -
diff --git a/app/views/features/_manage_enterprise_fields.html.erb b/app/views/features/_manage_enterprise_fields.html.erb index 93b963a..a8840bb 100644 --- a/app/views/features/_manage_enterprise_fields.html.erb +++ b/app/views/features/_manage_enterprise_fields.html.erb @@ -12,13 +12,13 @@ <%= _("Check/Uncheck All")%> - + - + - + @@ -27,59 +27,31 @@ - + <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "active_action(this, 'enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> - + <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required'), :onclick => "required_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> - + <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> <%= check_box_tag "enterprise_fields[#{field}][signup]", true, environment.custom_enterprise_field(field, 'signup'), :onclick => "signup_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> <% end %> - - <% @custom_enterprise_fields.each do |field| %> - - - <%= text_field_tag "enterprise_fields[#{field}][name]", environment.custom_enterprise_field_name(field) %> - - - <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> - <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "active_action(this, 'enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> - - - <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> - <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required'), :onclick => "required_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> - - - <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> - <%= check_box_tag "enterprise_fields[#{field}][signup]", true, environment.custom_enterprise_field(field, 'signup'), :onclick => "required_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %> - - - Delete - - - <% end %> - -
- -<%= link_to_function(_('Add field'), "add_new_field('enterprise');", :class => 'button icon-add with-text') %> -
diff --git a/app/views/features/_manage_person_fields.html.erb b/app/views/features/_manage_person_fields.html.erb index 8c5b43d..1d6eddf 100644 --- a/app/views/features/_manage_person_fields.html.erb +++ b/app/views/features/_manage_person_fields.html.erb @@ -1,88 +1,56 @@ <%= labelled_form_for(:environment, :url => {:action => 'manage_person_fields'}) do |f| %> - +
- - - - - <% @person_fields.each do |field| %> - - - - - - <% end %> - - <% @custom_person_fields.each do |field| %> - - - - <% end %> -
<%= _('Field') %> <%= _('Active') %> <%= _('Required') %> <%= _('Display on signup?') %> 
<%= _("Check/Uncheck All")%> + + +  
- <%= hidden_field_tag "person_fields[#{field}][active]", false %> - <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "active_action(this, 'person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> - - <%= hidden_field_tag "person_fields[#{field}][required]", false %> - <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required'), :onclick => "required_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> - - <%= hidden_field_tag "person_fields[#{field}][signup]", false %> - <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "signup_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> -  
- <%= text_field_tag "person_fields[#{field}][name]", environment.custom_person_field_name(field) %> - <%= hidden_field_tag "person_fields[#{field}][active]", false %> <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "active_action(this, 'person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> + <%= hidden_field_tag "person_fields[#{field}][required]", false %> <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required'), :onclick => "required_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> - <%= hidden_field_tag "person_fields[#{field}][signup]", false %> - <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "required_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %> - - Delete + <%= hidden_field_tag "person_fields[#{field}][signup]", false %> + <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "signup_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %>
-
- -<%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %> - - diff --git a/app/views/profile_editor/_organization.html.erb b/app/views/profile_editor/_organization.html.erb index 7b47b3a..bd5162e 100644 --- a/app/views/profile_editor/_organization.html.erb +++ b/app/views/profile_editor/_organization.html.erb @@ -60,12 +60,8 @@
<% end %> -
- <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'profile_data', :profile => @profile } %> -
- <%= labelled_check_box(_('Enable "contact us"'), 'profile_data[enable_contact_us]', "1", @profile.enable_contact_us) if @profile.enterprise? %> <%= render :partial => 'moderation', :locals => { :profile => @profile } %> diff --git a/app/views/profile_editor/_person_form.html.erb b/app/views/profile_editor/_person_form.html.erb index bc3771a..1ffd150 100644 --- a/app/views/profile_editor/_person_form.html.erb +++ b/app/views/profile_editor/_person_form.html.erb @@ -69,27 +69,79 @@

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

-<%= javascript_include_tag "manage-fields.js" %> - -
-<% @person.custom_fields.each { |key,value| %> -
-
- <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %> -
- <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", "", :size => 30 ) %> -
- Delete - -
-
-<% } %> -
+
+ + <% if @person.is_template? %> + + <%= javascript_include_tag "manage-custom-fields.js" %> + + + + + + + + + + + <% @person.custom_fields.each { |key,value| %> + + + + + + + + <% } %> + +
<%= _('Field name') %><%= _('Active') %><%= _('Required') %><%= _('Display on signup?') %> 
+ <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %> + + <%= 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]')" %> + + <%= 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]')" %> + + <%= 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]')" %> + + <%= link_to content_tag(:span, _('Delete')), '#', onclick: "return remove_custom_field(this);", title: "Delete", class: "button icon-delete" %> +
-<% if @person.is_template? %> <%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %> -<% end %> -

+ <% else %> + + <% Profile.find(@person.template_id).custom_fields.each { |key,value| %> + + <% if value['active'] %> +
+
+ + + <% if value['required'] %> + <%= label_tag value[:label] + ' (*)', nil, class: 'required' %> + <% else %> + <%= label_tag value[:label] %> + <% end %> + + +
+ <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", @person.custom_fields[key][:value], :size => 30 ) %> +
+ +
+ +
+ + +
+ +
+ <% end %> + + <% } %> + + <% end %> + +
diff --git a/app/views/profile_editor/edit.html.erb b/app/views/profile_editor/edit.html.erb index 40cd35d..abef586 100644 --- a/app/views/profile_editor/edit.html.erb +++ b/app/views/profile_editor/edit.html.erb @@ -10,12 +10,8 @@
<% end %> -
- <%= render :partial => partial_for_class(@profile.class), :locals => { :f => f } %> -
-

<%= _('Change picture') %>

<%= unchangeable_privacy_field @profile %> diff --git a/app/views/shared/_organization_custom_fields.html.erb b/app/views/shared/_organization_custom_fields.html.erb index 40ee8e1..5b19eb8 100644 --- a/app/views/shared/_organization_custom_fields.html.erb +++ b/app/views/shared/_organization_custom_fields.html.erb @@ -30,22 +30,3 @@ <%= optional_field(profile, 'foundation_year', f.text_field(:foundation_year)) %> <% end %> <%= javascript_include_tag('city_state_validation') %> - -
- -<% if profile.community? %> - - <% @environment.custom_community_fields_customs.each { |key| %> - <% #raise @environment.custom_community_fields_customs.inspect %> - <% optional_field(profile, key) do %> -
- <%= label_tag environment.custom_community_field_name(key), nil, class: 'formlabel' %> -
- <%= text_field_tag("profile_data[custom_fields][#{key}]", profile.custom_field_value(key)) %> -
-
- <% end %> - <% } %> -<% end %> - -
diff --git a/public/javascripts/manage-custom-fields.js b/public/javascripts/manage-custom-fields.js new file mode 100644 index 0000000..eb68371 --- /dev/null +++ b/public/javascripts/manage-custom-fields.js @@ -0,0 +1,123 @@ +function update_active(name_active, name_required, name_signup) { + var required = jQuery("input[name='" + name_required + "']")[0] + var signup = jQuery("input[name='" + name_signup + "']")[0] + var active = jQuery("input[name='" + name_active + "']")[0] + + if(required.checked || signup.checked) + active.checked = true +} + +function active_action(obj_active, name_required, name_signup) { + var required = jQuery("input[name='" + name_required + "']")[0] + var signup = jQuery("input[name='" + name_signup + "']")[0] + + required.disabled = signup.disabled = !obj_active.checked +} + +function required_action(name_active, name_required, name_signup) { + var obj_required = jQuery("input[name='" + name_required + "']")[0] + + if(obj_required.checked) { + jQuery("input[name='" + name_signup + "']")[0].checked = true + } + + update_active(name_active, name_required, name_signup) +} + +function signup_action(name_active, name_required, name_signup) { + var obj_signup = jQuery("input[name='" + name_signup + "']")[0] + + if(!obj_signup.checked) { + jQuery("input[name='" + name_required + "']")[0].checked = false + } + + update_active(name_active, name_required, name_signup) +} + +function remove_custom_field(element) { + jQuery(element).parent().parent().remove(); + //field = jQuery(element).parent().parent(); + //console.log( field ); + return false; +} + +function add_new_field() { + var next_custom_field_id; + var re = /\d+/g; + + if ( (jQuery('#custom-fields-container tr').length - 1) == 0 ) { + next_custom_field_id = 1; + } + else { + next_custom_field_id = parseInt(re.exec( jQuery('#custom-fields-container input').last().attr('id') )[0]) + 1; + } + + new_custom_field = '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + 'Delete' + + '' + + '' + + jQuery('#custom-fields-container tbody').append(new_custom_field); + +} + +/** +jQuery(document).ready(function(){ + function check_fields(check, table_id, start) { + var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") + for (var i = start; i < checkboxes.length; i+=3) { + checkboxes[i].checked = check + } + } + + function verify_checked(fields_id){ + var checkboxes = jQuery("#" + fields_id + "_fields_conf tbody tr td input[type='checkbox']") + for (var i = 2; i >= 0; i--) { + var allchecked = true + for (var j = i+3; j < checkboxes.length; j+=3) { + if(!checkboxes[j].checked) { + allchecked = false + break + } + } + + var checkbox = jQuery(checkboxes[i+3]).attr("id").split("_") + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", allchecked) + } + } + + function check_all(fields_id) { + jQuery("#" + fields_id + "_active").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 0)}) + jQuery("#" + fields_id + "_required").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 1)}) + jQuery("#" + fields_id +"_signup").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 2)}) + verify_checked(fields_id) + } + + //check_all("person") + //check_all("enterprise") + //check_all("community") + + jQuery("input[type='checkbox']").click(function (){ + var checkbox = jQuery(this).attr("id").split("_") + verify_checked(checkbox.first()) + + if(this.checked == false) { + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false) + } + }) +}) +**/ diff --git a/public/javascripts/manage-fields.js b/public/javascripts/manage-fields.js index 617a97a..95e254b 100644 --- a/public/javascripts/manage-fields.js +++ b/public/javascripts/manage-fields.js @@ -1,4 +1,3 @@ -/** function update_active(name_active, name_required, name_signup) { var required = jQuery("input[name='" + name_required + "']")[1] var signup = jQuery("input[name='" + name_signup + "']")[1] @@ -7,16 +6,15 @@ function update_active(name_active, name_required, name_signup) { if(required.checked || signup.checked) active.checked = true } + function active_action(obj_active, name_required, name_signup) { - console.log( 'teste1' ); - //var required = jQuery("input[name='" + name_required + "']")[0] - //var signup = jQuery("input[name='" + name_signup + "']")[0] + var required = jQuery("input[name='" + name_required + "']")[0] + var signup = jQuery("input[name='" + name_signup + "']")[0] - //required.disabled = signup.disabled = !obj_active.checked + required.disabled = signup.disabled = !obj_active.checked } function required_action(name_active, name_required, name_signup) { - console.log( 'teste' ); var obj_required = jQuery("input[name='" + name_required + "']")[1] if(obj_required.checked) { @@ -38,6 +36,7 @@ function signup_action(name_active, name_required, name_signup) { update_active(name_active, name_required, name_signup) } + jQuery(document).ready(function(){ function check_fields(check, table_id, start) { var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") @@ -82,71 +81,3 @@ jQuery(document).ready(function(){ } }) }) -**/ - -/** ##################################################################### **/ - -function send_ajax(source_url) { - jQuery(".link-address").autocomplete({ - source : function(request, response){ - jQuery.ajax({ - type: "GET", - url: source_url, - data: {query: request.term}, - success: function(result){ - response(result); - }, - error: function(ajax, stat, errorThrown) { - console.log('Link not found : ' + errorThrown); - } - }); - }, - - minLength: 3 - }); -} - -function new_field_action(){ - send_ajax(jQuery("#page_url").val()); - - jQuery(".delete-link-list-row").click(function(){ - jQuery(this).parent().parent().remove(); - return false; - }); - - jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop()); -} - -function remove_custom_field(element) { - jQuery(element).parent().parent().remove(); - //field = jQuery(element).parent().parent(); - //console.log( field ); - return false; -} - -function add_new_field(profile_type) { - - var custom_field_counter = jQuery('#custom-fields-container').find("div.field-with-privacy-selector").length + 1; - - var row = '
' + - '
' + - '' + - '
' + - '' + - '
' + - 'Delete ' + - '
' + - '
'; - - jQuery('#custom-fields-container').append(row); - -} - -jQuery(document).ready(function(){ - new_field_action(); - - //jQuery("#dropable-link-list").sortable({ - // revert: true, - // axis: "y" - //}); -}); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index dd2eae9..34d7d74 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -6572,12 +6572,12 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { } .controller-profile_editor #profile-data { - display: table; + /*display: table;*/ width: auto; } .field-with-privacy-selector { - display: table-row; + /*display: table-row;*/ } .field-with-privacy-selector:hover { @@ -6585,14 +6585,28 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { } .controller-profile_editor #profile-data .field-with-privacy-selector .formfieldline { - width: auto; + /*width: auto;*/ + display: inline-block; } .field-privacy-selector { - display: table-cell; + /*display: table-cell;*/ + display: inline-block; vertical-align: middle; text-align: center; width: 100px; + float: right; + position: relative; + top: 15px; +} + +#custom-fields-container { + margin-bottom: 25px; +} + +#custom-fields-container label.required { + font-weight: bold; + color: #c00; } #profile_change_picture { -- libgit2 0.21.2