Module: NewCustomersHelper
- Defined in:
- app/helpers/new_customers_helper.rb
Instance Method Summary collapse
- #contact_display_with_highlight(contact) ⇒ Object
- #customer_display_with_highlight(customer) ⇒ Object
- #new_customer_attribute_hidden_fields(new_customer) ⇒ Object
- #new_customer_attributes_params ⇒ Object
- #new_customer_link_to_duplicates_step ⇒ Object
- #new_customer_link_to_email_preferences_step ⇒ Object
- #new_customer_link_to_identify_step ⇒ Object
- #new_customer_link_to_setup_step ⇒ Object
- #prefixed_new_customer_form_attributes ⇒ Object
- #rep_assign_method_collection_for_select ⇒ Object
Instance Method Details
#contact_display_with_highlight(contact) ⇒ Object
3 4 5 |
# File 'app/helpers/new_customers_helper.rb', line 3 def contact_display_with_highlight(contact) link_to highlight(contact.full_name, @new_customer.person_name_parts), contact_path(contact) end |
#customer_display_with_highlight(customer) ⇒ Object
7 8 9 |
# File 'app/helpers/new_customers_helper.rb', line 7 def customer_display_with_highlight(customer) link_to highlight(customer.full_name, @new_customer.company_name_parts), customer_path(customer) end |
#new_customer_attribute_hidden_fields(new_customer) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/new_customers_helper.rb', line 11 def new_customer_attribute_hidden_fields(new_customer) new_customer.attributes.map do |attr_key, value| if value.present? if value.is_a?Array value.map{|v| hidden_field_tag("new_customer[#{attr_key}][]", v)} else hidden_field_tag("new_customer[#{attr_key}]", value) end end end.flatten.compact.join.html_safe end |
#new_customer_attributes_params ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/new_customers_helper.rb', line 23 def new_customer_attributes_params attr_hash = { new_customer: {}} @new_customer.attributes.each do |attr_key, value| if value.present? attr_hash[:new_customer][attr_key] = value end end attr_hash.to_param end |
#new_customer_link_to_duplicates_step ⇒ Object
56 57 58 59 60 |
# File 'app/helpers/new_customers_helper.rb', line 56 def new_customer_link_to_duplicates_step "2. Duplicates", { action: 'duplicates' }, { class: 'btn btn-link', params: prefixed_new_customer_form_attributes } end |
#new_customer_link_to_email_preferences_step ⇒ Object
68 69 70 71 72 |
# File 'app/helpers/new_customers_helper.rb', line 68 def new_customer_link_to_email_preferences_step "4. Email Preferences", { action: 'email_preferences' }, { class: 'btn btn-link', params: prefixed_new_customer_form_attributes } end |
#new_customer_link_to_identify_step ⇒ Object
50 51 52 53 54 |
# File 'app/helpers/new_customers_helper.rb', line 50 def new_customer_link_to_identify_step "1. Identification", { action: 'identify' }, { class: 'btn btn-link', params: prefixed_new_customer_form_attributes } end |
#new_customer_link_to_setup_step ⇒ Object
62 63 64 65 66 |
# File 'app/helpers/new_customers_helper.rb', line 62 def new_customer_link_to_setup_step "3. Setup", { action: 'setup' }, { class: 'btn btn-link', params: prefixed_new_customer_form_attributes } end |
#prefixed_new_customer_form_attributes ⇒ Object
46 47 48 |
# File 'app/helpers/new_customers_helper.rb', line 46 def prefixed_new_customer_form_attributes @new_customer.attributes.inject({}) {|hsh, (k,v)| hsh["new_customer[#{k}]"] = v if v.present? ; hsh } end |
#rep_assign_method_collection_for_select ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/new_customers_helper.rb', line 33 def rep_assign_method_collection_for_select = [] << [ Customer::NewCustomer::REP_ASSIGN_METHODS[:aa] , :aa ] if current_user.is_sales_rep? or current_user.is_admin? << [ "Self Assign (#{current_user.full_name})", :sa ] end if can?(:assign_sales_rep, Customer) << [ Customer::NewCustomer::REP_ASSIGN_METHODS[:ma], :ma ] end << [ Customer::NewCustomer::REP_ASSIGN_METHODS[:dna], :dna ] end |