Module: E9Crm::ContactsHelper
- Defined in:
- app/helpers/e9_crm/contacts_helper.rb
Instance Method Summary collapse
- #company_select_options ⇒ Object
- #contact_email_template_select_tag ⇒ Object
- #contact_newsletter_select_tag ⇒ Object
- #contact_simple_format(text) ⇒ Object
- #contact_tag_list(tags) ⇒ Object
- #contact_tags ⇒ Object
- #contact_user_subscribed_to_newsletter?(user) ⇒ Boolean
- #google_maps_link(query, opts = {}) ⇒ Object
- #google_news_link(query, opts = {}) ⇒ Object
- #google_search_link(query, opts = {}) ⇒ Object
- #link_to_contact_search(attribute, query, text = nil) ⇒ Object
- #link_to_google(query, opts = {}) ⇒ Object
- #records_table_field_map_for_contact ⇒ Object
Instance Method Details
#company_select_options ⇒ Object
12 13 14 15 16 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 12 def = Company.select('name', 'id').ordered.all.map {|c| [c.name, c.id] } .unshift(['Any Company', nil]) (, params[:company]) end |
#contact_email_template_select_tag ⇒ Object
70 71 72 73 74 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 70 def contact_email_template_select_tag = EmailTemplate.order('name').map {|e| [e.name, e.id] } #select_tag 'etid', options_for_select( options.presence || [['n/a', nil]] ) select_tag 'etid', () if .present? end |
#contact_newsletter_select_tag ⇒ Object
64 65 66 67 68 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 64 def = UserEmail.pending.order('name').map {|e| [e.name, e.id] } #select_tag 'eid', options_for_select( options.presence || [['n/a', nil]] ) select_tag 'eid', () if .present? end |
#contact_simple_format(text) ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 48 def contact_simple_format(text) auto_link( simple_format(text), :html => { :rel => 'external nofollow' }, :link => :urls ) end |
#contact_tag_list(tags) ⇒ Object
60 61 62 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 60 def contact_tag_list() .map {|tag| link_to_contact_search(:tagged, [tag], tag) }.join(', ').html_safe end |
#contact_tags ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 3 def @_contact_tags ||= begin relation = Tagging.joins(:tag).select('distinct tags.name') .where(:context => E9Tags.escape_context('users*')) Tagging.connection.send(:select_values, relation.to_sql, 'Contact Tags Select') end end |
#contact_user_subscribed_to_newsletter?(user) ⇒ Boolean
76 77 78 79 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 76 def (user) @_newsletter ||= MailingList. @_newsletter && user.subscription_ids.include?(@_newsletter.id) end |
#google_maps_link(query, opts = {}) ⇒ Object
44 45 46 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 44 def google_maps_link(query, opts = {}) link_to_google query, opts.merge(:text => :map, :exact => false, :base_url => "http://maps.google.com/maps?q=%s") end |
#google_news_link(query, opts = {}) ⇒ Object
40 41 42 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 40 def google_news_link(query, opts = {}) link_to_google query, opts.merge(:text => :news, :base_url => "http://news.google.com/news/search?q=%s") end |
#google_search_link(query, opts = {}) ⇒ Object
36 37 38 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 36 def google_search_link(query, opts = {}) link_to_google query, opts end |
#link_to_contact_search(attribute, query, text = nil) ⇒ Object
56 57 58 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 56 def link_to_contact_search(attribute, query, text = nil) link_to(text || query, contacts_path(attribute => query), :class => "contact-search contact-#{attribute.to_s.dasherize}-search") end |
#link_to_google(query, opts = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 18 def link_to_google(query, opts = {}) return unless query.present? opts.symbolize_keys! opts.reverse_merge!({ :base_url => 'http://google.com/search?q=%s', :exact => true, :text => :search }) opts[:text] = I18n.t(opts[:text]) if opts[:text].is_a?(Symbol) query = query.to_s query = "\"#{query}\"" if query =~ /\s/ && opts[:exact] query = CGI.escape(query) link_to opts[:text], opts[:base_url] % query, :rel => 'nofollow external' end |
#records_table_field_map_for_contact ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 81 def records_table_field_map_for_contact { :fields => { :avatar => proc {|r| link_to("<img src=\"#{r.avatar_url}\" alt=\"Avatar for #{r.name}\" />".html_safe, contact_path(r)) }, :details => proc {|r| render('details', :record => r) } }, :links => proc {|r| [ link_to_show_resource(r), link_to_edit_resource(r), link_to_destroy_resource(r) ]} } end |