Module: ContaiHelper
- Defined in:
- app/helpers/contai_helper.rb
Instance Method Summary collapse
- #contai_button(record, text: "Contai!", css_class: "btn btn-secondary contai-btn") ⇒ Object
- #contai_field_with_button(form, field, options = {}) ⇒ Object
Instance Method Details
#contai_button(record, text: "Contai!", css_class: "btn btn-secondary contai-btn") ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/contai_helper.rb', line 2 def (record, text: "Contai!", css_class: "btn btn-secondary contai-btn") return unless record.class.respond_to?(:contai_config) && record.class.contai_config.any? text, contai_generation_path, params: { model: record.class.name, id: record.id }, method: :post, remote: true, class: css_class, data: { contai_target: record.class.contai_config[:output_field], contai_record_id: record.id, contai_model: record.class.name } end |
#contai_field_with_button(form, field, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/contai_helper.rb', line 17 def (form, field, = {}) record = form.object return form.text_area(field, ) unless record.class.respond_to?(:contai_config) config = record.class.contai_config return form.text_area(field, ) unless config[:output_field] == field content_tag :div, class: "contai-field-wrapper" do form.text_area(field, .merge( data: { contai_target: "output" } )) + content_tag(:button, "Contai!", type: "button", class: "btn btn-secondary contai-generate-btn", data: { controller: "contai", contai_model_value: record.class.name, contai_record_id_value: record.id, contai_output_target: field }) end end |