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_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
13 14 15 16 17 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 13 def = Company.select("companies.name, companies.id").ordered.all.map {|c| [c.name, c.id] } .unshift(['Any Company', nil]) (, params[:company]) end |
#contact_email_template_select_tag ⇒ Object
65 66 67 68 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 65 def contact_email_template_select_tag = UserEmail.bulk_sendable.order('name').map {|e| [e.name, e.id] } select_tag 'email_id', () if .present? end |
#contact_simple_format(text) ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 49 def contact_simple_format(text) auto_link( simple_format(text), :html => { :rel => 'external nofollow' }, :link => :urls ) end |
#contact_tag_list(tags) ⇒ Object
61 62 63 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 61 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 11 |
# 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*')) .order('tags.name ASC') Tagging.connection.send(:select_values, relation.to_sql, 'Contact Tags Select') end end |
#contact_user_subscribed_to_newsletter?(user) ⇒ Boolean
70 71 72 73 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 70 def (user) @_newsletter ||= MailingList. @_newsletter && user.subscription_ids.include?(@_newsletter.id) end |
#google_maps_link(query, opts = {}) ⇒ Object
45 46 47 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 45 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
41 42 43 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 41 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
37 38 39 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 37 def google_search_link(query, opts = {}) link_to_google query, opts end |
#link_to_contact_search(attribute, query, text = nil) ⇒ Object
57 58 59 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 57 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
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 19 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
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/helpers/e9_crm/contacts_helper.rb', line 75 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 |