Sha256: b93d5aad2deb692a8f8c01bea1c568fef8c36aa9e9ab852511906d60df27e9f7

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

ActiveAdmin.register ActiveadminSelleoCms::FormQuestion, as: 'FormQuestion' do
  belongs_to :form
  actions :all, except: [:show]
  menu false

  collection_action :sort, :method => :get do
    params[:ids].split(",").each_with_index do |id, index|
      ActiveadminSelleoCms::FormQuestion.update_all(['position=?', index+1], ['id=?', id.to_i])
    end
    render :nothing => true
  end

  controller do

    def new
      set_form
      @form_question = @form.questions.new(question_type: params[:question_type])
      render :partial => 'form', :layout => false
    end

    def create
      set_form
      @form_question = @form.questions.new(params[:form_question])
    end

    def edit
      set_form
      set_question
      render :partial => 'form', :layout => false
    end

    def update
      set_form
      set_question
      @form_question.update_attributes(params[:form_question])
    end

    def destroy
      set_form
      set_question
    end

    def set_form
      @form = ActiveadminSelleoCms::Form.find(params[:form_id])
    end

    def set_question
      @form_question = @form.questions.find(params[:id])
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
activeadmin-selleo-cms-0.0.61 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.60 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.59 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.58 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.54 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.52 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.51 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.49 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.48 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.47 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.46 app/admin/activeadmin_selleo_cms/form_question.rb
activeadmin-selleo-cms-0.0.45 app/admin/activeadmin_selleo_cms/form_question.rb