Module: Rapidfire::ApplicationHelper
- Defined in:
- app/helpers/rapidfire/application_helper.rb
Instance Method Summary collapse
- #checkbox_checked?(answer, option) ⇒ Boolean
- #filter_link(question_id, option) ⇒ Object
- #render_answer_form_helper(answer, form) ⇒ Object
Instance Method Details
#checkbox_checked?(answer, option) ⇒ Boolean
8 9 10 11 12 |
# File 'app/helpers/rapidfire/application_helper.rb', line 8 def checkbox_checked?(answer, option) answers_delimiter = Rapidfire.answers_delimiter answers = answer.answer_text.to_s.split(answers_delimiter) answers.include?(option) end |
#filter_link(question_id, option) ⇒ Object
14 15 16 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/rapidfire/application_helper.rb', line 14 def filter_link(question_id, option) question_id = question_id.to_s option = option.to_s this_filter = { question_ids: (params.dig(:filter, :question_ids) || []).map(&:to_s), options: (params.dig(:filter, :options) || []).map(&:to_s) } if this_filter[:question_ids].include?(question_id) && this_filter[:options].include?(option) question_index = this_filter[:question_ids].index(question_id) this_filter[:question_ids].delete_at(question_index) if question_index option_index = this_filter[:options].index(option) this_filter[:options].delete_at(option_index) if option_index action_description = "Remove from" else this_filter[:question_ids] << question_id this_filter[:options] << option action_description = "Add to" end link_to "#{action_description} Filter", filter: this_filter end |
#render_answer_form_helper(answer, form) ⇒ Object
3 4 5 6 |
# File 'app/helpers/rapidfire/application_helper.rb', line 3 def render_answer_form_helper(answer, form) partial = answer.question.type.to_s.split("::").last.downcase render partial: "answer_wrapper", locals: { f: form, answer: answer, partial: partial } end |