Commit 8cc18ab590b8249b0c46221c3d374c5865dc6a08
1 parent
8d44bb72
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
change solution: custom fields per profile
Showing
17 changed files
with
267 additions
and
327 deletions
Show diff stats
app/controllers/admin/features_controller.rb
@@ -17,24 +17,17 @@ class FeaturesController < AdminController | @@ -17,24 +17,17 @@ class FeaturesController < AdminController | ||
17 | 17 | ||
18 | def manage_fields | 18 | def manage_fields |
19 | @person_fields = Person.fields | 19 | @person_fields = Person.fields |
20 | - @custom_person_fields = (@environment.settings[:custom_person_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } | ||
21 | - | ||
22 | @enterprise_fields = Enterprise.fields | 20 | @enterprise_fields = Enterprise.fields |
23 | - @custom_enterprise_fields = (@environment.settings[:custom_enterprise_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } | ||
24 | - | ||
25 | @community_fields = Community.fields | 21 | @community_fields = Community.fields |
26 | - @custom_community_fields = (@environment.settings[:custom_community_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } | ||
27 | end | 22 | end |
28 | 23 | ||
29 | def manage_person_fields | 24 | def manage_person_fields |
30 | environment.custom_person_fields = params[:person_fields] | 25 | environment.custom_person_fields = params[:person_fields] |
31 | - | ||
32 | if environment.save! | 26 | if environment.save! |
33 | session[:notice] = _('Person fields updated successfully.') | 27 | session[:notice] = _('Person fields updated successfully.') |
34 | else | 28 | else |
35 | flash[:error] = _('Person fields not updated successfully.') | 29 | flash[:error] = _('Person fields not updated successfully.') |
36 | end | 30 | end |
37 | - | ||
38 | redirect_to :action => 'manage_fields' | 31 | redirect_to :action => 'manage_fields' |
39 | end | 32 | end |
40 | 33 |
app/controllers/my_profile/profile_editor_controller.rb
@@ -11,9 +11,6 @@ class ProfileEditorController < MyProfileController | @@ -11,9 +11,6 @@ class ProfileEditorController < MyProfileController | ||
11 | 11 | ||
12 | # edits the profile info (posts back) | 12 | # edits the profile info (posts back) |
13 | def edit | 13 | def edit |
14 | - | ||
15 | - #raise params.inspect | ||
16 | - | ||
17 | @profile_data = profile | 14 | @profile_data = profile |
18 | @possible_domains = profile.possible_domains | 15 | @possible_domains = profile.possible_domains |
19 | if request.post? | 16 | if request.post? |
app/controllers/public/account_controller.rb
@@ -66,10 +66,9 @@ class AccountController < ApplicationController | @@ -66,10 +66,9 @@ class AccountController < ApplicationController | ||
66 | end | 66 | end |
67 | 67 | ||
68 | def custom_fields_for_template | 68 | def custom_fields_for_template |
69 | - custom_fields ||= environment.people.templates.find(params[:template_id]).custom_fields.map {|k,v| | ||
70 | - { :name => k, :label => v[:label] } | ||
71 | - } | ||
72 | - | 69 | + custom_fields ||= environment.people.templates.find(params[:template_id]).custom_fields.map { |k,v| |
70 | + { :name => k, :label => v[:label] } if v['signup'] | ||
71 | + }.compact | ||
73 | render :text => {:ok => true, :custom_fields => custom_fields}.to_json | 72 | render :text => {:ok => true, :custom_fields => custom_fields}.to_json |
74 | end | 73 | end |
75 | 74 |
app/helpers/application_helper.rb
@@ -809,12 +809,6 @@ module ApplicationHelper | @@ -809,12 +809,6 @@ module ApplicationHelper | ||
809 | form_for(name, { :builder => NoosferoFormBuilder }.merge(options), &proc) | 809 | form_for(name, { :builder => NoosferoFormBuilder }.merge(options), &proc) |
810 | end | 810 | end |
811 | 811 | ||
812 | - def optional_custom_field(profile) | ||
813 | - result = "" | ||
814 | - | ||
815 | - result | ||
816 | - end | ||
817 | - | ||
818 | def optional_field(profile, name, field_html = nil, only_required = false, &block) | 812 | def optional_field(profile, name, field_html = nil, only_required = false, &block) |
819 | result = "" | 813 | result = "" |
820 | 814 |
app/models/environment.rb
@@ -429,9 +429,7 @@ class Environment < ActiveRecord::Base | @@ -429,9 +429,7 @@ class Environment < ActiveRecord::Base | ||
429 | schooling_status = values['schooling'] | 429 | schooling_status = values['schooling'] |
430 | end | 430 | end |
431 | 431 | ||
432 | - self.settings[:custom_person_fields] = values.delete_if { |key, value| | ||
433 | - ! ( Person.fields.include?(key) || key =~ /^custom_field/ ) | ||
434 | - } | 432 | + self.settings[:custom_person_fields] = values.delete_if { |key, value| ! Person.fields.include?(key)} |
435 | self.settings[:custom_person_fields].each_pair do |key, value| | 433 | self.settings[:custom_person_fields].each_pair do |key, value| |
436 | if value['required'] == 'true' | 434 | if value['required'] == 'true' |
437 | self.settings[:custom_person_fields][key]['active'] = 'true' | 435 | self.settings[:custom_person_fields][key]['active'] = 'true' |
@@ -447,16 +445,6 @@ class Environment < ActiveRecord::Base | @@ -447,16 +445,6 @@ class Environment < ActiveRecord::Base | ||
447 | end | 445 | end |
448 | end | 446 | end |
449 | 447 | ||
450 | - def custom_person_fields_customs() | ||
451 | - custom_fields = [] | ||
452 | - self.settings[:custom_person_fields].each{ |k,v| custom_fields << k if k =~ /^custom_field/ } | ||
453 | - custom_fields | ||
454 | - end | ||
455 | - | ||
456 | - def custom_person_field_name(field) | ||
457 | - self.settings[:custom_person_fields][field]['name'] | ||
458 | - end | ||
459 | - | ||
460 | def custom_person_field(field, status) | 448 | def custom_person_field(field, status) |
461 | if (custom_person_fields[field] && custom_person_fields[field][status] == 'true') | 449 | if (custom_person_fields[field] && custom_person_fields[field][status] == 'true') |
462 | return true | 450 | return true |
@@ -497,7 +485,7 @@ class Environment < ActiveRecord::Base | @@ -497,7 +485,7 @@ class Environment < ActiveRecord::Base | ||
497 | end | 485 | end |
498 | 486 | ||
499 | def custom_enterprise_fields=(values) | 487 | def custom_enterprise_fields=(values) |
500 | - self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! ( Enterprise.fields.include?(key) || key =~ /^custom_field/ ) } | 488 | + self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! Enterprise.fields.include?(key)} |
501 | self.settings[:custom_enterprise_fields].each_pair do |key, value| | 489 | self.settings[:custom_enterprise_fields].each_pair do |key, value| |
502 | if value['required'] == 'true' | 490 | if value['required'] == 'true' |
503 | self.settings[:custom_enterprise_fields][key]['active'] = 'true' | 491 | self.settings[:custom_enterprise_fields][key]['active'] = 'true' |
@@ -509,16 +497,6 @@ class Environment < ActiveRecord::Base | @@ -509,16 +497,6 @@ class Environment < ActiveRecord::Base | ||
509 | end | 497 | end |
510 | end | 498 | end |
511 | 499 | ||
512 | - def custom_enterprise_fields_customs() | ||
513 | - custom_fields = [] | ||
514 | - self.settings[:custom_enterprise_fields].each{ |k,v| custom_fields << k if k =~ /^custom_field/ } | ||
515 | - custom_fields | ||
516 | - end | ||
517 | - | ||
518 | - def custom_enterprise_field_name(field) | ||
519 | - self.settings[:custom_enterprise_fields][field]['name'] | ||
520 | - end | ||
521 | - | ||
522 | def custom_enterprise_field(field, status) | 500 | def custom_enterprise_field(field, status) |
523 | if (custom_enterprise_fields[field] && custom_enterprise_fields[field][status] == 'true') | 501 | if (custom_enterprise_fields[field] && custom_enterprise_fields[field][status] == 'true') |
524 | return true | 502 | return true |
@@ -549,13 +527,8 @@ class Environment < ActiveRecord::Base | @@ -549,13 +527,8 @@ class Environment < ActiveRecord::Base | ||
549 | def custom_community_fields | 527 | def custom_community_fields |
550 | self.settings[:custom_community_fields].nil? ? {} : self.settings[:custom_community_fields] | 528 | self.settings[:custom_community_fields].nil? ? {} : self.settings[:custom_community_fields] |
551 | end | 529 | end |
552 | - | ||
553 | def custom_community_fields=(values) | 530 | def custom_community_fields=(values) |
554 | - self.settings[:custom_community_fields] = values.delete_if { |key, value| | ||
555 | - ! ( Community.fields.include?(key) || key =~ /^custom_field/ ) | ||
556 | - } | ||
557 | - | ||
558 | - | 531 | + self.settings[:custom_community_fields] = values.delete_if { |key, value| ! Community.fields.include?(key) } |
559 | self.settings[:custom_community_fields].each_pair do |key, value| | 532 | self.settings[:custom_community_fields].each_pair do |key, value| |
560 | if value['required'] == 'true' | 533 | if value['required'] == 'true' |
561 | self.settings[:custom_community_fields][key]['active'] = 'true' | 534 | self.settings[:custom_community_fields][key]['active'] = 'true' |
@@ -567,16 +540,6 @@ class Environment < ActiveRecord::Base | @@ -567,16 +540,6 @@ class Environment < ActiveRecord::Base | ||
567 | end | 540 | end |
568 | end | 541 | end |
569 | 542 | ||
570 | - def custom_community_fields_customs() | ||
571 | - custom_fields = [] | ||
572 | - self.settings[:custom_community_fields].each{ |k,v| custom_fields << k if k =~ /^custom_field/ } | ||
573 | - custom_fields | ||
574 | - end | ||
575 | - | ||
576 | - def custom_community_field_name(field) | ||
577 | - self.settings[:custom_community_fields][field]['name'] | ||
578 | - end | ||
579 | - | ||
580 | def custom_community_field(field, status) | 543 | def custom_community_field(field, status) |
581 | if (custom_community_fields[field] && custom_community_fields[field][status] == 'true') | 544 | if (custom_community_fields[field] && custom_community_fields[field][status] == 'true') |
582 | return true | 545 | return true |
app/models/organization.rb
1 | # Represents any organization of the system | 1 | # Represents any organization of the system |
2 | class Organization < Profile | 2 | class Organization < Profile |
3 | 3 | ||
4 | - attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name, :enable_contact_us #, :custom_fields | 4 | + attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name, :enable_contact_us |
5 | 5 | ||
6 | SEARCH_FILTERS += %w[ | 6 | SEARCH_FILTERS += %w[ |
7 | more_popular | 7 | more_popular |
@@ -13,12 +13,6 @@ class Organization < Profile | @@ -13,12 +13,6 @@ class Organization < Profile | ||
13 | closed | 13 | closed |
14 | end | 14 | end |
15 | 15 | ||
16 | - #settings_items :custom_fields | ||
17 | - | ||
18 | - #def custom_field_value(field) | ||
19 | - # self.custom_fields[field] | ||
20 | - #end | ||
21 | - | ||
22 | before_save do |organization| | 16 | before_save do |organization| |
23 | organization.closed = true if !organization.public_profile? | 17 | organization.closed = true if !organization.public_profile? |
24 | end | 18 | end |
app/models/person.rb
1 | # A person is the profile of an user holding all relationships with the rest of the system | 1 | # A person is the profile of an user holding all relationships with the rest of the system |
2 | class Person < Profile | 2 | class Person < Profile |
3 | 3 | ||
4 | - 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 | 4 | + 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 |
5 | 5 | ||
6 | SEARCH_FILTERS += %w[ | 6 | SEARCH_FILTERS += %w[ |
7 | more_popular | 7 | more_popular |
@@ -205,12 +205,6 @@ class Person < Profile | @@ -205,12 +205,6 @@ class Person < Profile | ||
205 | N_('Contact information'); N_('City'); N_('State'); N_('Country'); N_('Sex'); N_('Zip code'); N_('District'); N_('Address reference') | 205 | N_('Contact information'); N_('City'); N_('State'); N_('Country'); N_('Sex'); N_('Zip code'); N_('District'); N_('Address reference') |
206 | settings_items :photo, :contact_information, :sex, :city, :state, :country, :zip_code, :district, :address_reference | 206 | settings_items :photo, :contact_information, :sex, :city, :state, :country, :zip_code, :district, :address_reference |
207 | 207 | ||
208 | - #settings_items :custom_fields | ||
209 | - | ||
210 | - #def custom_field_value(field) | ||
211 | - # self.custom_fields[field] | ||
212 | - #end | ||
213 | - | ||
214 | extend SetProfileRegionFromCityState::ClassMethods | 208 | extend SetProfileRegionFromCityState::ClassMethods |
215 | set_profile_region_from_city_state | 209 | set_profile_region_from_city_state |
216 | 210 |
app/views/features/_manage_community_fields.html.erb
@@ -12,73 +12,46 @@ | @@ -12,73 +12,46 @@ | ||
12 | <td> | 12 | <td> |
13 | <%= _("Check/Uncheck All")%> | 13 | <%= _("Check/Uncheck All")%> |
14 | </td> | 14 | </td> |
15 | - <td align="center"> | 15 | + <td> |
16 | <input type="checkbox" id="community_active" /> | 16 | <input type="checkbox" id="community_active" /> |
17 | </td> | 17 | </td> |
18 | - <td align="center"> | 18 | + <td> |
19 | <input type="checkbox" id="community_required" /> | 19 | <input type="checkbox" id="community_required" /> |
20 | </td> | 20 | </td> |
21 | - <td align="center"> | 21 | + <td> |
22 | <input type="checkbox" id="community_signup" /> | 22 | <input type="checkbox" id="community_signup" /> |
23 | </td> | 23 | </td> |
24 | - <td> </td> | ||
25 | </tr> | 24 | </tr> |
26 | 25 | ||
27 | <% @community_fields.each do |field| %> | 26 | <% @community_fields.each do |field| %> |
28 | <tr> | 27 | <tr> |
29 | <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> | 28 | <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
30 | - <td align="center"> | ||
31 | - <%= hidden_field_tag "community_fields[#{field}][active]", false %> | ||
32 | - <%= 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]')" %> | ||
33 | - </td> | ||
34 | - <td align="center"> | ||
35 | - <%= hidden_field_tag "community_fields[#{field}][required]", false %> | ||
36 | - <%= 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]')" %> | ||
37 | - </td> | ||
38 | - <td align="center"> | ||
39 | - <%= hidden_field_tag "community_fields[#{field}][signup]", false %> | ||
40 | - <%= 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]')" %> | ||
41 | - </td> | ||
42 | - </tr> | ||
43 | - <% end %> | ||
44 | 29 | ||
45 | - <% @custom_community_fields.each do |field| %> | ||
46 | - <tr> | ||
47 | <td> | 30 | <td> |
48 | - <%= text_field_tag "community_fields[#{field}][name]", environment.custom_community_field_name(field) %> | ||
49 | - </td> | ||
50 | - <td align="center"> | ||
51 | <%= hidden_field_tag "community_fields[#{field}][active]", false %> | 31 | <%= hidden_field_tag "community_fields[#{field}][active]", false %> |
52 | <%= 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]')" %> | 32 | <%= 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]')" %> |
53 | </td> | 33 | </td> |
54 | - <td align="center"> | 34 | + <td> |
55 | <%= hidden_field_tag "community_fields[#{field}][required]", false %> | 35 | <%= hidden_field_tag "community_fields[#{field}][required]", false %> |
56 | <%= 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]')" %> | 36 | <%= 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]')" %> |
57 | </td> | 37 | </td> |
58 | - <td align="center"> | ||
59 | - <%= hidden_field_tag "community_fields[#{field}][signup]", false %> | ||
60 | - <%= 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]')" %> | ||
61 | - </td> | ||
62 | <td> | 38 | <td> |
63 | - <a href="#" class="button icon-delete delete-link-list-row" title="Delete" onclick="return remove_custom_field(this);"><span>Delete</span></a> | 39 | + <%= hidden_field_tag "community_fields[#{field}][signup]", false %> |
40 | + <%= 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]')" %> | ||
64 | </td> | 41 | </td> |
42 | + | ||
65 | </tr> | 43 | </tr> |
66 | <% end %> | 44 | <% end %> |
67 | - | ||
68 | </table> | 45 | </table> |
69 | 46 | ||
70 | -<br /> | ||
71 | - | ||
72 | -<%= link_to_function(_('Add field'), "add_new_field('community');", :class => 'button icon-add with-text') %> | ||
73 | - | ||
74 | <script type='text/javascript'> | 47 | <script type='text/javascript'> |
75 | - //var trs = jQuery('#community_fields_conf tr'); | ||
76 | - //var tr, td2; | ||
77 | - //for ( var i=2; tr=trs[i]; i++ ) { | ||
78 | - // if ( td2 = tr.getElementsByTagName('td')[1] ) { | ||
79 | - // td2.getElementsByTagName('input')[1].onclick(); | ||
80 | - // } | ||
81 | - //} | 48 | + var trs = jQuery('#community_fields_conf tr'); |
49 | + var tr, td2; | ||
50 | + for ( var i=2; tr=trs[i]; i++ ) { | ||
51 | + if ( td2 = tr.getElementsByTagName('td')[1] ) { | ||
52 | + td2.getElementsByTagName('input')[1].onclick(); | ||
53 | + } | ||
54 | + } | ||
82 | </script> | 55 | </script> |
83 | 56 | ||
84 | <div> | 57 | <div> |
app/views/features/_manage_enterprise_fields.html.erb
@@ -12,13 +12,13 @@ | @@ -12,13 +12,13 @@ | ||
12 | <td> | 12 | <td> |
13 | <%= _("Check/Uncheck All")%> | 13 | <%= _("Check/Uncheck All")%> |
14 | </td> | 14 | </td> |
15 | - <td align="center"> | 15 | + <td> |
16 | <input type="checkbox" id="enterprise_active" /> | 16 | <input type="checkbox" id="enterprise_active" /> |
17 | </td> | 17 | </td> |
18 | - <td align="center"> | 18 | + <td> |
19 | <input type="checkbox" id="enterprise_required" /> | 19 | <input type="checkbox" id="enterprise_required" /> |
20 | </td> | 20 | </td> |
21 | - <td align="center"> | 21 | + <td> |
22 | <input type="checkbox" id="enterprise_signup" /> | 22 | <input type="checkbox" id="enterprise_signup" /> |
23 | </td> | 23 | </td> |
24 | </tr> | 24 | </tr> |
@@ -27,59 +27,31 @@ | @@ -27,59 +27,31 @@ | ||
27 | <tr> | 27 | <tr> |
28 | 28 | ||
29 | <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> | 29 | <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
30 | - <td align="center"> | 30 | + <td> |
31 | <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> | 31 | <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> |
32 | <%= 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]')" %> | 32 | <%= 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]')" %> |
33 | </td> | 33 | </td> |
34 | - <td align="center"> | 34 | + <td> |
35 | <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> | 35 | <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> |
36 | <%= 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]')" %> | 36 | <%= 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]')" %> |
37 | </td> | 37 | </td> |
38 | - <td align="center"> | 38 | + <td> |
39 | <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> | 39 | <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> |
40 | <%= 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]')" %> | 40 | <%= 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]')" %> |
41 | </td> | 41 | </td> |
42 | 42 | ||
43 | </tr> | 43 | </tr> |
44 | <% end %> | 44 | <% end %> |
45 | - | ||
46 | - <% @custom_enterprise_fields.each do |field| %> | ||
47 | - <tr> | ||
48 | - <td> | ||
49 | - <%= text_field_tag "enterprise_fields[#{field}][name]", environment.custom_enterprise_field_name(field) %> | ||
50 | - </td> | ||
51 | - <td align="center"> | ||
52 | - <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> | ||
53 | - <%= 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]')" %> | ||
54 | - </td> | ||
55 | - <td align="center"> | ||
56 | - <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> | ||
57 | - <%= 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]')" %> | ||
58 | - </td> | ||
59 | - <td align="center"> | ||
60 | - <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> | ||
61 | - <%= 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]')" %> | ||
62 | - </td> | ||
63 | - <td> | ||
64 | - <a href="#" class="button icon-delete delete-link-list-row" title="Delete" onclick="return remove_custom_field(this);"><span>Delete</span></a> | ||
65 | - </td> | ||
66 | - </tr> | ||
67 | - <% end %> | ||
68 | - | ||
69 | </table> | 45 | </table> |
70 | 46 | ||
71 | -<br /> | ||
72 | - | ||
73 | -<%= link_to_function(_('Add field'), "add_new_field('enterprise');", :class => 'button icon-add with-text') %> | ||
74 | - | ||
75 | <script type='text/javascript'> | 47 | <script type='text/javascript'> |
76 | - //var trs = jQuery('#enterprise_fields_conf tr'); | ||
77 | - //var tr, td2; | ||
78 | - //for ( var i=2; tr=trs[i]; i++ ) { | ||
79 | - // if ( td2 = tr.getElementsByTagName('td')[1] ) { | ||
80 | - // td2.getElementsByTagName('input')[1].onclick(); | ||
81 | - // } | ||
82 | - //} | 48 | + var trs = jQuery('#enterprise_fields_conf tr'); |
49 | + var tr, td2; | ||
50 | + for ( var i=2; tr=trs[i]; i++ ) { | ||
51 | + if ( td2 = tr.getElementsByTagName('td')[1] ) { | ||
52 | + td2.getElementsByTagName('input')[1].onclick(); | ||
53 | + } | ||
54 | + } | ||
83 | </script> | 55 | </script> |
84 | 56 | ||
85 | <div> | 57 | <div> |
app/views/features/_manage_person_fields.html.erb
1 | <%= labelled_form_for(:environment, :url => {:action => 'manage_person_fields'}) do |f| %> | 1 | <%= labelled_form_for(:environment, :url => {:action => 'manage_person_fields'}) do |f| %> |
2 | 2 | ||
3 | -<table id='person_fields_conf' border="0"> | 3 | +<table id='person_fields_conf'> |
4 | <tr> | 4 | <tr> |
5 | <th><%= _('Field') %></th> | 5 | <th><%= _('Field') %></th> |
6 | <th><%= _('Active') %></th> | 6 | <th><%= _('Active') %></th> |
7 | <th><%= _('Required') %></th> | 7 | <th><%= _('Required') %></th> |
8 | <th><%= _('Display on signup?') %></th> | 8 | <th><%= _('Display on signup?') %></th> |
9 | - <th> </th> | ||
10 | </tr> | 9 | </tr> |
11 | 10 | ||
12 | <tr class='manage-fields-batch-actions'> | 11 | <tr class='manage-fields-batch-actions'> |
13 | <td> | 12 | <td> |
14 | <%= _("Check/Uncheck All")%> | 13 | <%= _("Check/Uncheck All")%> |
15 | </td> | 14 | </td> |
16 | - <td align="center"> | 15 | + <td> |
17 | <input type="checkbox" id="person_active" /> | 16 | <input type="checkbox" id="person_active" /> |
18 | </td> | 17 | </td> |
19 | - <td align="center"> | 18 | + <td> |
20 | <input type="checkbox" id="person_required" /> | 19 | <input type="checkbox" id="person_required" /> |
21 | </td> | 20 | </td> |
22 | - <td align="center"> | 21 | + <td> |
23 | <input type="checkbox" id="person_signup" /> | 22 | <input type="checkbox" id="person_signup" /> |
24 | </td> | 23 | </td> |
25 | - <td> </td> | ||
26 | </tr> | 24 | </tr> |
27 | 25 | ||
28 | <% @person_fields.each do |field| %> | 26 | <% @person_fields.each do |field| %> |
29 | <tr> | 27 | <tr> |
30 | <td><label for="person_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> | 28 | <td><label for="person_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
31 | - <td align="center"> | ||
32 | - <%= hidden_field_tag "person_fields[#{field}][active]", false %> | ||
33 | - <%= 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]')" %> | ||
34 | - </td> | ||
35 | - <td align="center"> | ||
36 | - <%= hidden_field_tag "person_fields[#{field}][required]", false %> | ||
37 | - <%= 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]')" %> | ||
38 | - </td> | ||
39 | - <td align="center"> | ||
40 | - <%= hidden_field_tag "person_fields[#{field}][signup]", false %> | ||
41 | - <%= 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]')" %> | ||
42 | - </td> | ||
43 | - <td> </td> | ||
44 | - </tr> | ||
45 | - <% end %> | ||
46 | - | ||
47 | - <% @custom_person_fields.each do |field| %> | ||
48 | - <tr> | ||
49 | <td> | 29 | <td> |
50 | - <%= text_field_tag "person_fields[#{field}][name]", environment.custom_person_field_name(field) %> | ||
51 | - </td> | ||
52 | - <td align="center"> | ||
53 | <%= hidden_field_tag "person_fields[#{field}][active]", false %> | 30 | <%= hidden_field_tag "person_fields[#{field}][active]", false %> |
54 | <%= 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]')" %> | 31 | <%= 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]')" %> |
55 | </td> | 32 | </td> |
56 | - <td align="center"> | 33 | + <td> |
57 | <%= hidden_field_tag "person_fields[#{field}][required]", false %> | 34 | <%= hidden_field_tag "person_fields[#{field}][required]", false %> |
58 | <%= 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]')" %> | 35 | <%= 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]')" %> |
59 | </td> | 36 | </td> |
60 | - <td align="center"> | ||
61 | - <%= hidden_field_tag "person_fields[#{field}][signup]", false %> | ||
62 | - <%= 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]')" %> | ||
63 | - </td> | ||
64 | <td> | 37 | <td> |
65 | - <a href="#" class="button icon-delete delete-link-list-row" title="Delete" onclick="return remove_custom_field(this);"><span>Delete</span></a> | 38 | + <%= hidden_field_tag "person_fields[#{field}][signup]", false %> |
39 | + <%= 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]')" %> | ||
66 | </td> | 40 | </td> |
67 | </tr> | 41 | </tr> |
68 | <% end %> | 42 | <% end %> |
69 | - | ||
70 | </table> | 43 | </table> |
71 | 44 | ||
72 | -<br /> | ||
73 | - | ||
74 | -<%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %> | ||
75 | - | ||
76 | -<script type='text/javascript'> | ||
77 | - // <!-- | ||
78 | - //var trs = jQuery('#person_fields_conf tr'); | 45 | +<script type='text/javascript'>// <!-- |
46 | + var trs = jQuery('#person_fields_conf tr'); | ||
79 | 47 | ||
80 | - //var tr, td2; | ||
81 | - //for ( var i=2; tr=trs[i]; i++ ) { | ||
82 | - // if ( td2 = tr.getElementsByTagName('td')[1] ) { | ||
83 | - // td2.getElementsByTagName('input')[1].onclick(); | ||
84 | - // } | ||
85 | - //} | 48 | + var tr, td2; |
49 | + for ( var i=2; tr=trs[i]; i++ ) { | ||
50 | + if ( td2 = tr.getElementsByTagName('td')[1] ) { | ||
51 | + td2.getElementsByTagName('input')[1].onclick(); | ||
52 | + } | ||
53 | + } | ||
86 | // --> | 54 | // --> |
87 | </script> | 55 | </script> |
88 | 56 |
app/views/profile_editor/_organization.html.erb
@@ -60,12 +60,8 @@ | @@ -60,12 +60,8 @@ | ||
60 | </div> | 60 | </div> |
61 | <% end %> | 61 | <% end %> |
62 | 62 | ||
63 | -<hr /> | ||
64 | - | ||
65 | <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'profile_data', :profile => @profile } %> | 63 | <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'profile_data', :profile => @profile } %> |
66 | 64 | ||
67 | -<hr /> | ||
68 | - | ||
69 | <%= labelled_check_box(_('Enable "contact us"'), 'profile_data[enable_contact_us]', "1", @profile.enable_contact_us) if @profile.enterprise? %> | 65 | <%= labelled_check_box(_('Enable "contact us"'), 'profile_data[enable_contact_us]', "1", @profile.enable_contact_us) if @profile.enterprise? %> |
70 | 66 | ||
71 | <%= render :partial => 'moderation', :locals => { :profile => @profile } %> | 67 | <%= render :partial => 'moderation', :locals => { :profile => @profile } %> |
app/views/profile_editor/_person_form.html.erb
@@ -69,27 +69,79 @@ | @@ -69,27 +69,79 @@ | ||
69 | 69 | ||
70 | <h2><%= _('Custom fields') %></h2> | 70 | <h2><%= _('Custom fields') %></h2> |
71 | 71 | ||
72 | -<%= javascript_include_tag "manage-fields.js" %> | ||
73 | - | ||
74 | -<div id="custom-fields-container" style="border:1px solid red; margin-bottom: 10px;"> | ||
75 | -<% @person.custom_fields.each { |key,value| %> | ||
76 | - <div class="field-with-privacy-selector"> | ||
77 | - <div class="formfieldline"> | ||
78 | - <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %> | ||
79 | - <div class="formfield type-text" style="display: inline-block;"> | ||
80 | - <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", "", :size => 30 ) %> | ||
81 | - </div><a href="#" class="button icon-delete" title="Delete" onclick="return remove_custom_field(this);"> | ||
82 | - <span>Delete</span> | ||
83 | - </a> | ||
84 | - </div> | ||
85 | - </div> | ||
86 | -<% } %> | ||
87 | -</div> | 72 | +<div id="custom-fields-container"> |
73 | + | ||
74 | + <% if @person.is_template? %> | ||
75 | + | ||
76 | + <%= javascript_include_tag "manage-custom-fields.js" %> | ||
77 | + | ||
78 | + <table border="0"> | ||
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;"> </th> | ||
85 | + </tr> | ||
86 | + | ||
87 | + <% @person.custom_fields.each { |key,value| %> | ||
88 | + <tr> | ||
89 | + <td> | ||
90 | + <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %> | ||
91 | + </td> | ||
92 | + <td align="center"> | ||
93 | + <%= 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]')" %> | ||
94 | + </td> | ||
95 | + <td align="center"> | ||
96 | + <%= 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]')" %> | ||
97 | + </td> | ||
98 | + <td align="center"> | ||
99 | + <%= 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]')" %> | ||
100 | + </td> | ||
101 | + <td align="center"> | ||
102 | + <%= link_to content_tag(:span, _('Delete')), '#', onclick: "return remove_custom_field(this);", title: "Delete", class: "button icon-delete" %> | ||
103 | + </td> | ||
104 | + </tr> | ||
105 | + <% } %> | ||
106 | + | ||
107 | + </table> | ||
88 | 108 | ||
89 | -<% if @person.is_template? %> | ||
90 | <span> | 109 | <span> |
91 | <%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %> | 110 | <%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %> |
92 | </span> | 111 | </span> |
93 | -<% end %> | ||
94 | 112 | ||
95 | -<br /><br /> | 113 | + <% else %> |
114 | + | ||
115 | + <% Profile.find(@person.template_id).custom_fields.each { |key,value| %> | ||
116 | + | ||
117 | + <% if value['active'] %> | ||
118 | + <div class="field-with-privacy-selector"> | ||
119 | + <div class="formfieldline"> | ||
120 | + | ||
121 | + <span style="display: block;"> | ||
122 | + <% if value['required'] %> | ||
123 | + <%= label_tag value[:label] + ' (*)', nil, class: 'required' %> | ||
124 | + <% else %> | ||
125 | + <%= label_tag value[:label] %> | ||
126 | + <% end %> | ||
127 | + </span> | ||
128 | + | ||
129 | + <div class="formfield type-text" style="display: inline-block;"> | ||
130 | + <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", @person.custom_fields[key][:value], :size => 30 ) %> | ||
131 | + </div> | ||
132 | + | ||
133 | + </div> | ||
134 | + | ||
135 | + <div class="field-privacy-selector"> | ||
136 | + <input id="checkbox-44" name="" title="This field must be public" type="checkbox" value=""> | ||
137 | + <label for="checkbox-44">Public</label> | ||
138 | + </div> | ||
139 | + | ||
140 | + </div> | ||
141 | + <% end %> | ||
142 | + | ||
143 | + <% } %> | ||
144 | + | ||
145 | + <% end %> | ||
146 | + | ||
147 | +</div> |
app/views/profile_editor/edit.html.erb
@@ -10,12 +10,8 @@ | @@ -10,12 +10,8 @@ | ||
10 | </div> | 10 | </div> |
11 | <% end %> | 11 | <% end %> |
12 | 12 | ||
13 | - <hr /> | ||
14 | - | ||
15 | <%= render :partial => partial_for_class(@profile.class), :locals => { :f => f } %> | 13 | <%= render :partial => partial_for_class(@profile.class), :locals => { :f => f } %> |
16 | 14 | ||
17 | - <hr /> | ||
18 | - | ||
19 | <div id="profile_change_picture_title"> | 15 | <div id="profile_change_picture_title"> |
20 | <h2><%= _('Change picture') %></h2> | 16 | <h2><%= _('Change picture') %></h2> |
21 | <span><%= unchangeable_privacy_field @profile %></span> | 17 | <span><%= unchangeable_privacy_field @profile %></span> |
app/views/shared/_organization_custom_fields.html.erb
@@ -30,22 +30,3 @@ | @@ -30,22 +30,3 @@ | ||
30 | <%= optional_field(profile, 'foundation_year', f.text_field(:foundation_year)) %> | 30 | <%= optional_field(profile, 'foundation_year', f.text_field(:foundation_year)) %> |
31 | <% end %> | 31 | <% end %> |
32 | <%= javascript_include_tag('city_state_validation') %> | 32 | <%= javascript_include_tag('city_state_validation') %> |
33 | - | ||
34 | -<hr /> | ||
35 | - | ||
36 | -<% if profile.community? %> | ||
37 | - | ||
38 | - <% @environment.custom_community_fields_customs.each { |key| %> | ||
39 | - <% #raise @environment.custom_community_fields_customs.inspect %> | ||
40 | - <% optional_field(profile, key) do %> | ||
41 | - <div class="formfieldline"> | ||
42 | - <%= label_tag environment.custom_community_field_name(key), nil, class: 'formlabel' %> | ||
43 | - <div class="formfield type-select"> | ||
44 | - <%= text_field_tag("profile_data[custom_fields][#{key}]", profile.custom_field_value(key)) %> | ||
45 | - </div> | ||
46 | - </div> | ||
47 | - <% end %> | ||
48 | - <% } %> | ||
49 | -<% end %> | ||
50 | - | ||
51 | -<hr /> |
@@ -0,0 +1,123 @@ | @@ -0,0 +1,123 @@ | ||
1 | +function update_active(name_active, name_required, name_signup) { | ||
2 | + var required = jQuery("input[name='" + name_required + "']")[0] | ||
3 | + var signup = jQuery("input[name='" + name_signup + "']")[0] | ||
4 | + var active = jQuery("input[name='" + name_active + "']")[0] | ||
5 | + | ||
6 | + if(required.checked || signup.checked) | ||
7 | + active.checked = true | ||
8 | +} | ||
9 | + | ||
10 | +function active_action(obj_active, name_required, name_signup) { | ||
11 | + var required = jQuery("input[name='" + name_required + "']")[0] | ||
12 | + var signup = jQuery("input[name='" + name_signup + "']")[0] | ||
13 | + | ||
14 | + required.disabled = signup.disabled = !obj_active.checked | ||
15 | +} | ||
16 | + | ||
17 | +function required_action(name_active, name_required, name_signup) { | ||
18 | + var obj_required = jQuery("input[name='" + name_required + "']")[0] | ||
19 | + | ||
20 | + if(obj_required.checked) { | ||
21 | + jQuery("input[name='" + name_signup + "']")[0].checked = true | ||
22 | + } | ||
23 | + | ||
24 | + update_active(name_active, name_required, name_signup) | ||
25 | +} | ||
26 | + | ||
27 | +function signup_action(name_active, name_required, name_signup) { | ||
28 | + var obj_signup = jQuery("input[name='" + name_signup + "']")[0] | ||
29 | + | ||
30 | + if(!obj_signup.checked) { | ||
31 | + jQuery("input[name='" + name_required + "']")[0].checked = false | ||
32 | + } | ||
33 | + | ||
34 | + update_active(name_active, name_required, name_signup) | ||
35 | +} | ||
36 | + | ||
37 | +function remove_custom_field(element) { | ||
38 | + jQuery(element).parent().parent().remove(); | ||
39 | + //field = jQuery(element).parent().parent(); | ||
40 | + //console.log( field ); | ||
41 | + return false; | ||
42 | +} | ||
43 | + | ||
44 | +function add_new_field() { | ||
45 | + var next_custom_field_id; | ||
46 | + var re = /\d+/g; | ||
47 | + | ||
48 | + if ( (jQuery('#custom-fields-container tr').length - 1) == 0 ) { | ||
49 | + next_custom_field_id = 1; | ||
50 | + } | ||
51 | + else { | ||
52 | + next_custom_field_id = parseInt(re.exec( jQuery('#custom-fields-container input').last().attr('id') )[0]) + 1; | ||
53 | + } | ||
54 | + | ||
55 | + new_custom_field = '' + | ||
56 | + '<tr>' + | ||
57 | + '<td>' + | ||
58 | + '<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="">' + | ||
59 | + '</td>' + | ||
60 | + '<td align="center">' + | ||
61 | + '<input id="profile_data_custom_fields_custom_field_' + next_custom_field_id + '_active" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][active]" onclick="active_action(this, "profile_data[custom_fields][custom_field_' + next_custom_field_id + '][required]", "profile_data[custom_fields][custom_field_' + next_custom_field_id + '][signup]")" type="checkbox">' + | ||
62 | + '</td>' + | ||
63 | + '<td align="center">' + | ||
64 | + '<input id="profile_data_custom_fields_custom_field_' + next_custom_field_id + '_required" name="profile_data[custom_fields][custom_field_' + next_custom_field_id + '][required]" onclick="required_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">' + | ||
65 | + '</td>' + | ||
66 | + '<td align="center">' + | ||
67 | + '<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">' + | ||
68 | + '</td>' + | ||
69 | + '<td align="center">' + | ||
70 | + '<a href="#" class="button icon-delete link-this-page" onclick="return remove_custom_field(this);" title="Delete"><span>Delete</span></a>' + | ||
71 | + '</td>' + | ||
72 | + '</tr>' | ||
73 | + | ||
74 | + jQuery('#custom-fields-container tbody').append(new_custom_field); | ||
75 | + | ||
76 | +} | ||
77 | + | ||
78 | +/** | ||
79 | +jQuery(document).ready(function(){ | ||
80 | + function check_fields(check, table_id, start) { | ||
81 | + var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") | ||
82 | + for (var i = start; i < checkboxes.length; i+=3) { | ||
83 | + checkboxes[i].checked = check | ||
84 | + } | ||
85 | + } | ||
86 | + | ||
87 | + function verify_checked(fields_id){ | ||
88 | + var checkboxes = jQuery("#" + fields_id + "_fields_conf tbody tr td input[type='checkbox']") | ||
89 | + for (var i = 2; i >= 0; i--) { | ||
90 | + var allchecked = true | ||
91 | + for (var j = i+3; j < checkboxes.length; j+=3) { | ||
92 | + if(!checkboxes[j].checked) { | ||
93 | + allchecked = false | ||
94 | + break | ||
95 | + } | ||
96 | + } | ||
97 | + | ||
98 | + var checkbox = jQuery(checkboxes[i+3]).attr("id").split("_") | ||
99 | + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", allchecked) | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + function check_all(fields_id) { | ||
104 | + jQuery("#" + fields_id + "_active").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 0)}) | ||
105 | + jQuery("#" + fields_id + "_required").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 1)}) | ||
106 | + jQuery("#" + fields_id +"_signup").click(function (){check_fields(this.checked, fields_id + "_fields_conf", 2)}) | ||
107 | + verify_checked(fields_id) | ||
108 | + } | ||
109 | + | ||
110 | + //check_all("person") | ||
111 | + //check_all("enterprise") | ||
112 | + //check_all("community") | ||
113 | + | ||
114 | + jQuery("input[type='checkbox']").click(function (){ | ||
115 | + var checkbox = jQuery(this).attr("id").split("_") | ||
116 | + verify_checked(checkbox.first()) | ||
117 | + | ||
118 | + if(this.checked == false) { | ||
119 | + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false) | ||
120 | + } | ||
121 | + }) | ||
122 | +}) | ||
123 | +**/ |
public/javascripts/manage-fields.js
1 | -/** | ||
2 | function update_active(name_active, name_required, name_signup) { | 1 | function update_active(name_active, name_required, name_signup) { |
3 | var required = jQuery("input[name='" + name_required + "']")[1] | 2 | var required = jQuery("input[name='" + name_required + "']")[1] |
4 | var signup = jQuery("input[name='" + name_signup + "']")[1] | 3 | var signup = jQuery("input[name='" + name_signup + "']")[1] |
@@ -7,16 +6,15 @@ function update_active(name_active, name_required, name_signup) { | @@ -7,16 +6,15 @@ function update_active(name_active, name_required, name_signup) { | ||
7 | if(required.checked || signup.checked) | 6 | if(required.checked || signup.checked) |
8 | active.checked = true | 7 | active.checked = true |
9 | } | 8 | } |
9 | + | ||
10 | function active_action(obj_active, name_required, name_signup) { | 10 | function active_action(obj_active, name_required, name_signup) { |
11 | - console.log( 'teste1' ); | ||
12 | - //var required = jQuery("input[name='" + name_required + "']")[0] | ||
13 | - //var signup = jQuery("input[name='" + name_signup + "']")[0] | 11 | + var required = jQuery("input[name='" + name_required + "']")[0] |
12 | + var signup = jQuery("input[name='" + name_signup + "']")[0] | ||
14 | 13 | ||
15 | - //required.disabled = signup.disabled = !obj_active.checked | 14 | + required.disabled = signup.disabled = !obj_active.checked |
16 | } | 15 | } |
17 | 16 | ||
18 | function required_action(name_active, name_required, name_signup) { | 17 | function required_action(name_active, name_required, name_signup) { |
19 | - console.log( 'teste' ); | ||
20 | var obj_required = jQuery("input[name='" + name_required + "']")[1] | 18 | var obj_required = jQuery("input[name='" + name_required + "']")[1] |
21 | 19 | ||
22 | if(obj_required.checked) { | 20 | if(obj_required.checked) { |
@@ -38,6 +36,7 @@ function signup_action(name_active, name_required, name_signup) { | @@ -38,6 +36,7 @@ function signup_action(name_active, name_required, name_signup) { | ||
38 | update_active(name_active, name_required, name_signup) | 36 | update_active(name_active, name_required, name_signup) |
39 | } | 37 | } |
40 | 38 | ||
39 | + | ||
41 | jQuery(document).ready(function(){ | 40 | jQuery(document).ready(function(){ |
42 | function check_fields(check, table_id, start) { | 41 | function check_fields(check, table_id, start) { |
43 | var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") | 42 | var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") |
@@ -82,71 +81,3 @@ jQuery(document).ready(function(){ | @@ -82,71 +81,3 @@ jQuery(document).ready(function(){ | ||
82 | } | 81 | } |
83 | }) | 82 | }) |
84 | }) | 83 | }) |
85 | -**/ | ||
86 | - | ||
87 | -/** ##################################################################### **/ | ||
88 | - | ||
89 | -function send_ajax(source_url) { | ||
90 | - jQuery(".link-address").autocomplete({ | ||
91 | - source : function(request, response){ | ||
92 | - jQuery.ajax({ | ||
93 | - type: "GET", | ||
94 | - url: source_url, | ||
95 | - data: {query: request.term}, | ||
96 | - success: function(result){ | ||
97 | - response(result); | ||
98 | - }, | ||
99 | - error: function(ajax, stat, errorThrown) { | ||
100 | - console.log('Link not found : ' + errorThrown); | ||
101 | - } | ||
102 | - }); | ||
103 | - }, | ||
104 | - | ||
105 | - minLength: 3 | ||
106 | - }); | ||
107 | -} | ||
108 | - | ||
109 | -function new_field_action(){ | ||
110 | - send_ajax(jQuery("#page_url").val()); | ||
111 | - | ||
112 | - jQuery(".delete-link-list-row").click(function(){ | ||
113 | - jQuery(this).parent().parent().remove(); | ||
114 | - return false; | ||
115 | - }); | ||
116 | - | ||
117 | - jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop()); | ||
118 | -} | ||
119 | - | ||
120 | -function remove_custom_field(element) { | ||
121 | - jQuery(element).parent().parent().remove(); | ||
122 | - //field = jQuery(element).parent().parent(); | ||
123 | - //console.log( field ); | ||
124 | - return false; | ||
125 | -} | ||
126 | - | ||
127 | -function add_new_field(profile_type) { | ||
128 | - | ||
129 | - var custom_field_counter = jQuery('#custom-fields-container').find("div.field-with-privacy-selector").length + 1; | ||
130 | - | ||
131 | - var row = '<div class="field-with-privacy-selector">' + | ||
132 | - '<div class="formfieldline">' + | ||
133 | - '<input id="profile_data_custom_fields_custom_field_' + custom_field_counter + '_label" name="profile_data[custom_fields][custom_field_' + custom_field_counter + '][label]" value="label" style="display:block" />' + | ||
134 | - '<div class="formfield type-text" style="display: inline-block;">' + | ||
135 | - '<input id="profile_data_custom_fields_custom_field_' + custom_field_counter + '_value" name="profile_data[custom_fields][custom_field_' + custom_field_counter + '][value]" size="30" type="text">' + | ||
136 | - '</div>' + | ||
137 | - '<a href="#" class="button icon-delete delete-link-list-row" title="Delete" onclick="return remove_custom_field(this);"><span>Delete</span></a> ' + | ||
138 | - '</div>' + | ||
139 | - '</div>'; | ||
140 | - | ||
141 | - jQuery('#custom-fields-container').append(row); | ||
142 | - | ||
143 | -} | ||
144 | - | ||
145 | -jQuery(document).ready(function(){ | ||
146 | - new_field_action(); | ||
147 | - | ||
148 | - //jQuery("#dropable-link-list").sortable({ | ||
149 | - // revert: true, | ||
150 | - // axis: "y" | ||
151 | - //}); | ||
152 | -}); |
public/stylesheets/application.css
@@ -6572,12 +6572,12 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { | @@ -6572,12 +6572,12 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { | ||
6572 | } | 6572 | } |
6573 | 6573 | ||
6574 | .controller-profile_editor #profile-data { | 6574 | .controller-profile_editor #profile-data { |
6575 | - display: table; | 6575 | + /*display: table;*/ |
6576 | width: auto; | 6576 | width: auto; |
6577 | } | 6577 | } |
6578 | 6578 | ||
6579 | .field-with-privacy-selector { | 6579 | .field-with-privacy-selector { |
6580 | - display: table-row; | 6580 | + /*display: table-row;*/ |
6581 | } | 6581 | } |
6582 | 6582 | ||
6583 | .field-with-privacy-selector:hover { | 6583 | .field-with-privacy-selector:hover { |
@@ -6585,14 +6585,28 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { | @@ -6585,14 +6585,28 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { | ||
6585 | } | 6585 | } |
6586 | 6586 | ||
6587 | .controller-profile_editor #profile-data .field-with-privacy-selector .formfieldline { | 6587 | .controller-profile_editor #profile-data .field-with-privacy-selector .formfieldline { |
6588 | - width: auto; | 6588 | + /*width: auto;*/ |
6589 | + display: inline-block; | ||
6589 | } | 6590 | } |
6590 | 6591 | ||
6591 | .field-privacy-selector { | 6592 | .field-privacy-selector { |
6592 | - display: table-cell; | 6593 | + /*display: table-cell;*/ |
6594 | + display: inline-block; | ||
6593 | vertical-align: middle; | 6595 | vertical-align: middle; |
6594 | text-align: center; | 6596 | text-align: center; |
6595 | width: 100px; | 6597 | width: 100px; |
6598 | + float: right; | ||
6599 | + position: relative; | ||
6600 | + top: 15px; | ||
6601 | +} | ||
6602 | + | ||
6603 | +#custom-fields-container { | ||
6604 | + margin-bottom: 25px; | ||
6605 | +} | ||
6606 | + | ||
6607 | +#custom-fields-container label.required { | ||
6608 | + font-weight: bold; | ||
6609 | + color: #c00; | ||
6596 | } | 6610 | } |
6597 | 6611 | ||
6598 | #profile_change_picture { | 6612 | #profile_change_picture { |