Module: ContactableHelper
- Defined in:
- app/helpers/contactable_helper.rb
Instance Method Summary collapse
-
#add_new_record_link(record, name, form_builder) ⇒ Object
Helpers for contact nested forms.
- #address_label(address) ⇒ Object
- #email_label(email) ⇒ Object
- #identification_label(identification) ⇒ Object
- #instant_messenger_label(instant_messenger) ⇒ Object
- #phone_label(phone) ⇒ Object
-
#remove_link_unless_new_record(fields) ⇒ Object
remove link.
- #website_label(website) ⇒ Object
Instance Method Details
#add_new_record_link(record, name, form_builder) ⇒ Object
Helpers for contact nested forms
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/contactable_helper.rb', line 27 def add_new_record_link(record, name, form_builder) name = name.to_s plural_name = name.pluralize link_to_function "add a new #{name}", :class => 'add' do |page| new_record = record.send(plural_name).build form_builder.semantic_fields_for plural_name, new_record, :child_index => 'NEW_RECORD' do |p| html = "<fieldset class='inputs'><ol>#{render(:partial => plural_name + '/' + name, :locals => { :f => p, name.to_sym => new_record })}</ol></fieldset>" page << "$('##{plural_name}').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()));" end end end |
#address_label(address) ⇒ Object
10 11 12 |
# File 'app/helpers/contactable_helper.rb', line 10 def address_label(address) "#{address.type ? address.type.name : nil} - #{address.full_address}" end |
#email_label(email) ⇒ Object
14 15 16 |
# File 'app/helpers/contactable_helper.rb', line 14 def email_label(email) "#{email.type ? email.type.name : nil} - #{email.address}" end |
#identification_label(identification) ⇒ Object
2 3 4 |
# File 'app/helpers/contactable_helper.rb', line 2 def identification_label(identification) "#{identification.type ? identification.type.name : nil} - #{identification.code}" end |
#instant_messenger_label(instant_messenger) ⇒ Object
22 23 24 |
# File 'app/helpers/contactable_helper.rb', line 22 def instant_messenger_label(instant_messenger) "#{instant_messenger.type ? instant_messenger.type.name : nil} - #{instant_messenger.protocol ? instant_messenger.protocol.name : nil} - #{instant_messenger.nick}" end |
#phone_label(phone) ⇒ Object
6 7 8 |
# File 'app/helpers/contactable_helper.rb', line 6 def phone_label(phone) "#{phone.type ? phone.type.name : nil} - #{phone.number}" end |
#remove_link_unless_new_record(fields) ⇒ Object
remove link
40 41 42 43 44 45 |
# File 'app/helpers/contactable_helper.rb', line 40 def remove_link_unless_new_record(fields) out = '' out << fields.hidden_field(:_delete) unless fields.object.new_record? out << link_to_function("remove", "$(this).parent().parent().hide(); $(this).siblings('input[type=hidden]')[0].value = 1;", :class => 'remove') out end |
#website_label(website) ⇒ Object
18 19 20 |
# File 'app/helpers/contactable_helper.rb', line 18 def website_label(website) "#{website.type ? website.type.name : nil} - #{website.address}" end |