e9_crm 0.1.14 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/app/controllers/e9_crm/campaigns_controller.rb +1 -1
  2. data/app/controllers/e9_crm/contacts_controller.rb +6 -1
  3. data/app/controllers/e9_crm/dated_costs_controller.rb +0 -2
  4. data/app/helpers/e9_crm/base_helper.rb +56 -79
  5. data/app/helpers/e9_crm/contacts_helper.rb +1 -1
  6. data/app/models/contact.rb +6 -16
  7. data/app/views/e9_crm/contacts/show.html.haml +5 -0
  8. data/app/views/e9_crm/offers/_offer.html.haml +2 -2
  9. data/app/views/{e9_crm/record_attributes → record_attributes}/_user.html.haml +0 -0
  10. data/config/routes.rb +0 -4
  11. data/e9_crm.gemspec +3 -2
  12. data/lib/e9_crm.rb +5 -6
  13. data/lib/e9_crm/version.rb +1 -1
  14. metadata +54 -28
  15. data/app/controllers/e9_crm/menu_options_controller.rb +0 -28
  16. data/app/models/address_attribute.rb +0 -7
  17. data/app/models/instant_messaging_handle_attribute.rb +0 -4
  18. data/app/models/menu_option.rb +0 -38
  19. data/app/models/phone_number_attribute.rb +0 -4
  20. data/app/models/record_attribute.rb +0 -41
  21. data/app/models/website_attribute.rb +0 -4
  22. data/app/views/e9_crm/menu_options/_form_inner.html.haml +0 -6
  23. data/app/views/e9_crm/menu_options/_header.html.haml +0 -7
  24. data/app/views/e9_crm/record_attributes/_address_attribute.html.haml +0 -5
  25. data/app/views/e9_crm/record_attributes/_form_partial.html.haml +0 -4
  26. data/app/views/e9_crm/record_attributes/_instant_messaging_handle_attribute.html.haml +0 -5
  27. data/app/views/e9_crm/record_attributes/_phone_number_attribute.html.haml +0 -5
  28. data/app/views/e9_crm/record_attributes/_record_attribute.html.haml +0 -10
  29. data/app/views/e9_crm/record_attributes/_templates.js.erb +0 -12
  30. data/app/views/e9_crm/record_attributes/_website_attribute.html.haml +0 -5
@@ -17,7 +17,7 @@ class E9Crm::CampaignsController < E9Crm::ResourcesController
17
17
  protected
18
18
 
19
19
  def collection_scope
20
- end_of_association_chain.typed.includes(:campaign_group)
20
+ #end_of_association_chain.typed.includes(:campaign_group)
21
21
 
22
22
  # NOTE this is a pretty ugly join just to be able to sort on campaign group name
23
23
  end_of_association_chain.typed
@@ -18,9 +18,14 @@ class E9Crm::ContactsController < E9Crm::ResourcesController
18
18
  has_scope :by_company, :as => :company, :only => :index
19
19
 
20
20
  # record attributes templates js
21
+ #caches_action :templates
22
+
21
23
  skip_before_filter :authenticate_user!, :filter_access_filter, :only => :templates
22
24
  before_filter :build_resource, :only => :templates
23
- #caches_action :templates
25
+
26
+ def templates
27
+ render RecordAttribute::TEMPLATES
28
+ end
24
29
 
25
30
  # NOTE for some reason create! { redirect } is trying to redirect on failure
26
31
  def create
@@ -67,8 +67,6 @@ class E9Crm::DatedCostsController < E9Crm::ResourcesController
67
67
  end
68
68
 
69
69
  def add_index_breadcrumb
70
- #association_chain
71
-
72
70
  add_breadcrumb! Campaign.model_name.collection.titleize, campaigns_path
73
71
 
74
72
  if parent
@@ -1,33 +1,10 @@
1
1
  module E9Crm::BaseHelper
2
2
 
3
- def kramdown(string)
4
- Kramdown::Document.new(string).to_html.html_safe
5
- end
6
-
7
- alias :k :kramdown
8
-
9
- def help_tooltip(string, data_title = nil)
10
- return <<-HTML.strip.html_safe
11
- <span class="help" rel="tooltip" #{data_title ? %Q[data-title="#{data_title}"] : nil } title="#{CGI.escape_html(string)}">#{t(:inline_help_link)}</span>
12
- HTML
13
- end
3
+ #def kramdown(string)
4
+ #Kramdown::Document.new(string).to_html.html_safe
5
+ #end
14
6
 
15
- def help_label(form_or_id, key, options = {})
16
- options[:key] ||= :"#{key}_help"
17
-
18
- help_title = options.delete(:title) || resource_humanize(options.delete(:key))
19
-
20
- str = ''.html_safe
21
- str.safe_concat resource_humanize(key)
22
- str.safe_concat ' '
23
- str.safe_concat help_tooltip(help_title, options.delete(:header))
24
-
25
- if form_or_id.respond_to?(:label)
26
- form_or_id.label(key, str, options)
27
- else
28
- label_tag(form_or_id, str, options)
29
- end
30
- end
7
+ #alias :k :kramdown
31
8
 
32
9
  ##
33
10
  # Field maps
@@ -56,58 +33,58 @@ module E9Crm::BaseHelper
56
33
  # Misc
57
34
  #
58
35
 
59
- def link_to_add_record_attribute(association_name)
60
- link_to(
61
- t(:add_record_attribute, :scope => :e9_crm),
62
- 'javascript:;',
63
- :class => 'add-nested-association',
64
- 'data-association' => association_name
65
- )
66
- end
67
-
68
- def link_to_destroy_record_attribute
69
- link_to(
70
- t(:destroy_record_attribute, :scope => :e9_crm),
71
- 'javascript:;',
72
- :class => 'destroy-nested-association'
73
- )
74
- end
75
-
76
- def render_record_attribute_form(association_name, form)
77
- render('e9_crm/record_attributes/form_partial', {
78
- :form => form,
79
- :association_name => association_name
80
- })
81
- end
82
-
83
- def render_record_attribute_association(association_name, form, options = {})
84
- options.symbolize_keys!
85
-
86
- association = resource.send(association_name)
87
-
88
- unless association.empty?
89
- form.fields_for(association_name) do |f|
90
- concat record_attribute_template(association_name, f, options)
91
- end
92
- end
93
- end
94
-
95
- def record_attribute_template(association_name, builder, options = {})
96
- options.symbolize_keys!
97
-
98
- render(
99
- :partial => options[:partial] || "e9_crm/record_attributes/#{association_name.to_s.singularize}",
100
- :locals => { :f => builder }
101
- )
102
- end
103
-
104
- # tries to build an associated resource, looking to the assocatiaon's model for a method
105
- # named "%{association_name}_build_parameters}" first for any default params
106
- def build_associated_resource(association_name)
107
- params_method = "#{association_name}_build_parameters"
108
- build_params = resource_class.send(params_method) if resource_class.respond_to?(params_method)
109
- resource.send(association_name).build(build_params || {})
110
- end
36
+ #def link_to_add_record_attribute(association_name)
37
+ #link_to(
38
+ #t(:add_record_attribute, :scope => :e9_crm),
39
+ #'javascript:;',
40
+ #:class => 'add-nested-association',
41
+ #'data-association' => association_name
42
+ #)
43
+ #end
44
+
45
+ #def link_to_destroy_record_attribute
46
+ #link_to(
47
+ #t(:destroy_record_attribute, :scope => :e9_crm),
48
+ #'javascript:;',
49
+ #:class => 'destroy-nested-association'
50
+ #)
51
+ #end
52
+
53
+ #def render_record_attribute_form(association_name, form)
54
+ #render('e9_crm/record_attributes/form_partial', {
55
+ #:form => form,
56
+ #:association_name => association_name
57
+ #})
58
+ #end
59
+
60
+ #def render_record_attribute_association(association_name, form, options = {})
61
+ #options.symbolize_keys!
62
+
63
+ #association = resource.send(association_name)
64
+
65
+ #unless association.empty?
66
+ #form.fields_for(association_name) do |f|
67
+ #concat record_attribute_template(association_name, f, options)
68
+ #end
69
+ #end
70
+ #end
71
+
72
+ #def record_attribute_template(association_name, builder, options = {})
73
+ #options.symbolize_keys!
74
+
75
+ #render(
76
+ #:partial => options[:partial] || "e9_crm/record_attributes/#{association_name.to_s.singularize}",
77
+ #:locals => { :f => builder }
78
+ #)
79
+ #end
80
+
81
+ ## tries to build an associated resource, looking to the assocatiaon's model for a method
82
+ ## named "%{association_name}_build_parameters}" first for any default params
83
+ #def build_associated_resource(association_name)
84
+ #params_method = "#{association_name}_build_parameters"
85
+ #build_params = resource_class.send(params_method) if resource_class.respond_to?(params_method)
86
+ #resource.send(association_name).build(build_params || {})
87
+ #end
111
88
 
112
89
  def sortable_controller?
113
90
  @_sortable_controller ||= controller.class.ancestors.member?(E9Rails::Controllers::Sortable)
@@ -10,7 +10,7 @@ module E9Crm::ContactsHelper
10
10
  end
11
11
 
12
12
  def company_select_options
13
- options = Company.select('name', 'id').ordered.all.map {|c| [c.name, c.id] }
13
+ options = Company.select("companies.name, companies.id").ordered.all.map {|c| [c.name, c.id] }
14
14
  options.unshift(['Any Company', nil])
15
15
  options_for_select(options, params[:company])
16
16
  end
@@ -94,22 +94,12 @@ class Contact < ActiveRecord::Base
94
94
  PageView.by_user(users)
95
95
  end
96
96
 
97
- has_many :record_attributes, :as => :record
98
- RECORD_ATTRIBUTES = %w[users phone_number_attributes instant_messaging_handle_attributes website_attributes address_attributes]
99
- # NOTE Mind the hack here, "users" are "attributes" but not added in this loop. This was so the RECORD_ATTRIBUTES constant
100
- # would include :users (for building the templates.js).
101
- RECORD_ATTRIBUTES.select {|r| r =~ /attributes$/ }.each do |association_name|
102
- has_many association_name.to_sym, :class_name => association_name.classify, :as => :record
103
- accepts_nested_attributes_for association_name.to_sym, :allow_destroy => true, :reject_if => :reject_record_attribute?
104
- end
105
-
106
- def build_all_record_attributes
107
- RECORD_ATTRIBUTES.each do |attr|
108
- params_method = "#{attr}_build_parameters"
109
- build_params = self.class.send(params_method) if self.class.respond_to?(params_method)
110
- send(attr).send(:build, build_params || {})
111
- end
112
- end
97
+ has_record_attributes :users,
98
+ :phone_number_attributes,
99
+ :instant_messaging_handle_attributes,
100
+ :website_attributes,
101
+ :address_attributes,
102
+ :skip_name_format => true
113
103
 
114
104
  ##
115
105
  # Validations
@@ -1,16 +1,21 @@
1
1
  .contact-body
2
2
  = title resource.name
3
+
3
4
  .contact-photo
4
5
  %img{:src => resource.avatar_url, :alt => "Avatar for #{resource.name}"}
6
+
5
7
  = render 'who', :record => resource, :hide_name => true
8
+
6
9
  .contact-links.actions
7
10
  = link_to_edit_resource(resource)
8
11
  = google_search_link(resource.name)
9
12
  = google_news_link(resource.name)
13
+
10
14
  - if (tags = resource.tags(:show_all => true)).present?
11
15
  .contact-tags
12
16
  %label #{Tag.model_name.human.pluralize}:
13
17
  = contact_tag_list(tags)
18
+
14
19
  .contact-info
15
20
  %label #{Contact.human_attribute_name(:info)}:
16
21
  = contact_simple_format(resource.info.presence || t(:none))
@@ -1,4 +1,4 @@
1
- %div{:id => "offer_#{renderable.id}_body"}
1
+ %div{:id => "offer_#{offer.id}_body"}
2
2
  - content_for :bottom_javascripts do
3
3
  :javascript
4
- $(function(){ $("#offer_#{renderable.id}_body").load("#{new_public_offer_deal_path(renderable)}") });
4
+ $(function(){ $("#offer_#{offer.id}_body").load("#{new_public_offer_deal_path(offer)}") });
data/config/routes.rb CHANGED
@@ -35,10 +35,6 @@ Rails.application.routes.draw do
35
35
  collection { get :select }
36
36
  end
37
37
 
38
- resources :menu_options, :except => [:show] do
39
- collection { post :update_order }
40
- end
41
-
42
38
  resources :dated_costs, :path => 'advertising_costs', :only => [:index] do
43
39
  collection do
44
40
  post :bulk_create
data/e9_crm.gemspec CHANGED
@@ -23,8 +23,9 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency("inherited_resources", "~> 1.1.2")
24
24
  s.add_dependency("has_scope")
25
25
  s.add_dependency("money")
26
- s.add_dependency("e9_rails", "~> 0.0.16")
27
- s.add_dependency("e9_tags", "~> 0.0.12")
26
+ s.add_dependency("e9_rails")
27
+ s.add_dependency("e9_tags")
28
+ s.add_dependency("e9_attributes")
28
29
  s.add_dependency("will_paginate")
29
30
  s.add_dependency("kramdown", "~> 0.13")
30
31
  end
data/lib/e9_crm.rb CHANGED
@@ -1,12 +1,9 @@
1
- require 'rails'
1
+ require 'e9_base'
2
2
  require 'e9_rails'
3
3
  require 'e9_tags'
4
+ require 'e9_attributes'
5
+
4
6
  require 'money'
5
- require 'inherited_resources'
6
- require 'will_paginate'
7
- require 'has_scope'
8
- require 'kramdown'
9
- require 'e9_base'
10
7
 
11
8
  require 'e9_crm/rails_extensions'
12
9
 
@@ -65,6 +62,8 @@ module E9Crm
65
62
  E9Crm.tracking_controllers.each do |controller|
66
63
  controller.send(:include, E9Crm::TrackingController)
67
64
  end
65
+
66
+ MenuOption.keys |= %w(Deal\ Category)
68
67
  end
69
68
 
70
69
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module E9Crm
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.16'
3
3
  end
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e9_crm
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.14
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 16
9
+ version: 0.1.16
6
10
  platform: ruby
7
11
  authors:
8
12
  - Travis Cox
@@ -10,7 +14,7 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2011-06-07 00:00:00 -04:00
17
+ date: 2011-09-07 00:00:00 -04:00
14
18
  default_executable:
15
19
  dependencies:
16
20
  - !ruby/object:Gem::Dependency
@@ -21,6 +25,10 @@ dependencies:
21
25
  requirements:
22
26
  - - ~>
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 3
30
+ - 0
31
+ - 0
24
32
  version: 3.0.0
25
33
  type: :runtime
26
34
  version_requirements: *id001
@@ -32,6 +40,10 @@ dependencies:
32
40
  requirements:
33
41
  - - ~>
34
42
  - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 1
46
+ - 2
35
47
  version: 1.1.2
36
48
  type: :runtime
37
49
  version_requirements: *id002
@@ -43,6 +55,8 @@ dependencies:
43
55
  requirements:
44
56
  - - ">="
45
57
  - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
46
60
  version: "0"
47
61
  type: :runtime
48
62
  version_requirements: *id003
@@ -54,6 +68,8 @@ dependencies:
54
68
  requirements:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
57
73
  version: "0"
58
74
  type: :runtime
59
75
  version_requirements: *id004
@@ -63,9 +79,11 @@ dependencies:
63
79
  requirement: &id005 !ruby/object:Gem::Requirement
64
80
  none: false
65
81
  requirements:
66
- - - ~>
82
+ - - ">="
67
83
  - !ruby/object:Gem::Version
68
- version: 0.0.16
84
+ segments:
85
+ - 0
86
+ version: "0"
69
87
  type: :runtime
70
88
  version_requirements: *id005
71
89
  - !ruby/object:Gem::Dependency
@@ -74,33 +92,53 @@ dependencies:
74
92
  requirement: &id006 !ruby/object:Gem::Requirement
75
93
  none: false
76
94
  requirements:
77
- - - ~>
95
+ - - ">="
78
96
  - !ruby/object:Gem::Version
79
- version: 0.0.12
97
+ segments:
98
+ - 0
99
+ version: "0"
80
100
  type: :runtime
81
101
  version_requirements: *id006
82
102
  - !ruby/object:Gem::Dependency
83
- name: will_paginate
103
+ name: e9_attributes
84
104
  prerelease: false
85
105
  requirement: &id007 !ruby/object:Gem::Requirement
86
106
  none: false
87
107
  requirements:
88
108
  - - ">="
89
109
  - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
90
112
  version: "0"
91
113
  type: :runtime
92
114
  version_requirements: *id007
93
115
  - !ruby/object:Gem::Dependency
94
- name: kramdown
116
+ name: will_paginate
95
117
  prerelease: false
96
118
  requirement: &id008 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ segments:
124
+ - 0
125
+ version: "0"
126
+ type: :runtime
127
+ version_requirements: *id008
128
+ - !ruby/object:Gem::Dependency
129
+ name: kramdown
130
+ prerelease: false
131
+ requirement: &id009 !ruby/object:Gem::Requirement
97
132
  none: false
98
133
  requirements:
99
134
  - - ~>
100
135
  - !ruby/object:Gem::Version
136
+ segments:
137
+ - 0
138
+ - 13
101
139
  version: "0.13"
102
140
  type: :runtime
103
- version_requirements: *id008
141
+ version_requirements: *id009
104
142
  description: |
105
143
  *NOTE his plugin requires the private e9_base CMS gem and WILL NOT WORK without it.*
106
144
 
@@ -162,7 +200,6 @@ files:
162
200
  - app/controllers/e9_crm/email_templates.controller.rb
163
201
  - app/controllers/e9_crm/file_download_offers_controller.rb
164
202
  - app/controllers/e9_crm/leads_controller.rb
165
- - app/controllers/e9_crm/menu_options_controller.rb
166
203
  - app/controllers/e9_crm/new_content_subscription_offers_controller.rb
167
204
  - app/controllers/e9_crm/newsletter_subscription_offers_controller.rb
168
205
  - app/controllers/e9_crm/offer_subclass_controller.rb
@@ -184,7 +221,6 @@ files:
184
221
  - app/helpers/e9_crm/menu_options_helper.rb
185
222
  - app/helpers/e9_crm/offers_helper.rb
186
223
  - app/helpers/e9_crm/page_views_helper.rb
187
- - app/models/address_attribute.rb
188
224
  - app/models/advertising_campaign.rb
189
225
  - app/models/affiliate_campaign.rb
190
226
  - app/models/campaign.rb
@@ -198,20 +234,15 @@ files:
198
234
  - app/models/email_campaign.rb
199
235
  - app/models/email_template.rb
200
236
  - app/models/file_download_offer.rb
201
- - app/models/instant_messaging_handle_attribute.rb
202
- - app/models/menu_option.rb
203
237
  - app/models/new_content_subscription_offer.rb
204
238
  - app/models/newsletter_subscription_offer.rb
205
239
  - app/models/no_campaign.rb
206
240
  - app/models/offer.rb
207
241
  - app/models/page_view.rb
208
- - app/models/phone_number_attribute.rb
209
- - app/models/record_attribute.rb
210
242
  - app/models/sales_campaign.rb
211
243
  - app/models/subscription_offer.rb
212
244
  - app/models/tracking_cookie.rb
213
245
  - app/models/video_offer.rb
214
- - app/models/website_attribute.rb
215
246
  - app/observers/deal_observer.rb
216
247
  - app/uploaders/file_uploader.rb
217
248
  - app/views/e9_crm/advertising_campaigns/_form_inner.html.haml
@@ -277,8 +308,6 @@ files:
277
308
  - app/views/e9_crm/leads/_form.html.haml
278
309
  - app/views/e9_crm/leads/create.js.erb
279
310
  - app/views/e9_crm/leads/new.html.haml
280
- - app/views/e9_crm/menu_options/_form_inner.html.haml
281
- - app/views/e9_crm/menu_options/_header.html.haml
282
311
  - app/views/e9_crm/new_content_subscription_offers/_form_inner.html.haml
283
312
  - app/views/e9_crm/newsletter_subscription_offers/_form_inner.html.haml
284
313
  - app/views/e9_crm/offers/_form_inner.html.haml
@@ -287,14 +316,6 @@ files:
287
316
  - app/views/e9_crm/offers/_public_offer.html.haml
288
317
  - app/views/e9_crm/offers/show.html.haml
289
318
  - app/views/e9_crm/page_views/_table.html.haml
290
- - app/views/e9_crm/record_attributes/_address_attribute.html.haml
291
- - app/views/e9_crm/record_attributes/_form_partial.html.haml
292
- - app/views/e9_crm/record_attributes/_instant_messaging_handle_attribute.html.haml
293
- - app/views/e9_crm/record_attributes/_phone_number_attribute.html.haml
294
- - app/views/e9_crm/record_attributes/_record_attribute.html.haml
295
- - app/views/e9_crm/record_attributes/_templates.js.erb
296
- - app/views/e9_crm/record_attributes/_user.html.haml
297
- - app/views/e9_crm/record_attributes/_website_attribute.html.haml
298
319
  - app/views/e9_crm/resources/_form.html.haml
299
320
  - app/views/e9_crm/resources/_form_inner.html.haml
300
321
  - app/views/e9_crm/resources/_header.html.haml
@@ -310,6 +331,7 @@ files:
310
331
  - app/views/e9_crm/sales_campaigns/_form_inner.html.haml
311
332
  - app/views/e9_crm/subscription_offers/_form_inner.html.haml
312
333
  - app/views/e9_crm/video_offers/_form_inner.html.haml
334
+ - app/views/record_attributes/_user.html.haml
313
335
  - config/initializers/inflections.rb
314
336
  - config/locales/e9.en.yml
315
337
  - config/locales/en.yml
@@ -345,17 +367,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
345
367
  requirements:
346
368
  - - ">="
347
369
  - !ruby/object:Gem::Version
370
+ segments:
371
+ - 0
348
372
  version: "0"
349
373
  required_rubygems_version: !ruby/object:Gem::Requirement
350
374
  none: false
351
375
  requirements:
352
376
  - - ">="
353
377
  - !ruby/object:Gem::Version
378
+ segments:
379
+ - 0
354
380
  version: "0"
355
381
  requirements: []
356
382
 
357
383
  rubyforge_project: e9_crm
358
- rubygems_version: 1.6.2
384
+ rubygems_version: 1.3.7
359
385
  signing_key:
360
386
  specification_version: 3
361
387
  summary: CRM engine plugin for the e9 CMS
@@ -1,28 +0,0 @@
1
- class E9Crm::MenuOptionsController < E9Crm::ResourcesController
2
- defaults :resource_class => MenuOption
3
- include E9Rails::Controllers::Sortable
4
-
5
- self.should_paginate_index = false
6
-
7
- has_scope :options_for, :as => :key, :only => :index
8
-
9
- # NOTE The reason this is set in a filter instead of just a default scope value
10
- # is that it is used in the index view to add the key param to the new
11
- # resource link
12
- #
13
- before_filter :ensure_default_fetch_key, :only => :index
14
-
15
- def create
16
- create! { collection_path(:key => resource.key) }
17
- end
18
-
19
- def update
20
- update! { collection_path(:key => resource.key) }
21
- end
22
-
23
- protected
24
-
25
- def ensure_default_fetch_key
26
- params[:key] ||= MenuOption::KEYS.sort.first
27
- end
28
- end
@@ -1,7 +0,0 @@
1
- # Attribute for address info
2
- #
3
- class AddressAttribute < RecordAttribute
4
- def to_html
5
- to_s.gsub(/\n/, '<br />').html_safe
6
- end
7
- end
@@ -1,4 +0,0 @@
1
- # An instant messaging handle type, e.g. AIM, Skype
2
- #
3
- class InstantMessagingHandleAttribute < RecordAttribute
4
- end
@@ -1,38 +0,0 @@
1
- # A simple class to manage menu options, usable by other classes to build their menus.
2
- #
3
- class MenuOption < ActiveRecord::Base
4
- KEYS = [
5
- #'Task Category',
6
- #'Task Status',
7
- 'Address',
8
- 'Deal Category',
9
- 'Email',
10
- 'Instant Messaging Handle',
11
- 'Phone Number',
12
- 'Website'
13
- ].freeze
14
-
15
- validates :value, :presence => true
16
- validates :key, :presence => true, :inclusion => { :in => KEYS, :allow_blank => true }
17
-
18
- acts_as_list :scope => 'menu_options.key = \"#{key}\"'
19
-
20
- scope :options_for, lambda {|key| where(:key => key).order('menu_options.position ASC') }
21
-
22
- ##
23
- # A direct SQL selection of values for a given key
24
- #
25
- # MenuOption.fetch('Email') #=> ['Personal','Work']
26
- #
27
- # === Parameters
28
- #
29
- # [key (String)] The key for the assocated menu options.
30
- #
31
- def self.fetch_values(key)
32
- connection.send(:select_values, options_for(key).order(:position).project('value').to_sql, 'Menu Option Select')
33
- end
34
-
35
- def to_s
36
- value
37
- end
38
- end
@@ -1,4 +0,0 @@
1
- # A phone number type, e.g. (Home, Work, Mobile)
2
- #
3
- class PhoneNumberAttribute < RecordAttribute
4
- end
@@ -1,41 +0,0 @@
1
- # An arbitrary 'attribute' attachable to records.
2
- #
3
- # Gets support for arbitrary options via InheritableOptions. By default it
4
- # has one option, +type+, but subclasses could extend for further options by
5
- # overwriting +options_parameters+.
6
- #
7
- # By default, the +type+ options are managed via the +MenuOption+ class.
8
- #
9
- class RecordAttribute < ActiveRecord::Base
10
- include E9Rails::ActiveRecord::STI
11
- include E9Rails::ActiveRecord::AttributeSearchable
12
- include E9Rails::ActiveRecord::InheritableOptions
13
-
14
- self.options_parameters = [:type]
15
-
16
- belongs_to :record, :polymorphic => true
17
-
18
- ##
19
- # Looks up the available +types+ for this attribute by fetching a
20
- # titleized version of the class name from +MenuOption+.
21
- #
22
- # e.g.
23
- #
24
- # PhoneNumberAttribute.types
25
- #
26
- # is equivalent to:
27
- #
28
- # MenuOption.fetch_values('Phone Number')
29
- #
30
- def self.types
31
- if name =~ /^(\w+)Attribute$/
32
- MenuOption.fetch_values($1.titleize)
33
- else
34
- []
35
- end
36
- end
37
-
38
- def to_s
39
- options.type ? "#{value} (#{options.type})" : value
40
- end
41
- end
@@ -1,4 +0,0 @@
1
- # Attribute for related websites, e.g. Facebook Page, Personal Website
2
- #
3
- class WebsiteAttribute < RecordAttribute
4
- end
@@ -1,6 +0,0 @@
1
- .field
2
- = f.label :key
3
- = f.select :key, MenuOption::KEYS.sort
4
- .field
5
- = f.label :value, nil, :class => :req
6
- = f.text_field :value
@@ -1,7 +0,0 @@
1
- .toolbar
2
- .toolbar-left
3
- %form{:action => menu_options_path, :method => :get, :class => 'scope-selects'}
4
- = label_tag 'menu_option_key_select', t(:view)
5
- = select_tag 'key', options_for_select(MenuOption::KEYS.sort, params[:key])
6
- .toolbar-right
7
- = link_to_new_resource(MenuOption, :menu_option => {:key => params[:key]}, :class => 'new-menu-option')
@@ -1,5 +0,0 @@
1
- = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f, :value_field_type => :text_area } do
2
- - if (types = AddressAttribute.types).present?
3
- = f.fields_for f.object.options do |ff|
4
- .field
5
- = ff.select :type, types
@@ -1,4 +0,0 @@
1
- %fieldset.nested-associations
2
- %legend= form.label(association_name)
3
- = render_record_attribute_association(association_name, form)
4
- = link_to_add_record_attribute(association_name)
@@ -1,5 +0,0 @@
1
- = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f } do
2
- - if (types = InstantMessagingHandleAttribute.types).present?
3
- = f.fields_for f.object.options do |ff|
4
- .field
5
- = ff.select :type, types
@@ -1,5 +0,0 @@
1
- = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f } do
2
- - if (types = PhoneNumberAttribute.types).present?
3
- = f.fields_for f.object.options do |ff|
4
- .field
5
- = ff.select :type, types
@@ -1,10 +0,0 @@
1
- .record-attribute.nested-association
2
- - if f.object.persisted?
3
- = f.hidden_field :id
4
- = f.hidden_field :_destroy, :value => 0
5
- .field
6
- = f.send local_assigns[:value_field_type] || :text_field, :value
7
-
8
- = yield
9
-
10
- = link_to_destroy_record_attribute
@@ -1,12 +0,0 @@
1
- E9CRM = window.E9CRM || {};
2
- E9CRM.js_templates = {};
3
- E9CRM.js_templates.start_child_index =
4
- E9CRM.js_templates.current_child_index = <%= child_index = 100000 %>;
5
- <%= fields_for(resource) do |f| %>
6
- <% resource_class::RECORD_ATTRIBUTES.each do |association_name| %>
7
- <% build_associated_resource(association_name) %>
8
- <%= f.fields_for(association_name, :child_index => child_index) do |association_form_builder| %>
9
- E9CRM.js_templates.<%= association_name %> = "<%= escape_javascript(record_attribute_template(association_name, association_form_builder)) %>";
10
- <% end %>
11
- <% end %>
12
- <% end %>
@@ -1,5 +0,0 @@
1
- = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f } do
2
- - if (types = WebsiteAttribute.types).present?
3
- = f.fields_for f.object.options do |ff|
4
- .field
5
- = ff.select :type, types