Sha256: 8d7d819fb6c9df238fa7467630f8f486407c424a79efa754f267ce97901af306

Contents?: true

Size: 1.23 KB

Versions: 88

Compression:

Stored size: 1.23 KB

Contents

#InlineForms::SPECIAL_COLUMN_TYPES[:question_list]=:no_migration

# checklist
def question_list_show(object, attribute)
  out = '<ul class="question_list">'
  out << link_to_inline_edit(object, attribute) if object.send(attribute).empty?
  object.send(attribute).sort.each do | item |
    out << '<li>'
    out << link_to_inline_edit(object, attribute, item._presentation )
    out << '</li>'
  end
  out <<  '</ul>'
  out.html_safe
end

def question_list_edit(object, attribute)
  object.send(attribute).build  if object.send(attribute).empty?
  values = object.send(attribute).first.class.name.constantize.find(:all) # TODO bring order
  out = '<div class="edit_form_checklist">'
  out << '<ul>'
  Question.all.each do | question |
    out << '<li>'
    out << h(question._presentation)
    unless question.subquestions.empty?
      out << '<ul>'
      question.subquestions.each do | subquestion |
        out << '<li>'
        out << h(subquestion._presentation)
        out << '</li>'
      end
      out << '</ul>'
    end
    out << '</li>'
  end
  out << '</ul>'
  out << '</div>'
  out.html_safe
end

def question_list_update(object, attribute)
  params[attribute] ||= {}
  object.send(attribute.singularize + '_ids=', params[attribute].keys)
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
inline_forms-1.3.12 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.11 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.10 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.9 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.8 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.7 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.6 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.5 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.4 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.3 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.2 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.1 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.3.0 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.2.9 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.2.8 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.2.7 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.2.5 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.2.4 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.2.3 lib/app/helpers/form_elements/question_list.rb
inline_forms-1.2.2 lib/app/helpers/form_elements/question_list.rb