Sha256: 715e63394a6fde723a587979362c04ec1cd7912a46c2eff2456a8dd14c7dc489

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module SolidusAdmin
  class TaxonomiesController < SolidusAdmin::BaseController
    include SolidusAdmin::ControllerHelpers::Search

    before_action :load_taxonomy, only: [:move]

    def index
      taxonomies = apply_search_to(
        Spree::Taxonomy.all,
        param: :q,
      )

      set_page_and_extract_portion_from(taxonomies)

      respond_to do |format|
        format.html { render component('taxonomies/index').new(page: @page) }
      end
    end

    def move
      @taxonomy.insert_at(params[:position].to_i)

      respond_to do |format|
        format.js { head :no_content }
      end
    end

    def destroy
      @taxonomies = Spree::Taxonomy.where(id: params[:id])

      Spree::Taxonomy.transaction { @taxonomies.destroy_all }

      flash[:notice] = t('.success')
      redirect_back_or_to taxonomies_path, status: :see_other
    end

    private

    def load_taxonomy
      @taxonomy = Spree::Taxonomy.find(params[:id])
      authorize! action_name, @taxonomy
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_admin-0.3.2 app/controllers/solidus_admin/taxonomies_controller.rb
solidus_admin-0.3.1 app/controllers/solidus_admin/taxonomies_controller.rb
solidus_admin-0.3.0 app/controllers/solidus_admin/taxonomies_controller.rb
solidus_admin-0.2.0 app/controllers/solidus_admin/taxonomies_controller.rb
solidus_admin-0.1.0 app/controllers/solidus_admin/taxonomies_controller.rb