Module: CrmFormHelper
- Included in:
- AddressesController, OrdersController, QuotesController
- Defined in:
- app/helpers/crm_form_helper.rb
Overview
View helper: crm form.
Instance Method Summary collapse
- #blocking_submit_button(options = {}) ⇒ Object
- #boolean_select(form, field, value, prompt = false, disabled = false) ⇒ Object
- #datalist(id, values) ⇒ Object
- #edit_button ⇒ Object
-
#form_style_attribute_display(label, display = nil, options = {}) ⇒ Object
Displays a form line with the label and display value using the same style as the form builder simple form uses, pass the value as display parameter of use a block.
- #opportunity_local_sales_rep_input(form, options = {}) ⇒ Object
- #sales_support_rep_input(form, options = {}) ⇒ Object
- #submit_cancel(options = {}) ⇒ Object
- #technical_rep_input(form, options = {}) ⇒ Object
- #technical_rep_sec_input(form, options = {}) ⇒ Object
- #yes_no_blank_boolean_collection_for_select(blank_name = 'n/a') ⇒ Object
- #yes_no_boolean_collection_for_select(blank: nil) ⇒ Object
Instance Method Details
#blocking_submit_button(options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/crm_form_helper.rb', line 16 def ( = {}) data_hash = { controller: 'ui-blocker', turbo_submits_with: 'Please wait…' } data_hash[:turbo_confirm] = [:confirm] if [:confirm].present? data_hash.merge!([:data]) if [:data].present? extra_class = .delete(:extra_class) || 'mx-2 px-4' css_class = "btn btn-#{[:button_class] || 'success'} #{extra_class}" (type: 'submit', name: [:name] || 'commit', value: [:value] || '1', data: data_hash, id: [:id], class: css_class) do ([:label] || 'Continue').html_safe end end |
#boolean_select(form, field, value, prompt = false, disabled = false) ⇒ Object
4 5 6 |
# File 'app/helpers/crm_form_helper.rb', line 4 def boolean_select(form, field, value, prompt = false, disabled = false) form.select field, ([["Yes", true], ["No", false]], selected: value), { prompt: prompt }, { disabled: disabled, class: "form-control", style: "max-width:200px" } end |
#datalist(id, values) ⇒ Object
95 96 97 98 99 100 101 |
# File 'app/helpers/crm_form_helper.rb', line 95 def datalist(id, values) content_tag(:datalist, id: id) do values.each do |n| concat tag.option(value: n) end end end |
#edit_button ⇒ Object
8 9 10 |
# File 'app/helpers/crm_form_helper.rb', line 8 def fa_icon('pen-to-square', text: 'Edit') end |
#form_style_attribute_display(label, display = nil, options = {}) ⇒ Object
Displays a form line with the label and display value using the same style
as the form builder simple form uses, pass the value as display parameter
of use a block
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/crm_form_helper.rb', line 67 def form_style_attribute_display(label, display = nil, = {}) content_tag :div, class: 'form-group row' do content_tag(:label, label, class: 'optional col-sm-3 col-form-label') + content_tag(:div, class: 'col') do display_value = display || (yield if block_given?) output = if [:raw] tag.span display_value elsif [:multi_line] text_area_tag 'label', display_value, class: 'form-control', disabled: true else text_field_tag 'label', display_value, class: 'form-control', disabled: true end output << tag.small([:hint], class: 'form-text form-hint text-muted') if [:hint] output.html_safe end end end |
#opportunity_local_sales_rep_input(form, options = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/helpers/crm_form_helper.rb', line 32 def opportunity_local_sales_rep_input(form, = {}) form.input :local_sales_rep_id, label: 'Local Sales Rep', as: :tom_select, collection: Employee., include_blank: true, placeholder: [:placeholder] end |
#sales_support_rep_input(form, options = {}) ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/helpers/crm_form_helper.rb', line 56 def sales_support_rep_input(form, = {}) form.input :sales_support_rep_id, label: 'Sales Support Rep', as: :tom_select, collection: Employee., include_blank: true, placeholder: [:placeholder] end |
#submit_cancel(options = {}) ⇒ Object
12 13 14 |
# File 'app/helpers/crm_form_helper.rb', line 12 def submit_cancel( = {}) render partial: "/submit_cancel", locals: end |
#technical_rep_input(form, options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/helpers/crm_form_helper.rb', line 40 def technical_rep_input(form, = {}) form.input :technical_support_rep_id, label: 'Technical Rep 1', as: :tom_select, collection: Employee., include_blank: true, placeholder: [:placeholder] end |
#technical_rep_sec_input(form, options = {}) ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/helpers/crm_form_helper.rb', line 48 def technical_rep_sec_input(form, = {}) form.input :technical_support_rep_sec_id, label: 'Technical Rep 2', as: :tom_select, collection: Employee., include_blank: true, placeholder: [:placeholder] end |
#yes_no_blank_boolean_collection_for_select(blank_name = 'n/a') ⇒ Object
91 92 93 |
# File 'app/helpers/crm_form_helper.rb', line 91 def yes_no_blank_boolean_collection_for_select(blank_name = 'n/a') yes_no_boolean_collection_for_select(blank: blank_name) end |
#yes_no_boolean_collection_for_select(blank: nil) ⇒ Object
85 86 87 88 89 |
# File 'app/helpers/crm_form_helper.rb', line 85 def yes_no_boolean_collection_for_select(blank: nil) r = [['Yes', true], ['No', false]] r.insert(0, [blank, '']) if blank r end |