Commit 7601acd63ba1583d4f2fe98f3731856024019f3c
1 parent
a4bfc4d9
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
add infra
Showing
13 changed files
with
298 additions
and
169 deletions
Show diff stats
app/controllers/admin/features_controller.rb
... | ... | @@ -17,17 +17,18 @@ class FeaturesController < AdminController |
17 | 17 | |
18 | 18 | def manage_fields |
19 | 19 | @person_fields = Person.fields |
20 | - @custom_person_fields = [] | |
21 | - @environment.settings[:custom_person_fields].each{|k,v| @custom_person_fields << k if k =~ /^custom_field/ && ! @custom_person_fields.include?(k) } | |
20 | + @custom_person_fields = (@environment.settings[:custom_person_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } | |
21 | + | |
22 | 22 | @enterprise_fields = Enterprise.fields |
23 | + @custom_enterprise_fields = (@environment.settings[:custom_enterprise_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } | |
24 | + | |
23 | 25 | @community_fields = Community.fields |
26 | + @custom_community_fields = (@environment.settings[:custom_community_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } | |
24 | 27 | end |
25 | 28 | |
26 | 29 | def manage_person_fields |
27 | 30 | environment.custom_person_fields = params[:person_fields] |
28 | 31 | |
29 | - #raise params[:person_fields].inspect | |
30 | - | |
31 | 32 | if environment.save! |
32 | 33 | session[:notice] = _('Person fields updated successfully.') |
33 | 34 | else | ... | ... |
app/models/environment.rb
... | ... | @@ -497,7 +497,7 @@ class Environment < ActiveRecord::Base |
497 | 497 | end |
498 | 498 | |
499 | 499 | def custom_enterprise_fields=(values) |
500 | - self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! Enterprise.fields.include?(key)} | |
500 | + self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! ( Enterprise.fields.include?(key) || key =~ /^custom_field/ ) } | |
501 | 501 | self.settings[:custom_enterprise_fields].each_pair do |key, value| |
502 | 502 | if value['required'] == 'true' |
503 | 503 | self.settings[:custom_enterprise_fields][key]['active'] = 'true' |
... | ... | @@ -509,6 +509,16 @@ class Environment < ActiveRecord::Base |
509 | 509 | end |
510 | 510 | end |
511 | 511 | |
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 | + | |
512 | 522 | def custom_enterprise_field(field, status) |
513 | 523 | if (custom_enterprise_fields[field] && custom_enterprise_fields[field][status] == 'true') |
514 | 524 | return true |
... | ... | @@ -539,8 +549,13 @@ class Environment < ActiveRecord::Base |
539 | 549 | def custom_community_fields |
540 | 550 | self.settings[:custom_community_fields].nil? ? {} : self.settings[:custom_community_fields] |
541 | 551 | end |
552 | + | |
542 | 553 | def custom_community_fields=(values) |
543 | - self.settings[:custom_community_fields] = values.delete_if { |key, value| ! Community.fields.include?(key) } | |
554 | + self.settings[:custom_community_fields] = values.delete_if { |key, value| | |
555 | + ! ( Community.fields.include?(key) || key =~ /^custom_field/ ) | |
556 | + } | |
557 | + | |
558 | + | |
544 | 559 | self.settings[:custom_community_fields].each_pair do |key, value| |
545 | 560 | if value['required'] == 'true' |
546 | 561 | self.settings[:custom_community_fields][key]['active'] = 'true' |
... | ... | @@ -552,6 +567,16 @@ class Environment < ActiveRecord::Base |
552 | 567 | end |
553 | 568 | end |
554 | 569 | |
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 | + | |
555 | 580 | def custom_community_field(field, status) |
556 | 581 | if (custom_community_fields[field] && custom_community_fields[field][status] == 'true') |
557 | 582 | return true | ... | ... |
app/models/organization.rb
1 | 1 | # Represents any organization of the system |
2 | 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 | |
4 | + attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name, :enable_contact_us #, :custom_fields | |
5 | 5 | |
6 | 6 | SEARCH_FILTERS += %w[ |
7 | 7 | more_popular |
... | ... | @@ -13,6 +13,12 @@ class Organization < Profile |
13 | 13 | closed |
14 | 14 | end |
15 | 15 | |
16 | + #settings_items :custom_fields | |
17 | + | |
18 | + #def custom_field_value(field) | |
19 | + # self.custom_fields[field] | |
20 | + #end | |
21 | + | |
16 | 22 | before_save do |organization| |
17 | 23 | organization.closed = true if !organization.public_profile? |
18 | 24 | end | ... | ... |
app/models/person.rb
1 | 1 | # A person is the profile of an user holding all relationships with the rest of the system |
2 | 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 | |
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 | |
5 | 5 | |
6 | 6 | SEARCH_FILTERS += %w[ |
7 | 7 | more_popular |
... | ... | @@ -205,6 +205,12 @@ class Person < Profile |
205 | 205 | N_('Contact information'); N_('City'); N_('State'); N_('Country'); N_('Sex'); N_('Zip code'); N_('District'); N_('Address reference') |
206 | 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 | + | |
208 | 214 | extend SetProfileRegionFromCityState::ClassMethods |
209 | 215 | set_profile_region_from_city_state |
210 | 216 | ... | ... |
app/models/profile.rb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | # which by default is the one returned by Environment:default. |
4 | 4 | class Profile < ActiveRecord::Base |
5 | 5 | |
6 | - attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login | |
6 | + attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login, :custom_fields | |
7 | 7 | |
8 | 8 | # use for internationalizable human type names in search facets |
9 | 9 | # reimplement on subclasses |
... | ... | @@ -23,6 +23,12 @@ class Profile < ActiveRecord::Base |
23 | 23 | |
24 | 24 | SEARCH_DISPLAYS = %w[compact] |
25 | 25 | |
26 | + settings_items :custom_fields, :default => {} | |
27 | + | |
28 | + def custom_field_value(key) | |
29 | + self.custom_fields[key] | |
30 | + end | |
31 | + | |
26 | 32 | def self.default_search_display |
27 | 33 | 'compact' |
28 | 34 | end | ... | ... |
app/views/features/_manage_community_fields.html.erb
... | ... | @@ -12,46 +12,73 @@ |
12 | 12 | <td> |
13 | 13 | <%= _("Check/Uncheck All")%> |
14 | 14 | </td> |
15 | - <td> | |
15 | + <td align="center"> | |
16 | 16 | <input type="checkbox" id="community_active" /> |
17 | 17 | </td> |
18 | - <td> | |
18 | + <td align="center"> | |
19 | 19 | <input type="checkbox" id="community_required" /> |
20 | 20 | </td> |
21 | - <td> | |
21 | + <td align="center"> | |
22 | 22 | <input type="checkbox" id="community_signup" /> |
23 | 23 | </td> |
24 | + <td> </td> | |
24 | 25 | </tr> |
25 | 26 | |
26 | 27 | <% @community_fields.each do |field| %> |
27 | 28 | <tr> |
28 | 29 | <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
29 | - | |
30 | - <td> | |
30 | + <td align="center"> | |
31 | 31 | <%= hidden_field_tag "community_fields[#{field}][active]", false %> |
32 | 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 | 33 | </td> |
34 | - <td> | |
34 | + <td align="center"> | |
35 | 35 | <%= hidden_field_tag "community_fields[#{field}][required]", false %> |
36 | 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 | 37 | </td> |
38 | - <td> | |
38 | + <td align="center"> | |
39 | 39 | <%= hidden_field_tag "community_fields[#{field}][signup]", false %> |
40 | 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 | 41 | </td> |
42 | + </tr> | |
43 | + <% end %> | |
42 | 44 | |
45 | + <% @custom_community_fields.each do |field| %> | |
46 | + <tr> | |
47 | + <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 %> | |
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]')" %> | |
53 | + </td> | |
54 | + <td align="center"> | |
55 | + <%= 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]')" %> | |
57 | + </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> | |
63 | + <a href="#" class="button icon-delete delete-link-list-row" title="Delete" onclick="return remove_custom_field(this);"><span>Delete</span></a> | |
64 | + </td> | |
43 | 65 | </tr> |
44 | 66 | <% end %> |
67 | + | |
45 | 68 | </table> |
46 | 69 | |
70 | +<br /> | |
71 | + | |
72 | +<%= link_to_function(_('Add field'), "add_new_field('community');", :class => 'button icon-add with-text') %> | |
73 | + | |
47 | 74 | <script type='text/javascript'> |
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 | - } | |
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 | + //} | |
55 | 82 | </script> |
56 | 83 | |
57 | 84 | <div> | ... | ... |
app/views/features/_manage_enterprise_fields.html.erb
... | ... | @@ -12,13 +12,13 @@ |
12 | 12 | <td> |
13 | 13 | <%= _("Check/Uncheck All")%> |
14 | 14 | </td> |
15 | - <td> | |
15 | + <td align="center"> | |
16 | 16 | <input type="checkbox" id="enterprise_active" /> |
17 | 17 | </td> |
18 | - <td> | |
18 | + <td align="center"> | |
19 | 19 | <input type="checkbox" id="enterprise_required" /> |
20 | 20 | </td> |
21 | - <td> | |
21 | + <td align="center"> | |
22 | 22 | <input type="checkbox" id="enterprise_signup" /> |
23 | 23 | </td> |
24 | 24 | </tr> |
... | ... | @@ -27,31 +27,59 @@ |
27 | 27 | <tr> |
28 | 28 | |
29 | 29 | <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> |
30 | - <td> | |
30 | + <td align="center"> | |
31 | 31 | <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> |
32 | 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 | 33 | </td> |
34 | - <td> | |
34 | + <td align="center"> | |
35 | 35 | <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> |
36 | 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 | 37 | </td> |
38 | - <td> | |
38 | + <td align="center"> | |
39 | 39 | <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> |
40 | 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 | 41 | </td> |
42 | 42 | |
43 | 43 | </tr> |
44 | 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 | + | |
45 | 69 | </table> |
46 | 70 | |
71 | +<br /> | |
72 | + | |
73 | +<%= link_to_function(_('Add field'), "add_new_field('enterprise');", :class => 'button icon-add with-text') %> | |
74 | + | |
47 | 75 | <script type='text/javascript'> |
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 | - } | |
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 | + //} | |
55 | 83 | </script> |
56 | 84 | |
57 | 85 | <div> | ... | ... |
app/views/features/_manage_person_fields.html.erb
... | ... | @@ -71,19 +71,18 @@ |
71 | 71 | |
72 | 72 | <br /> |
73 | 73 | |
74 | -<%= link_to_function(_('Add field'), 'add_new_field();', :class => 'button icon-add with-text') %> | |
75 | - | |
76 | -<%= javascript_include_tag 'edit-profile-fields.js' %> | |
77 | - | |
78 | -<script type='text/javascript'>// <!-- | |
79 | - var trs = jQuery('#person_fields_conf tr'); | |
80 | - | |
81 | - var tr, td2; | |
82 | - for ( var i=2; tr=trs[i]; i++ ) { | |
83 | - if ( td2 = tr.getElementsByTagName('td')[1] ) { | |
84 | - td2.getElementsByTagName('input')[1].onclick(); | |
85 | - } | |
86 | - } | |
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'); | |
79 | + | |
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 | + //} | |
87 | 86 | // --> |
88 | 87 | </script> |
89 | 88 | ... | ... |
app/views/profile_editor/_organization.html.erb
... | ... | @@ -60,8 +60,12 @@ |
60 | 60 | </div> |
61 | 61 | <% end %> |
62 | 62 | |
63 | +<hr /> | |
64 | + | |
63 | 65 | <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'profile_data', :profile => @profile } %> |
64 | 66 | |
67 | +<hr /> | |
68 | + | |
65 | 69 | <%= labelled_check_box(_('Enable "contact us"'), 'profile_data[enable_contact_us]', "1", @profile.enable_contact_us) if @profile.enterprise? %> |
66 | 70 | |
67 | 71 | <%= render :partial => 'moderation', :locals => { :profile => @profile } %> | ... | ... |
app/views/profile_editor/_person_form.html.erb
... | ... | @@ -7,6 +7,17 @@ |
7 | 7 | </div> |
8 | 8 | <% end %> |
9 | 9 | |
10 | +<% @environment.custom_person_fields_customs.each { |k| %> | |
11 | + <% optional_field(@person, k) do %> | |
12 | + <div class="formfieldline"> | |
13 | + <%= label_tag environment.custom_person_field_name(k), nil, class: 'formlabel' %> | |
14 | + <div class="formfield type-select"> | |
15 | + <%= text_field_tag("profile_data[custom_fields][#{k}]", @person.custom_field_value(k)) %> | |
16 | + </div> | |
17 | + </div> | |
18 | + <% end %> | |
19 | +<% } %> | |
20 | + | |
10 | 21 | <%= optional_field(@person, 'description', f.text_area(:description, :rows => 5, :rel => _('Description'))) %> |
11 | 22 | <%= optional_field(@person, 'preferred_domain', select_preferred_domain(:profile_data)) %> |
12 | 23 | <%= optional_field(@person, 'contact_information', f.text_field(:contact_information, :rel => _('Contact information'))) %> |
... | ... | @@ -65,13 +76,3 @@ |
65 | 76 | <%= optional_field(@person, 'organization', f.text_field(:organization, :rel => _('Organization'))) %> |
66 | 77 | <%= optional_field(@person, 'organization_website', f.text_field(:organization_website, :rel => _('Organization website'))) %> |
67 | 78 | |
68 | -<hr /> | |
69 | - | |
70 | -<% @environment.custom_person_fields_customs.each { |k| %> | |
71 | - <br /> | |
72 | - <%= label_tag environment.custom_person_field_name(k) %> | |
73 | - <%= optional_field(@person, k, text_field_tag("profile_data[#{k}]")) %> | |
74 | - <br /> | |
75 | -<% } %> | |
76 | - | |
77 | -<hr /> | ... | ... |
app/views/shared/_organization_custom_fields.html.erb
... | ... | @@ -30,3 +30,22 @@ |
30 | 30 | <%= optional_field(profile, 'foundation_year', f.text_field(:foundation_year)) %> |
31 | 31 | <% end %> |
32 | 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 /> | ... | ... |
public/javascripts/edit-profile-fields.js
... | ... | @@ -1,105 +0,0 @@ |
1 | -function send_ajax(source_url) { | |
2 | - jQuery(".link-address").autocomplete({ | |
3 | - source : function(request, response){ | |
4 | - jQuery.ajax({ | |
5 | - type: "GET", | |
6 | - url: source_url, | |
7 | - data: {query: request.term}, | |
8 | - success: function(result){ | |
9 | - response(result); | |
10 | - }, | |
11 | - error: function(ajax, stat, errorThrown) { | |
12 | - console.log('Link not found : ' + errorThrown); | |
13 | - } | |
14 | - }); | |
15 | - }, | |
16 | - | |
17 | - minLength: 3 | |
18 | - }); | |
19 | -} | |
20 | - | |
21 | -function new_field_action(){ | |
22 | - send_ajax(jQuery("#page_url").val()); | |
23 | - | |
24 | - jQuery(".delete-link-list-row").click(function(){ | |
25 | - jQuery(this).parent().parent().remove(); | |
26 | - return false; | |
27 | - }); | |
28 | - | |
29 | - jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop()); | |
30 | -} | |
31 | - | |
32 | -function remove_custom_field(element) { | |
33 | - jQuery(element).parent().parent().remove(); | |
34 | - return false; | |
35 | -} | |
36 | - | |
37 | -function add_new_field() { | |
38 | - | |
39 | - last_row = jQuery('#person_fields_conf > tbody:last tr:last'); | |
40 | - | |
41 | - if ( last_row.find('label').length == 1 ) { | |
42 | - | |
43 | - var row = '<tr>' + | |
44 | - '<td>' + | |
45 | - '<input id="person_fields_custom_field_1_name" maxlength="20" name="person_fields[custom_field_1][name]" type="text" />' + | |
46 | - '</td>' + | |
47 | - '<td align="center"> ' + | |
48 | - '<input id="person_fields_custom_field_1_active" name="person_fields[custom_field_1][active]" type="hidden" value="false" /> ' + | |
49 | - '<input id="person_fields_custom_field_1_active" name="person_fields[custom_field_1][active]" type="checkbox" value="false" /> ' + | |
50 | - '</td> ' + | |
51 | - '<td align="center"> ' + | |
52 | - '<input id="person_fields_custom_field_1_required" name="person_fields[custom_field_1][required]" type="hidden" value="false" /> ' + | |
53 | - '<input id="person_fields_custom_field_1_required" name="person_fields[custom_field_1][required]" type="checkbox" value="true" /> ' + | |
54 | - '</td> ' + | |
55 | - '<td align="center"> ' + | |
56 | - '<input id="person_fields_custom_field_1_signup" name="person_fields[custom_field_1][signup]" type="hidden" value="false" /> ' + | |
57 | - '<input id="person_fields_custom_field_1_signup" name="person_fields[custom_field_1][signup]" type="checkbox" value="true" /> ' + | |
58 | - '</td> ' + | |
59 | - '<td> ' + | |
60 | - '<a href="#" class="button icon-delete delete-link-list-row" title="Delete" onclick="return remove_custom_field(this);"><span>Delete</span></a> ' + | |
61 | - '</td> ' + | |
62 | - '</tr>'; | |
63 | - | |
64 | - jQuery('#person_fields_conf > tbody:last').append(row); | |
65 | - | |
66 | - } | |
67 | - else { | |
68 | - | |
69 | - var new_field = jQuery('#person_fields_conf > tbody:last tr:last').clone(); | |
70 | - | |
71 | - var field = new_field.find('input'); | |
72 | - //var chkboxes = field.filter(':checkbox'); | |
73 | - | |
74 | - var re = new RegExp( '\\d', 'g' ); | |
75 | - var id = field.attr('id').match(re); | |
76 | - var next_id = parseInt(id) + 1; | |
77 | - | |
78 | - jQuery.each( field, function( k, v ) { | |
79 | - v.id = v.id.replace(id, next_id); | |
80 | - v.name = v.name.replace(id, next_id); | |
81 | - if (v.type == 'text') { v.value = '' } | |
82 | - if (v.type == 'checkbox') { v.value = true; } | |
83 | - if (v.type == 'hidden') { v.value = false; } | |
84 | - | |
85 | - }); | |
86 | - | |
87 | - //field.val(''); | |
88 | - | |
89 | - //chkboxes.attr('onclick', chkboxes.attr('onclick').replace(id, next_id)); | |
90 | - //console.log( chkboxes ); | |
91 | - | |
92 | - jQuery('#person_fields_conf > tbody').append(new_field); | |
93 | - | |
94 | - } | |
95 | - | |
96 | -} | |
97 | - | |
98 | -jQuery(document).ready(function(){ | |
99 | - new_field_action(); | |
100 | - | |
101 | - //jQuery("#dropable-link-list").sortable({ | |
102 | - // revert: true, | |
103 | - // axis: "y" | |
104 | - //}); | |
105 | -}); |
public/javascripts/manage-fields.js
1 | +/** | |
1 | 2 | function update_active(name_active, name_required, name_signup) { |
2 | 3 | var required = jQuery("input[name='" + name_required + "']")[1] |
3 | 4 | var signup = jQuery("input[name='" + name_signup + "']")[1] |
... | ... | @@ -6,15 +7,16 @@ function update_active(name_active, name_required, name_signup) { |
6 | 7 | if(required.checked || signup.checked) |
7 | 8 | active.checked = true |
8 | 9 | } |
9 | - | |
10 | 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] | |
11 | + console.log( 'teste1' ); | |
12 | + //var required = jQuery("input[name='" + name_required + "']")[0] | |
13 | + //var signup = jQuery("input[name='" + name_signup + "']")[0] | |
13 | 14 | |
14 | - required.disabled = signup.disabled = !obj_active.checked | |
15 | + //required.disabled = signup.disabled = !obj_active.checked | |
15 | 16 | } |
16 | 17 | |
17 | 18 | function required_action(name_active, name_required, name_signup) { |
19 | + console.log( 'teste' ); | |
18 | 20 | var obj_required = jQuery("input[name='" + name_required + "']")[1] |
19 | 21 | |
20 | 22 | if(obj_required.checked) { |
... | ... | @@ -36,7 +38,6 @@ function signup_action(name_active, name_required, name_signup) { |
36 | 38 | update_active(name_active, name_required, name_signup) |
37 | 39 | } |
38 | 40 | |
39 | - | |
40 | 41 | jQuery(document).ready(function(){ |
41 | 42 | function check_fields(check, table_id, start) { |
42 | 43 | var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") |
... | ... | @@ -81,3 +82,114 @@ jQuery(document).ready(function(){ |
81 | 82 | } |
82 | 83 | }) |
83 | 84 | }) |
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 | + return false; | |
123 | +} | |
124 | + | |
125 | +function add_new_field(profile_type) { | |
126 | + | |
127 | + console.log( profile_type ); | |
128 | + | |
129 | + last_row = jQuery('#' + profile_type + '_fields_conf > tbody:last tr:last'); | |
130 | + | |
131 | + if ( last_row.find('label').length == 1 ) { | |
132 | + | |
133 | + var row = '<tr>' + | |
134 | + '<td>' + | |
135 | + '<input id="' + profile_type + '_fields_custom_field_1_name" maxlength="20" name="' + profile_type + '_fields[custom_field_1][name]" type="text" />' + | |
136 | + '</td>' + | |
137 | + '<td align="center"> ' + | |
138 | + '<input id="' + profile_type + '_fields_custom_field_1_active" name="' + profile_type + '_fields[custom_field_1][active]" type="hidden" value="false" /> ' + | |
139 | + '<input id="' + profile_type + '_fields_custom_field_1_active" name="' + profile_type + '_fields[custom_field_1][active]" type="checkbox" value="false" /> ' + | |
140 | + '</td> ' + | |
141 | + '<td align="center"> ' + | |
142 | + '<input id="' + profile_type + '_fields_custom_field_1_required" name="' + profile_type + '_fields[custom_field_1][required]" type="hidden" value="false" /> ' + | |
143 | + '<input id="' + profile_type + '_fields_custom_field_1_required" name="' + profile_type + '_fields[custom_field_1][required]" type="checkbox" value="true" /> ' + | |
144 | + '</td> ' + | |
145 | + '<td align="center"> ' + | |
146 | + '<input id="' + profile_type + '_fields_custom_field_1_signup" name="' + profile_type + '_fields[custom_field_1][signup]" type="hidden" value="false" /> ' + | |
147 | + '<input id="' + profile_type + '_fields_custom_field_1_signup" name="' + profile_type + '_fields[custom_field_1][signup]" type="checkbox" value="true" /> ' + | |
148 | + '</td> ' + | |
149 | + '<td> ' + | |
150 | + '<a href="#" class="button icon-delete delete-link-list-row" title="Delete" onclick="return remove_custom_field(this);"><span>Delete</span></a> ' + | |
151 | + '</td> ' + | |
152 | + '</tr>'; | |
153 | + | |
154 | + jQuery('#' + profile_type + '_fields_conf > tbody:last').append(row); | |
155 | + | |
156 | + } | |
157 | + else { | |
158 | + | |
159 | + var new_field = jQuery('#' + profile_type + '_fields_conf > tbody:last tr:last').clone(); | |
160 | + | |
161 | + var field = new_field.find('input'); | |
162 | + //var chkboxes = field.filter(':checkbox'); | |
163 | + | |
164 | + var re = new RegExp( '\\d', 'g' ); | |
165 | + var id = field.attr('id').match(re); | |
166 | + var next_id = parseInt(id) + 1; | |
167 | + | |
168 | + jQuery.each( field, function( k, v ) { | |
169 | + v.id = v.id.replace(id, next_id); | |
170 | + v.name = v.name.replace(id, next_id); | |
171 | + if (v.type == 'text') { v.value = '' } | |
172 | + if (v.type == 'checkbox') { v.value = true; } | |
173 | + if (v.type == 'hidden') { v.value = false; } | |
174 | + | |
175 | + }); | |
176 | + | |
177 | + //field.val(''); | |
178 | + | |
179 | + //chkboxes.attr('onclick', chkboxes.attr('onclick').replace(id, next_id)); | |
180 | + //console.log( chkboxes ); | |
181 | + | |
182 | + jQuery('#' + profile_type + '_fields_conf > tbody').append(new_field); | |
183 | + | |
184 | + } | |
185 | + | |
186 | +} | |
187 | + | |
188 | +jQuery(document).ready(function(){ | |
189 | + new_field_action(); | |
190 | + | |
191 | + //jQuery("#dropable-link-list").sortable({ | |
192 | + // revert: true, | |
193 | + // axis: "y" | |
194 | + //}); | |
195 | +}); | ... | ... |