Module: CrmFormHelper
- Included in:
- AddressesController, OrdersController, QuotesController
- Defined in:
- app/helpers/crm_form_helper.rb
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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/crm_form_helper.rb', line 15 def ( = {}) form = [:form] data_hash = { turbo_submits_with: 'Please wait…' } block_ui_class = 'block-ui-on-click' if [:confirm].present? data_hash[:turbo_confirm] = [:confirm] block_ui_class = 'block-ui-on-click' end data_hash.merge!([:data]) if [:data].present? extra_class = .delete(:extra_class) extra_class = 'mx-2 px-4' if extra_class.nil? name = [:name] || 'commit' value = [:value] || '1' id = [:id] css_class = "btn btn-#{[:button_class] || 'success'} #{block_ui_class} #{extra_class}" label = ([:label] || 'Continue').html_safe (type: 'submit', name:, value:, data: data_hash, id:, class: css_class) do label end end |
#boolean_select(form, field, value, prompt = false, disabled = false) ⇒ Object
3 4 5 |
# File 'app/helpers/crm_form_helper.rb', line 3 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
106 107 108 109 110 111 112 |
# File 'app/helpers/crm_form_helper.rb', line 106 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
7 8 9 |
# File 'app/helpers/crm_form_helper.rb', line 7 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
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/helpers/crm_form_helper.rb', line 76 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 if [:hint] output << tag.small([:hint], class: 'form-text form-hint text-muted') end output.html_safe end end end |
#opportunity_local_sales_rep_input(form, options = {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/helpers/crm_form_helper.rb', line 41 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
65 66 67 68 69 70 71 |
# File 'app/helpers/crm_form_helper.rb', line 65 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
11 12 13 |
# File 'app/helpers/crm_form_helper.rb', line 11 def submit_cancel( = {}) render partial: "/submit_cancel", locals: end |
#technical_rep_input(form, options = {}) ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/helpers/crm_form_helper.rb', line 49 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
57 58 59 60 61 62 63 |
# File 'app/helpers/crm_form_helper.rb', line 57 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
102 103 104 |
# File 'app/helpers/crm_form_helper.rb', line 102 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
96 97 98 99 100 |
# File 'app/helpers/crm_form_helper.rb', line 96 def yes_no_boolean_collection_for_select(blank: nil) r = [['Yes',true],['No',false]] r.insert(0, [blank, '']) if blank r end |