e9_crm 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/helpers/e9_crm/contacts_helper.rb +60 -6
- data/app/models/address_attribute.rb +3 -0
- data/app/models/company.rb +1 -0
- data/app/models/contact.rb +5 -2
- data/app/views/e9_crm/contacts/_contact.html.haml +18 -1
- data/app/views/e9_crm/contacts/_details.html.haml +6 -17
- data/app/views/e9_crm/contacts/_header.html.haml +10 -8
- data/app/views/e9_crm/contacts/_sidebar.html.haml +38 -0
- data/app/views/e9_crm/contacts/_tag_table.html.haml +4 -4
- data/app/views/e9_crm/contacts/_who.html.haml +5 -4
- data/app/views/e9_crm/contacts/show.html.haml +24 -0
- data/config/locales/en.yml +7 -2
- data/lib/e9_crm/model.rb +1 -1
- data/lib/e9_crm/version.rb +1 -1
- metadata +4 -3
- data/app/views/e9_crm/contacts/merge.html.haml +0 -1
@@ -1,21 +1,75 @@
|
|
1
1
|
module E9Crm::ContactsHelper
|
2
2
|
|
3
|
+
def contact_tags
|
4
|
+
@_contact_tags ||= begin
|
5
|
+
relation = Tagging.joins(:tag).select('distinct tags.name')
|
6
|
+
.where(:context => E9Tags.escape_context('users*'))
|
7
|
+
|
8
|
+
Tagging.connection.send(:select_values, relation.to_sql, 'Contact Tags Select')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def link_to_google(query, opts = {})
|
13
|
+
return unless query.present?
|
14
|
+
|
15
|
+
opts.symbolize_keys!
|
16
|
+
opts.reverse_merge!({
|
17
|
+
:base_url => 'http://google.com/search?q=%s',
|
18
|
+
:exact => true,
|
19
|
+
:text => :search
|
20
|
+
})
|
21
|
+
|
22
|
+
opts[:text] = I18n.t(opts[:text]) if opts[:text].is_a?(Symbol)
|
23
|
+
|
24
|
+
query = query.to_s
|
25
|
+
query = "\"#{query}\"" if query =~ /\s/ && opts[:exact]
|
26
|
+
query = CGI.escape(query)
|
27
|
+
link_to opts[:text], opts[:base_url] % query, :rel => 'nofollow external'
|
28
|
+
end
|
29
|
+
|
30
|
+
def google_search_link(query, opts = {})
|
31
|
+
link_to_google query, opts
|
32
|
+
end
|
33
|
+
|
34
|
+
def google_news_link(query, opts = {})
|
35
|
+
link_to_google query, opts.merge(:text => :news, :base_url => "http://news.google.com/news/search?q=%s")
|
36
|
+
end
|
37
|
+
|
38
|
+
def google_maps_link(query, opts = {})
|
39
|
+
link_to_google query, opts.merge(:text => :map, :exact => false, :base_url => "http://maps.google.com/maps?q=%s")
|
40
|
+
end
|
41
|
+
|
42
|
+
def contact_simple_format(text)
|
43
|
+
auto_link(
|
44
|
+
simple_format(text),
|
45
|
+
:html => { :rel => 'external nofollow' },
|
46
|
+
:link => :urls
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
3
50
|
def link_to_contact_search(attribute, query, text = nil)
|
4
51
|
link_to(text || query, contacts_path(attribute => query), :class => "contact-search contact-#{attribute.to_s.dasherize}-search")
|
5
52
|
end
|
6
53
|
|
7
|
-
def
|
8
|
-
|
54
|
+
def contact_tag_list(tags)
|
55
|
+
tags.map {|tag| link_to_contact_search(:tagged, [tag], tag) }.join(', ').html_safe
|
56
|
+
end
|
57
|
+
|
58
|
+
def contact_newsletter_select_tag
|
59
|
+
options = UserEmail.pending.order('name').map {|e| [e.name, e.id] }
|
60
|
+
#select_tag 'eid', options_for_select( options.presence || [['n/a', nil]] )
|
61
|
+
select_tag 'eid', options_for_select(options) if options.present?
|
9
62
|
end
|
10
63
|
|
11
|
-
def
|
12
|
-
|
64
|
+
def contact_email_template_select_tag
|
65
|
+
options = EmailTemplate.order('name').map {|e| [e.name, e.id] }
|
66
|
+
#select_tag 'etid', options_for_select( options.presence || [['n/a', nil]] )
|
67
|
+
select_tag 'etid', options_for_select(options) if options.present?
|
13
68
|
end
|
14
69
|
|
15
70
|
def contact_user_subscribed_to_newsletter?(user)
|
16
71
|
@_newsletter ||= MailingList.newsletter
|
17
|
-
|
18
|
-
user.subscription_ids.include? @_newsletter.id
|
72
|
+
@_newsletter && user.subscription_ids.include?(@_newsletter.id)
|
19
73
|
end
|
20
74
|
|
21
75
|
def records_table_field_map_for_contact
|
data/app/models/company.rb
CHANGED
data/app/models/contact.rb
CHANGED
@@ -129,11 +129,14 @@ class Contact < ActiveRecord::Base
|
|
129
129
|
AND record_attributes.record_type = 'Contact'
|
130
130
|
LEFT OUTER JOIN users AS contacts_users
|
131
131
|
ON contacts_users.contact_id = contacts.id
|
132
|
+
LEFT OUTER JOIN companies
|
133
|
+
ON companies.id = contacts.company_id
|
132
134
|
}
|
133
135
|
|
134
136
|
where_sql = any_attrs_like_scope_conditions(:first_name, :last_name, :title, query)
|
135
137
|
.or(RecordAttribute.attr_like_scope_condition(:value, query))
|
136
|
-
.
|
138
|
+
.or(Company.attr_like_scope_condition(:name, query))
|
139
|
+
.to_sql.gsub(/\s+/, ' ')
|
137
140
|
|
138
141
|
ucond = sanitize_sql_array(['contacts_users.email like ?', "%#{query}%"])
|
139
142
|
where_sql << " OR (#{ucond})"
|
@@ -186,7 +189,7 @@ class Contact < ActiveRecord::Base
|
|
186
189
|
# Helper to concatenate a Contact's full name
|
187
190
|
#
|
188
191
|
def name
|
189
|
-
[first_name, last_name].join(' ')
|
192
|
+
[first_name, last_name].join(' ').to_s.strip
|
190
193
|
end
|
191
194
|
|
192
195
|
def merge_and_destroy!(other_contact)
|
@@ -1 +1,18 @@
|
|
1
|
-
|
1
|
+
-#.contact-deals
|
2
|
+
-#%h2
|
3
|
+
-#= Deal.model_name.human.pluralize
|
4
|
+
-#= link_to_new_resource(Deal, :deal => {:contact_id => resource.id })
|
5
|
+
-#- resource.deals.each do |deal|
|
6
|
+
-#.contact-deal
|
7
|
+
-#.contact-deal-status
|
8
|
+
-#= deal.status
|
9
|
+
-#.contact-deal-type
|
10
|
+
-#= deal.type.titleize
|
11
|
+
-#.contact-deal-value
|
12
|
+
-#= deal.value
|
13
|
+
-#.contact-leads
|
14
|
+
-#%h2
|
15
|
+
-#= Lead.model_name.human.pluralize
|
16
|
+
-#- resource.leads.each do |lead|
|
17
|
+
-#.contact-lead
|
18
|
+
-#.contact-lead-type
|
@@ -1,26 +1,15 @@
|
|
1
1
|
= render 'who', :record => record
|
2
2
|
|
3
|
-
- if record.
|
3
|
+
- if record.phone_number_attributes.any?
|
4
4
|
.contact-phone-numbers
|
5
|
+
- record.phone_number_attributes.each do |phone_number_attribute|
|
6
|
+
.contact-phone-number= phone_number_attribute
|
7
|
+
|
8
|
+
- if record.users.any?
|
9
|
+
.contact-emails
|
5
10
|
- record.users.each do |user|
|
6
11
|
.contact-email
|
7
12
|
= '* ' if contact_user_subscribed_to_newsletter?(user)
|
8
13
|
= link_to(user.email, "mailto:#{user.email}")
|
9
14
|
= "(#{user.options.type})" if user.options.type
|
10
15
|
= "(primary)" if user.primary?
|
11
|
-
|
12
|
-
- if record.phone_number_attributes.any?
|
13
|
-
.contact-phone-numbers
|
14
|
-
- record.phone_number_attributes.each do |phone_number_attribute|
|
15
|
-
.contact-phone-number= phone_number_attribute
|
16
|
-
|
17
|
-
- if record.instant_messaging_handle_attributes.any?
|
18
|
-
.contact-im-handles
|
19
|
-
- record.instant_messaging_handle_attributes.each do |instant_messaging_handle_attribute|
|
20
|
-
.contact-im-handle= instant_messaging_handle_attribute
|
21
|
-
|
22
|
-
- if record.website_attributes.any?
|
23
|
-
.contact-websites
|
24
|
-
- record.website_attributes.each do |website_attribute|
|
25
|
-
.contact-website
|
26
|
-
= auto_link(website_attribute.to_s, :rel => "external nofollow")
|
@@ -7,14 +7,16 @@
|
|
7
7
|
= submit_tag t(:go), :name => nil
|
8
8
|
= submit_tag t(:clear), :name => nil, :id => 'contact_search_clear'
|
9
9
|
.toolbar-middle
|
10
|
-
|
11
|
-
=
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
=
|
17
|
-
|
10
|
+
- if (tag = contact_email_template_select_tag).present?
|
11
|
+
= form_tag new_contact_email_path, :method => :get, :id => 'contact_email_form', 'data-empty' => e9_t(:no_contacts_notification), 'data-count' => @contact_ids.length do
|
12
|
+
= tag
|
13
|
+
= hidden_field_tag 'uids', @contact_ids.join(','), :id => 'contact_email_uids'
|
14
|
+
= submit_tag e9_t(:send_email_template), :name => nil
|
15
|
+
- if (tag = contact_email_template_select_tag).present?
|
16
|
+
= form_tag send_email_admin_user_email_path('__ID__'), :method => :put, :id => 'contact_newsletter_form', 'data-confirm' => e9_t(:contact_newsletter_confirmation, :count => collection.length), 'data-empty' => e9_t(:no_contacts_notification), 'data-count' => @contact_ids.length do
|
17
|
+
= tag
|
18
|
+
= hidden_field_tag 'uids', @contact_ids.join(','), :id => 'contact_newsletter_uids'
|
19
|
+
= submit_tag e9_t(:send_email_newsletter), :name => nil
|
18
20
|
.toolbar-right
|
19
21
|
= link_to_new_resource(Contact)
|
20
22
|
= link_to_new_resource(Company)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
- if resource.phone_number_attributes.any?
|
2
|
+
.contact-phone-numbers
|
3
|
+
%label= Contact.human_attribute_name(:phone_number_attributes)
|
4
|
+
- resource.phone_number_attributes.each do |phone_number_attribute|
|
5
|
+
.contact-phone-number= phone_number_attribute
|
6
|
+
|
7
|
+
- if resource.users.any?
|
8
|
+
.contact-emails
|
9
|
+
%label= Contact.human_attribute_name(:users)
|
10
|
+
- resource.users.each do |user|
|
11
|
+
.contact-email
|
12
|
+
= '* ' if contact_user_subscribed_to_newsletter?(user)
|
13
|
+
= link_to(user.email, "mailto:#{user.email}")
|
14
|
+
= "(#{user.options.type})" if user.options.type
|
15
|
+
= "(primary)" if user.primary?
|
16
|
+
|
17
|
+
- if resource.instant_messaging_handle_attributes.any?
|
18
|
+
.contact-im-handles
|
19
|
+
%label= Contact.human_attribute_name(:instant_messaging_handle_attributes)
|
20
|
+
- resource.instant_messaging_handle_attributes.each do |instant_messaging_handle_attribute|
|
21
|
+
.contact-im-handle= instant_messaging_handle_attribute
|
22
|
+
|
23
|
+
- if resource.website_attributes.any?
|
24
|
+
.contact-websites
|
25
|
+
%label= Contact.human_attribute_name(:website_attributes)
|
26
|
+
- resource.website_attributes.each do |website_attribute|
|
27
|
+
.contact-website
|
28
|
+
= auto_link(website_attribute.to_s, :rel => "external nofollow")
|
29
|
+
|
30
|
+
- if resource.address_attributes.any?
|
31
|
+
.contact-addresses
|
32
|
+
%label= Contact.human_attribute_name(:address_attributes)
|
33
|
+
- resource.address_attributes.each do |address_attribute|
|
34
|
+
.contact-address
|
35
|
+
.address= address_attribute.to_html
|
36
|
+
.actions
|
37
|
+
= google_maps_link(address_attribute)
|
38
|
+
|
@@ -4,12 +4,12 @@
|
|
4
4
|
%th{:colspan => 2}
|
5
5
|
= t(:tags_name, :scope => :e9_tags)
|
6
6
|
%tbody
|
7
|
-
-
|
7
|
+
- contact_tags.sort.group_by {|tag| tag[0].upcase }.each do |letter, tags|
|
8
8
|
%tr
|
9
9
|
%td.tag-starts-with= letter
|
10
10
|
%td.tags
|
11
11
|
%ul.tags
|
12
|
-
- tags.
|
12
|
+
- tags.each do |tag|; tag_id = "tagged-#{tag.downcase.dasherize}"
|
13
13
|
%li.tag
|
14
|
-
= label_tag(tag_id, tag
|
15
|
-
= check_box_tag('tagged[]', tag
|
14
|
+
= label_tag(tag_id, tag)
|
15
|
+
= check_box_tag('tagged[]', tag, tagged_params.member?(tag), :id => tag_id)
|
@@ -1,14 +1,15 @@
|
|
1
1
|
.contact-who
|
2
|
-
|
2
|
+
- unless local_assigns[:hide_name]
|
3
|
+
%span.contact-who-name= record.name
|
3
4
|
|
4
|
-
|
5
|
+
= " - " if record.company_id? || record.title?
|
5
6
|
|
6
7
|
- if record.title?
|
7
8
|
%span.contact-who-title
|
8
|
-
= link_to_contact_search(:
|
9
|
+
= link_to_contact_search(:search, record.title)
|
9
10
|
|
10
11
|
= " at " if record.company_id? && record.title?
|
11
12
|
|
12
13
|
- if record.company_id?
|
13
14
|
%span.contact-who-company
|
14
|
-
= link_to_contact_search(:
|
15
|
+
= link_to_contact_search(:search, record.company_name)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
.contact-body
|
2
|
+
= title resource.name
|
3
|
+
= render 'who', :record => resource
|
4
|
+
.contact-links.actions
|
5
|
+
= link_to_edit_resource(resource)
|
6
|
+
= google_search_link(resource.name)
|
7
|
+
= google_news_link(resource.name)
|
8
|
+
- if (tags = resource.tags(:show_all => true)).present?
|
9
|
+
.contact-tags
|
10
|
+
%label #{Tag.model_name.human.pluralize}:
|
11
|
+
= contact_tag_list(tags)
|
12
|
+
.contact-info
|
13
|
+
%label #{Contact.human_attribute_name(:info)}:
|
14
|
+
= contact_simple_format(resource.info.presence || t(:none))
|
15
|
+
- if company = resource.company
|
16
|
+
.contact-company
|
17
|
+
%label= company.name
|
18
|
+
.contact-company-links.actions
|
19
|
+
= google_search_link(company.name)
|
20
|
+
= google_news_link(company.name)
|
21
|
+
- if company.info.present?
|
22
|
+
= contact_simple_format(text)
|
23
|
+
.contact-sidebar
|
24
|
+
= render 'sidebar'
|
data/config/locales/en.yml
CHANGED
@@ -7,6 +7,8 @@ en:
|
|
7
7
|
totals: Totals
|
8
8
|
inline_help_link: '[?]'
|
9
9
|
edit_dated_costs: Edit Costs
|
10
|
+
news: News
|
11
|
+
map: Map
|
10
12
|
|
11
13
|
e9_crm:
|
12
14
|
add_record_attribute: Add
|
@@ -64,7 +66,10 @@ en:
|
|
64
66
|
deal: Deal
|
65
67
|
page_view: Page View
|
66
68
|
tracking_cookie: Tracking Cookie
|
67
|
-
|
69
|
+
address_attribute: Address
|
70
|
+
instant_messaging_handle_attribute: IM Handle
|
71
|
+
phone_number_attrubute: Phone
|
72
|
+
website_attribute: Website
|
68
73
|
attributes:
|
69
74
|
campaign:
|
70
75
|
name: Name
|
@@ -73,7 +78,7 @@ en:
|
|
73
78
|
avatar: Photo
|
74
79
|
users: Email Addresses
|
75
80
|
address_attributes: Addresses
|
76
|
-
instant_messaging_handle_attributes:
|
81
|
+
instant_messaging_handle_attributes: IM Handles
|
77
82
|
phone_number_attrubutes: Phone Numbers
|
78
83
|
website_attributes: Websites
|
79
84
|
info: Background Information
|
data/lib/e9_crm/model.rb
CHANGED
data/lib/e9_crm/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: e9_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Travis Cox
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-19 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -214,11 +214,12 @@ files:
|
|
214
214
|
- app/views/e9_crm/contacts/_details.html.haml
|
215
215
|
- app/views/e9_crm/contacts/_form_inner.html.haml
|
216
216
|
- app/views/e9_crm/contacts/_header.html.haml
|
217
|
+
- app/views/e9_crm/contacts/_sidebar.html.haml
|
217
218
|
- app/views/e9_crm/contacts/_tag_table.html.haml
|
218
219
|
- app/views/e9_crm/contacts/_who.html.haml
|
219
220
|
- app/views/e9_crm/contacts/index.html.haml
|
220
221
|
- app/views/e9_crm/contacts/index.js.erb
|
221
|
-
- app/views/e9_crm/contacts/
|
222
|
+
- app/views/e9_crm/contacts/show.html.haml
|
222
223
|
- app/views/e9_crm/contacts/templates.js.erb
|
223
224
|
- app/views/e9_crm/dated_costs/_dated_cost.html.haml
|
224
225
|
- app/views/e9_crm/dated_costs/_form.html.haml
|
@@ -1 +0,0 @@
|
|
1
|
-
|