Sha256: ae6d62ecc5e373b4d066b307ddd424f106ce6aa55214f354173953f84081df0e

Contents?: true

Size: 1.05 KB

Versions: 15

Compression:

Stored size: 1.05 KB

Contents

class Backend::Content::RowsController < Backend::BaseController
  include Concerns::Backend::PositionableController
  before_action :find_model, only: [:update_position, :destroy]

  def new
    if params[:klass] && params[:id] && params[:locale]
      instance = params[:klass].constantize.find params[:id]
      row = instance.content_rows.create!(locale: params[:locale])

      redirect_to content_path(instance, params[:locale], "content-row-#{row.id}")
    else
      render text: 'Insufficient params. Please provide klass, id and locale.'
    end
  end

  def destroy
    @row.destroy
    redirect_back_to_content('content-rows')
  end

  private

  def find_model
    @row = ContentRow.find params[:id]
  end

  def content_path(instance, locale, anchor)
    path = "edit_translation_backend_#{instance.class.to_s.downcase}_path"
    send(path, instance, locale, anchor: anchor)
  end

  def redirect_back_to_content(anchor = nil)
    anchor = "content-row-#{@row.id}" unless anchor.present?
    redirect_to content_path(@row.rowable, @row.locale, anchor)
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
udongo-5.9.0 app/controllers/backend/content/rows_controller.rb
udongo-5.8.0 app/controllers/backend/content/rows_controller.rb
udongo-5.7.0 app/controllers/backend/content/rows_controller.rb
udongo-5.6.0 app/controllers/backend/content/rows_controller.rb
udongo-5.5.0 app/controllers/backend/content/rows_controller.rb
udongo-5.4.0 app/controllers/backend/content/rows_controller.rb
udongo-5.3.1 app/controllers/backend/content/rows_controller.rb
udongo-5.3.0 app/controllers/backend/content/rows_controller.rb
udongo-5.2.0 app/controllers/backend/content/rows_controller.rb
udongo-5.1.0 app/controllers/backend/content/rows_controller.rb
udongo-5.0.2 app/controllers/backend/content/rows_controller.rb
udongo-5.0.1 app/controllers/backend/content/rows_controller.rb
udongo-5.0.0 app/controllers/backend/content/rows_controller.rb
udongo-4.0.0 app/controllers/backend/content/rows_controller.rb
udongo-3.0.0 app/controllers/backend/content/rows_controller.rb