Module: NewCustomersHelper
- Defined in:
- app/helpers/new_customers_helper.rb
Overview
View helper: new customers.
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
4 5 6 |
# File 'app/helpers/new_customers_helper.rb', line 4 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
8 9 10 |
# File 'app/helpers/new_customers_helper.rb', line 8 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
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/new_customers_helper.rb', line 12 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
24 25 26 27 28 29 30 |
# File 'app/helpers/new_customers_helper.rb', line 24 def new_customer_attributes_params attr_hash = { new_customer: {} } @new_customer.attributes.each do |attr_key, value| attr_hash[:new_customer][attr_key] = value if value.present? end attr_hash.to_param end |
#new_customer_link_to_duplicates_step ⇒ Object
53 54 55 56 57 |
# File 'app/helpers/new_customers_helper.rb', line 53 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
65 66 67 68 69 |
# File 'app/helpers/new_customers_helper.rb', line 65 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
47 48 49 50 51 |
# File 'app/helpers/new_customers_helper.rb', line 47 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
59 60 61 62 63 |
# File 'app/helpers/new_customers_helper.rb', line 59 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
41 42 43 44 45 |
# File 'app/helpers/new_customers_helper.rb', line 41 def prefixed_new_customer_form_attributes @new_customer.attributes.each_with_object({}) do |(k, v), hsh| hsh["new_customer[#{k}]"] = v if v.present? end end |
#rep_assign_method_collection_for_select ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/helpers/new_customers_helper.rb', line 32 def rep_assign_method_collection_for_select = [] << [Customer::NewCustomer::REP_ASSIGN_METHODS[:aa], :aa] << ["Self Assign (#{current_user.full_name})", :sa] if current_user.is_sales_rep? || current_user.is_admin? << [Customer::NewCustomer::REP_ASSIGN_METHODS[:ma], :ma] if can?(:assign_sales_rep, Customer) << [Customer::NewCustomer::REP_ASSIGN_METHODS[:dna], :dna] end |