ffcrm_cloudfuji 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/event_rules.js.coffee +55 -0
- data/app/assets/javascripts/ffcrm_cloudfuji.js +1 -1
- data/app/assets/stylesheets/event_rules.css.scss +53 -0
- data/app/assets/stylesheets/ffcrm_cloudfuji.css +1 -1
- data/app/controllers/admin/{lead_scoring_controller.rb → event_rules_controller.rb} +12 -12
- data/app/helpers/admin/event_rules_helper.rb +47 -0
- data/app/models/event_rule.rb +112 -0
- data/app/models/lead_event_rule_count.rb +4 -0
- data/app/observers/cloudfuji_lead_observer.rb +27 -0
- data/app/views/admin/{lead_scoring → event_rules}/_errors.html.haml +1 -1
- data/app/views/admin/event_rules/_form.html.haml +39 -0
- data/app/views/admin/{lead_scoring → event_rules}/index.html.haml +7 -7
- data/app/views/leads/_sidebar_show_lead_scoring.html.haml +3 -3
- data/config/locales/en-US.yml +5 -0
- data/config/routes.rb +1 -1
- data/db/migrate/20120524031157_extend_lead_scoring_as_event_rules.rb +54 -0
- data/db/migrate/20120525151511_add_ido_id_to_lead.rb +5 -0
- data/lib/fat_free_crm/cloudfuji/event_observers/customer_observer.rb +3 -1
- data/lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb +4 -2
- data/lib/fat_free_crm/cloudfuji/event_observers/event_rules_observer.rb +23 -0
- data/lib/fat_free_crm/cloudfuji/event_observers/user_observer.rb +6 -5
- data/lib/fat_free_crm/cloudfuji.rb +1 -1
- data/lib/ffcrm_cloudfuji/engine.rb +9 -4
- data/lib/ffcrm_cloudfuji/version.rb +1 -1
- data/spec/event_observers/event_rules_observer_spec.rb +103 -0
- data/spec/factories/lead_scoring_factories.rb +9 -3
- data/spec/internal/db/schema.rb +19 -13
- data/spec/models/event_rule_spec.rb +47 -0
- data/spec/observers/cloudfuji_lead_observer_spec.rb +26 -0
- metadata +80 -92
- data/app/assets/javascripts/lead_scoring.js.coffee +0 -42
- data/app/assets/stylesheets/lead_scoring.css.scss +0 -47
- data/app/helpers/admin/lead_scoring_helper.rb +0 -10
- data/app/models/lead_scoring_rule.rb +0 -6
- data/app/models/lead_scoring_rule_count.rb +0 -4
- data/app/views/admin/lead_scoring/_form.html.haml +0 -14
- data/config/initializers/inflections.rb +0 -3
- data/lib/fat_free_crm/cloudfuji/event_observers/lead_scoring_observer.rb +0 -38
- data/spec/event_observers/lead_scoring_observer_spec.rb +0 -87
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
include FatFreeCRM::Cloudfuji::EventObservers
|
4
|
+
|
5
|
+
describe EventRulesObserver do
|
6
|
+
before do
|
7
|
+
@observer = EventRulesObserver.new
|
8
|
+
@observer.params = {
|
9
|
+
'category' => 'customer',
|
10
|
+
'event' => 'had_tea',
|
11
|
+
"data" => {
|
12
|
+
"email" => "test_lead@example.com",
|
13
|
+
"type_of_tea" => "Jasmine"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_rule_count(lead, rule)
|
19
|
+
LeadEventRuleCount.find_by_lead_id_and_event_rule_id(lead, rule)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'Cloudfuji event received' do
|
23
|
+
describe 'Lead scoring' do
|
24
|
+
|
25
|
+
it "should increment a lead's score when an event is fired" do
|
26
|
+
user = FactoryGirl.create(:user, :ido_id => "1234")
|
27
|
+
@lead = FactoryGirl.create(:lead, :email => 'test_lead@example.com', :user => user, :campaign => nil)
|
28
|
+
|
29
|
+
@rule = FactoryGirl.create :event_rule,
|
30
|
+
:event_category => "cloudfuji_event_received",
|
31
|
+
:cloudfuji_event => "customer_had_tea",
|
32
|
+
:action => "change_lead_score",
|
33
|
+
:change_score_by => 20
|
34
|
+
|
35
|
+
@observer.catch_all
|
36
|
+
@lead.reload
|
37
|
+
@lead.versions.last.event.should include("Rule for Cloudfuji event - 'customer_had_tea': Score changed by 20 points")
|
38
|
+
@lead.score.should == 20
|
39
|
+
find_rule_count(@lead, @rule).count.should == 1
|
40
|
+
|
41
|
+
# Should increment score twice
|
42
|
+
@observer.catch_all
|
43
|
+
@lead.reload
|
44
|
+
@lead.score.should == 40
|
45
|
+
find_rule_count(@lead, @rule).count.should == 2
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should increment a lead's score only when matching data is present" do
|
49
|
+
user = FactoryGirl.create(:user, :ido_id => "1234")
|
50
|
+
@lead = FactoryGirl.create(:lead, :email => 'test_lead@example.com', :user => user, :campaign => nil)
|
51
|
+
|
52
|
+
@rule = FactoryGirl.create :event_rule,
|
53
|
+
:event_category => "cloudfuji_event_received",
|
54
|
+
:cloudfuji_event => "customer_had_tea",
|
55
|
+
:action => "change_lead_score",
|
56
|
+
:change_score_by => 15,
|
57
|
+
:match => "Russian Earl Grey"
|
58
|
+
|
59
|
+
@observer.catch_all
|
60
|
+
@lead.reload
|
61
|
+
@lead.score.should == 0
|
62
|
+
# No LeadEventRuleCount should be created yet
|
63
|
+
find_rule_count(@lead, @rule).should == nil
|
64
|
+
|
65
|
+
@observer.params['data']['type_of_tea'] = "Russian Earl Grey"
|
66
|
+
@observer.catch_all
|
67
|
+
|
68
|
+
@lead.reload
|
69
|
+
@lead.score.should == 15
|
70
|
+
find_rule_count(@lead, @rule).count.should == 1
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should not decrement a lead's score three times if the rule should only be applied twice" do
|
74
|
+
user = FactoryGirl.create(:user, :ido_id => "1234")
|
75
|
+
@lead = FactoryGirl.create(:lead, :email => 'test_lead@example.com', :user => user, :campaign => nil)
|
76
|
+
|
77
|
+
@rule = FactoryGirl.create :event_rule,
|
78
|
+
:event_category => "cloudfuji_event_received",
|
79
|
+
:cloudfuji_event => "customer_had_tea",
|
80
|
+
:action => "change_lead_score",
|
81
|
+
:change_score_by => -10,
|
82
|
+
:limit_per_lead => 1
|
83
|
+
|
84
|
+
test_score = 0
|
85
|
+
2.times do |i|
|
86
|
+
test_score += -10
|
87
|
+
@observer.catch_all
|
88
|
+
@lead.reload
|
89
|
+
|
90
|
+
@lead.versions.last.event.should == "Rule for Cloudfuji event - 'customer_had_tea': Score changed by -10 points. (New total: #{test_score})"
|
91
|
+
@lead.score.should == test_score
|
92
|
+
find_rule_count(@lead, @rule).count.should == i + 1
|
93
|
+
end
|
94
|
+
|
95
|
+
# Should only decrement score twice
|
96
|
+
@observer.catch_all
|
97
|
+
@lead.reload
|
98
|
+
@lead.score.should == -20
|
99
|
+
find_rule_count(@lead, @rule).count.should == 2
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -1,9 +1,15 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
factory :
|
3
|
-
|
2
|
+
factory :event_rule do
|
3
|
+
event_category { %w(cloudfuji_event_received lead_attribute_changed).sample }
|
4
|
+
|
5
|
+
cloudfuji_event {
|
4
6
|
%w(customer email app user).sample << "_" <<
|
5
7
|
%w(partied danced backflipped moonwalked).sample
|
6
8
|
}
|
7
|
-
|
9
|
+
lead_attribute { %w(username score first_name last_name).sample }
|
10
|
+
|
11
|
+
action { %w(add_tag remove_tag change_lead_score send_notification).sample }
|
12
|
+
tag { 'EventTag' }
|
13
|
+
change_score_by { rand(100) }
|
8
14
|
end
|
9
15
|
end
|
data/spec/internal/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
14
|
+
ActiveRecord::Schema.define(:version => 20120525151511) do
|
15
15
|
|
16
16
|
create_table "account_contacts", :force => true do |t|
|
17
17
|
t.integer "account_id"
|
@@ -196,6 +196,20 @@ ActiveRecord::Schema.define(:version => 20120515194445) do
|
|
196
196
|
|
197
197
|
add_index "emails", ["mediator_id", "mediator_type"], :name => "index_emails_on_mediator_id_and_mediator_type"
|
198
198
|
|
199
|
+
create_table "event_rules", :force => true do |t|
|
200
|
+
t.string "cloudfuji_event"
|
201
|
+
t.string "match"
|
202
|
+
t.integer "change_score_by", :default => 0
|
203
|
+
t.datetime "created_at", :null => false
|
204
|
+
t.datetime "updated_at", :null => false
|
205
|
+
t.string "event_category", :default => "cloudfuji_event_received"
|
206
|
+
t.string "lead_attribute"
|
207
|
+
t.string "action", :default => "change_lead_score"
|
208
|
+
t.string "tag"
|
209
|
+
t.integer "limit_per_lead"
|
210
|
+
t.boolean "case_insensitive_matching"
|
211
|
+
end
|
212
|
+
|
199
213
|
create_table "field_groups", :force => true do |t|
|
200
214
|
t.string "name", :limit => 64
|
201
215
|
t.string "label", :limit => 128
|
@@ -227,19 +241,10 @@ ActiveRecord::Schema.define(:version => 20120515194445) do
|
|
227
241
|
add_index "fields", ["field_group_id"], :name => "index_fields_on_field_group_id"
|
228
242
|
add_index "fields", ["name"], :name => "index_fields_on_name"
|
229
243
|
|
230
|
-
create_table "
|
244
|
+
create_table "lead_event_rule_counts", :force => true do |t|
|
231
245
|
t.integer "lead_id"
|
232
|
-
t.integer "
|
233
|
-
t.integer "count",
|
234
|
-
end
|
235
|
-
|
236
|
-
create_table "lead_scoring_rules", :force => true do |t|
|
237
|
-
t.string "event"
|
238
|
-
t.string "match"
|
239
|
-
t.integer "points", :default => 0
|
240
|
-
t.boolean "once"
|
241
|
-
t.datetime "created_at", :null => false
|
242
|
-
t.datetime "updated_at", :null => false
|
246
|
+
t.integer "event_rule_id"
|
247
|
+
t.integer "count", :default => 0
|
243
248
|
end
|
244
249
|
|
245
250
|
create_table "leads", :force => true do |t|
|
@@ -271,6 +276,7 @@ ActiveRecord::Schema.define(:version => 20120515194445) do
|
|
271
276
|
t.string "skype", :limit => 128
|
272
277
|
t.text "subscribed_users"
|
273
278
|
t.integer "score", :default => 0
|
279
|
+
t.text "ido_id"
|
274
280
|
end
|
275
281
|
|
276
282
|
add_index "leads", ["assigned_to"], :name => "index_leads_on_assigned_to"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe EventRule do
|
4
|
+
describe "validations" do
|
5
|
+
|
6
|
+
it "should create a new instance given valid attributes" do
|
7
|
+
EventRule.create!(
|
8
|
+
:event_category => "cloudfuji_event_received",
|
9
|
+
:cloudfuji_event => "dummy_event",
|
10
|
+
:action => "add_tag",
|
11
|
+
:tag => "EventTag"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be invalid without a cloudfuji_event if event category is cloudfuji_event_received" do
|
16
|
+
@event_rule = EventRule.new :event_category => "cloudfuji_event_received"
|
17
|
+
@event_rule.should_not be_valid
|
18
|
+
@event_rule.errors[:cloudfuji_event].should include("can't be blank")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be invalid without a lead_attribute if event category is lead_attribute_changed" do
|
22
|
+
@event_rule = EventRule.new :event_category => "lead_attribute_changed"
|
23
|
+
@event_rule.should_not be_valid
|
24
|
+
@event_rule.errors[:lead_attribute].should include("can't be blank")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be invalid without a tag if action is add_tag or remove_tag" do
|
28
|
+
@event_rule = EventRule.new :action => "add_tag"
|
29
|
+
@event_rule.should_not be_valid
|
30
|
+
@event_rule.errors[:tag].should include("can't be blank")
|
31
|
+
@event_rule.action = "remove_tag"
|
32
|
+
@event_rule.should_not be_valid
|
33
|
+
@event_rule.errors[:tag].should include("can't be blank")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be invalid without change_score_by if action is change_lead_score" do
|
37
|
+
@event_rule = EventRule.new :event_category => "cloudfuji_event_received",
|
38
|
+
:cloudfuji_event => "dummy_event",
|
39
|
+
:action => "change_lead_score",
|
40
|
+
:change_score_by => nil
|
41
|
+
@event_rule.should_not be_valid
|
42
|
+
|
43
|
+
@event_rule.errors[:change_score_by].should include("is not a number")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe CloudfujiLeadObserver do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@observer = CloudfujiLeadObserver.send :new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should process an event rule when a lead column is updated" do
|
10
|
+
user = FactoryGirl.create(:user, :ido_id => "1234")
|
11
|
+
@lead = FactoryGirl.create(:lead, :first_name => "Henry", :user => user, :campaign => nil)
|
12
|
+
|
13
|
+
EventRule.create!(
|
14
|
+
:event_category => "lead_attribute_changed",
|
15
|
+
:lead_attribute => "first_name",
|
16
|
+
:action => "change_lead_score",
|
17
|
+
:change_score_by => 5
|
18
|
+
)
|
19
|
+
|
20
|
+
EventRule.any_instance.should_receive(:process).with(@lead, ['Henry', 'George'])
|
21
|
+
|
22
|
+
@lead.first_name = "George"
|
23
|
+
@observer.after_update(@lead)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,137 +1,119 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffcrm_cloudfuji
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Sean Grove
|
9
9
|
- Nathan Broadbent
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
date: 2012-05-25 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
16
17
|
name: rspec-rails
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
19
|
none: false
|
19
|
-
requirements:
|
20
|
+
requirements:
|
20
21
|
- - ~>
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2.6"
|
23
24
|
type: :development
|
24
25
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
27
|
-
requirements:
|
28
|
-
- - ~>
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '2.6'
|
31
|
-
- !ruby/object:Gem::Dependency
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
32
28
|
name: capybara
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
34
30
|
none: false
|
35
|
-
requirements:
|
36
|
-
- -
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version:
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
|
-
version_requirements:
|
42
|
-
|
43
|
-
requirements:
|
44
|
-
- - ! '>='
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
48
39
|
name: combustion
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
41
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version:
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
55
46
|
type: :development
|
56
47
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
|
59
|
-
requirements:
|
60
|
-
- - ! '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
64
50
|
name: cloudfuji
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
52
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
70
56
|
version: 0.0.42
|
71
57
|
type: :runtime
|
72
58
|
prerelease: false
|
73
|
-
version_requirements:
|
74
|
-
|
75
|
-
requirements:
|
76
|
-
- - ! '>='
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: 0.0.42
|
79
|
-
- !ruby/object:Gem::Dependency
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
80
61
|
name: authlogic_cloudfuji
|
81
|
-
requirement: !ruby/object:Gem::Requirement
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
63
|
none: false
|
83
|
-
requirements:
|
64
|
+
requirements:
|
84
65
|
- - ~>
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version:
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0.9"
|
87
68
|
type: :runtime
|
88
69
|
prerelease: false
|
89
|
-
version_requirements:
|
90
|
-
none: false
|
91
|
-
requirements:
|
92
|
-
- - ~>
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0.9'
|
70
|
+
version_requirements: *id005
|
95
71
|
description: Integrates Fat Free CRM with the Cloudfuji hosting platform.
|
96
72
|
email: s@cloudfuji.com
|
97
73
|
executables: []
|
74
|
+
|
98
75
|
extensions: []
|
76
|
+
|
99
77
|
extra_rdoc_files: []
|
100
|
-
|
78
|
+
|
79
|
+
files:
|
101
80
|
- .gitignore
|
102
81
|
- .travis.yml
|
103
82
|
- Gemfile
|
104
83
|
- MIT-LICENSE
|
105
84
|
- README
|
106
85
|
- Rakefile
|
86
|
+
- app/assets/javascripts/event_rules.js.coffee
|
107
87
|
- app/assets/javascripts/ffcrm_cloudfuji.js
|
108
|
-
- app/assets/
|
88
|
+
- app/assets/stylesheets/event_rules.css.scss
|
109
89
|
- app/assets/stylesheets/ffcrm_cloudfuji.css
|
110
|
-
- app/
|
111
|
-
- app/
|
112
|
-
- app/
|
113
|
-
- app/models/
|
114
|
-
- app/
|
115
|
-
- app/views/admin/
|
116
|
-
- app/views/admin/
|
117
|
-
- app/views/admin/
|
90
|
+
- app/controllers/admin/event_rules_controller.rb
|
91
|
+
- app/helpers/admin/event_rules_helper.rb
|
92
|
+
- app/models/event_rule.rb
|
93
|
+
- app/models/lead_event_rule_count.rb
|
94
|
+
- app/observers/cloudfuji_lead_observer.rb
|
95
|
+
- app/views/admin/event_rules/_errors.html.haml
|
96
|
+
- app/views/admin/event_rules/_form.html.haml
|
97
|
+
- app/views/admin/event_rules/index.html.haml
|
118
98
|
- app/views/leads/_lead.html.haml
|
119
99
|
- app/views/leads/_sidebar_show_lead_scoring.html.haml
|
120
100
|
- config.ru
|
121
101
|
- config/database.yml
|
122
102
|
- config/initializers/cloudfuji.rb
|
123
|
-
- config/
|
103
|
+
- config/locales/en-US.yml
|
124
104
|
- config/routes.rb
|
125
105
|
- config/settings.yml
|
126
106
|
- db/migrate/20120227184555_add_cloudfuji_fields_to_users.rb
|
127
107
|
- db/migrate/20120515194445_add_lead_scoring_rules.rb
|
108
|
+
- db/migrate/20120524031157_extend_lead_scoring_as_event_rules.rb
|
109
|
+
- db/migrate/20120525151511_add_ido_id_to_lead.rb
|
128
110
|
- ffcrm_cloudfuji.gemspec
|
129
111
|
- install.rb
|
130
112
|
- lib/fat_free_crm/cloudfuji.rb
|
131
113
|
- lib/fat_free_crm/cloudfuji/event_observers/app_observer.rb
|
132
114
|
- lib/fat_free_crm/cloudfuji/event_observers/customer_observer.rb
|
133
115
|
- lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb
|
134
|
-
- lib/fat_free_crm/cloudfuji/event_observers/
|
116
|
+
- lib/fat_free_crm/cloudfuji/event_observers/event_rules_observer.rb
|
135
117
|
- lib/fat_free_crm/cloudfuji/event_observers/payment_observer.rb
|
136
118
|
- lib/fat_free_crm/cloudfuji/event_observers/user_observer.rb
|
137
119
|
- lib/fat_free_crm/cloudfuji/view_hooks.rb
|
@@ -140,40 +122,46 @@ files:
|
|
140
122
|
- lib/ffcrm_cloudfuji/version.rb
|
141
123
|
- spec/event_observers/app_observer_spec.rb
|
142
124
|
- spec/event_observers/customer_observer_spec.rb
|
143
|
-
- spec/event_observers/
|
125
|
+
- spec/event_observers/event_rules_observer_spec.rb
|
144
126
|
- spec/factories/lead_scoring_factories.rb
|
145
127
|
- spec/internal/config/database.yml
|
146
128
|
- spec/internal/db/schema.rb
|
129
|
+
- spec/models/event_rule_spec.rb
|
130
|
+
- spec/observers/cloudfuji_lead_observer_spec.rb
|
147
131
|
- spec/spec_helper.rb
|
148
132
|
- uninstall.rb
|
149
133
|
homepage: http://cloudfuji.com
|
150
134
|
licenses: []
|
135
|
+
|
151
136
|
post_install_message:
|
152
137
|
rdoc_options: []
|
153
|
-
|
138
|
+
|
139
|
+
require_paths:
|
154
140
|
- lib
|
155
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
142
|
none: false
|
157
|
-
requirements:
|
158
|
-
- -
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
|
161
|
-
segments:
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: -827916366021811991
|
147
|
+
segments:
|
162
148
|
- 0
|
163
|
-
|
164
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
151
|
none: false
|
166
|
-
requirements:
|
167
|
-
- -
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
|
170
|
-
segments:
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
hash: -827916366021811991
|
156
|
+
segments:
|
171
157
|
- 0
|
172
|
-
|
158
|
+
version: "0"
|
173
159
|
requirements: []
|
160
|
+
|
174
161
|
rubyforge_project:
|
175
|
-
rubygems_version: 1.8.
|
162
|
+
rubygems_version: 1.8.17
|
176
163
|
signing_key:
|
177
164
|
specification_version: 3
|
178
165
|
summary: Fat Free CRM - Cloudfuji Integration
|
179
166
|
test_files: []
|
167
|
+
|
@@ -1,42 +0,0 @@
|
|
1
|
-
(($) ->
|
2
|
-
class @LeadScoring
|
3
|
-
constructor: (@templates = {}) ->
|
4
|
-
|
5
|
-
add_fields: (button, content) ->
|
6
|
-
new_id = new Date().getTime()
|
7
|
-
regexp = new RegExp('new_lead_scoring_rule', 'g')
|
8
|
-
$('ul#lead_scoring_rules').append(content.replace(regexp, new_id))
|
9
|
-
# Setup event autocomplete for new field
|
10
|
-
this.event_autocomplete('input#lead_scoring_rules_'+new_id+'_event')
|
11
|
-
|
12
|
-
remove_fields: (button) ->
|
13
|
-
container = $(button).closest('li.lead_scoring_rule')
|
14
|
-
index = container.data('index')
|
15
|
-
# If rule has no id, just remove
|
16
|
-
if $("#lead_scoring_rules_"+index+"_id").length == 0
|
17
|
-
container.remove()
|
18
|
-
else
|
19
|
-
# If rule has an id, mark container as hidden and add _destroy field
|
20
|
-
container.hide()
|
21
|
-
container.append($('<input type="text" name="lead_scoring_rules['+index+'][_destroy]" value="yes">'))
|
22
|
-
|
23
|
-
event_autocomplete: (selector = 'input.lead_scoring_event') ->
|
24
|
-
$(selector).autocomplete({source: observed_cloudfuji_events, minLength: 0})
|
25
|
-
# Show all events on focus, if input is empty
|
26
|
-
$(selector).focus ->
|
27
|
-
$(this).autocomplete "search", "" if $(this).val() == ""
|
28
|
-
|
29
|
-
$(document).ready ->
|
30
|
-
lead_scoring = new LeadScoring()
|
31
|
-
# Initialize autocomplete for events
|
32
|
-
lead_scoring.event_autocomplete()
|
33
|
-
|
34
|
-
$("button.add_lead_scoring_rule").live "click", ->
|
35
|
-
lead_scoring.add_fields this, $(this).data("content")
|
36
|
-
false
|
37
|
-
|
38
|
-
$(".remove_lead_scoring_rule").live "click", ->
|
39
|
-
lead_scoring.remove_fields this
|
40
|
-
false
|
41
|
-
|
42
|
-
) jQuery
|
@@ -1,47 +0,0 @@
|
|
1
|
-
li.lead_scoring_rule {
|
2
|
-
font-size: 13px;
|
3
|
-
|
4
|
-
&:last-child {
|
5
|
-
border-bottom: none;
|
6
|
-
}
|
7
|
-
|
8
|
-
input {
|
9
|
-
font-size: 13px;
|
10
|
-
margin: 0 4px;
|
11
|
-
vertical-align: middle;
|
12
|
-
margin-bottom: 3px;
|
13
|
-
}
|
14
|
-
.lead_scoring_event { width: 160px; }
|
15
|
-
.lead_scoring_once {
|
16
|
-
width: 14px;
|
17
|
-
margin-left: 2px;
|
18
|
-
}
|
19
|
-
.lead_scoring_match { width: 190px; }
|
20
|
-
.lead_scoring_points { width: 35px; }
|
21
|
-
|
22
|
-
.field_with_errors {
|
23
|
-
display: inline;
|
24
|
-
input {
|
25
|
-
background-color: #ffdddd;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
ul#lead_scoring_rules {
|
31
|
-
a.remove_lead_scoring_rule {
|
32
|
-
margin-right: 6px;
|
33
|
-
img {
|
34
|
-
vertical-align: middle;
|
35
|
-
margin-bottom: 4px;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
.buttonbar.lead_scoring_buttons {
|
41
|
-
width: 845px;
|
42
|
-
float: left;
|
43
|
-
font-size: 13px;
|
44
|
-
input[type='submit'], button { font-size: 14px; }
|
45
|
-
.save_or_cancel { float: right; }
|
46
|
-
button { float: left; }
|
47
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Admin::LeadScoringHelper
|
2
|
-
|
3
|
-
def add_lead_scoring_rule_button(f)
|
4
|
-
fields = f.fields_for "new_lead_scoring_rule", LeadScoringRule.new(:points => 0) do |builder|
|
5
|
-
render("form", :r => builder, :index => "new_lead_scoring_rule")
|
6
|
-
end
|
7
|
-
button_tag 'Add New Rule', :class => "add_lead_scoring_rule", "data-content" => "#{fields}"
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
%li.lead_scoring_rule{"data-index" => index}
|
2
|
-
= link_to image_tag('delete.png', :size => '16x16', :alt => 'Remove Rule'), nil, :class => "remove_lead_scoring_rule"
|
3
|
-
|
4
|
-
= r.hidden_field(:id) unless r.object.new_record?
|
5
|
-
|
6
|
-
If event:
|
7
|
-
= r.text_field :event, :class => "lead_scoring_event"
|
8
|
-
matches:
|
9
|
-
= r.text_field :match, :class => "lead_scoring_match"
|
10
|
-
change score by
|
11
|
-
= r.text_field :points, :class => "lead_scoring_points"
|
12
|
-
points.
|
13
|
-
Only once per lead:
|
14
|
-
= r.check_box :once, :class => "lead_scoring_once"
|