Sha256: 017907f2f86053ed4e15ef3a8017923b45ebd374fac8c07ef1ea35e864f232d4

Contents?: true

Size: 1 KB

Versions: 129

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Spree
  module Admin
    class OptionTypesController < ResourceController
      before_action :setup_new_option_value, only: :edit

      def update_values_positions
        params[:positions].each do |id, index|
          Spree::OptionValue.where(id: id).update_all(position: index)
        end

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

      private

      def location_after_save
        edit_admin_option_type_url(@option_type)
      end

      def load_product
        @product = Spree::Product.find_by_param!(params[:product_id])
      end

      def setup_new_option_value
        @option_type.option_values.build if @option_type.option_values.empty?
      end

      def set_available_option_types
        @available_option_types = if @product.option_type_ids.any?
          Spree::OptionType.where('id NOT IN (?)', @product.option_type_ids)
        else
          Spree::OptionType.all
        end
      end
    end
  end
end

Version data entries

129 entries across 129 versions & 2 rubygems

Version Path
solidus_backend-4.3.4 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.2.4 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.1.5 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.3.3 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.3.2 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.1.4 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.3.1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.3.0 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.2.3 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.1.3 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.0.4 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-3.4.6 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.0.3 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.1.2 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.2.2 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-3.4.5 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.2.1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.2.0 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.1.1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-4.0.2 app/controllers/spree/admin/option_types_controller.rb