Sha256: 092bb815ddb6ea6bd683bdd291319b2e7a3db65fa2c879a1bf1c097e19741ad1

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

class Pulitzer::PartialsController < Pulitzer::ApplicationController
  before_action :set_partial, except: [:new, :create, :update_all]

  def new
    @partial = Pulitzer::Partial.new(partial_params)
    @free_form_section = @partial.free_form_section
    render partial: 'new', locals: { partial: @partial }
  end

  def create
    @free_form_section = Pulitzer::FreeFormSection.find partial_params[:free_form_section_id]
    @partial = @free_form_section.partials.create partial_params
    if @partial && @partial.errors.empty?
      Pulitzer::CreatePartialContentElements.new(@partial).call
      render partial: 'show_wrapper', locals: { partial: @partial }
    else
      render partial: 'new', locals: {partial: @partial}
    end
  end

  def show
    render partial: 'show', locals: { partial: @partial }
  end

  def edit
    render partial: 'form', locals: { partial: @partial }
  end

  def update
    @partial.update partial_params
    render partial: 'show', locals: { partial: @partial }
  end

  def update_all
    partials = Pulitzer::Partial.find params[:partial]
    partials.each do |partial|
      new_sort_order = params[:partial].index(partial.id.to_s)
      partial.update_attribute(:sort_order, new_sort_order)
    end
    head :ok and return
  end

  def destroy
    @partial.destroy
    head :ok and return
  end

  def upgrade
    @partial = UpgradePartialVersion.new(@partial).call
    render partial: 'show', locals: { partial: @partial }
  end

  protected

  def partial_params
    params[:partial].permit!
  end

  def set_partial
    @partial = Pulitzer::Partial.find(params[:id])
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pulitzer-0.15.31 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.30 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.29 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.28 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.27 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.26 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.25 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.24 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.23 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.22 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.21 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.20 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.19 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.18 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.17 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.16 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.14 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.15.13 app/controllers/pulitzer/partials_controller.rb