Sha256: 2e245cc390c2b597baee240adb1623bca487a5ab5d903d19c1c733ec566c7295

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

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|
          OptionValue.where(id: id).update_all(position: index)
        end

        respond_to do |format|
          format.html { redirect_to admin_product_variants_url(params[:product_id]) }
          format.js { render plain: 'Ok' }
        end
      end

      private

      def location_after_save
        edit_admin_option_type_url(@option_type)
      end

      def load_product
        @product = 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?
          OptionType.where('id NOT IN (?)', @product.option_type_ids)
        else
          OptionType.all
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
solidus_backend-2.1.1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.0.3 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.0.2 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.1.0 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.1.0.rc1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.0.1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.1.0.beta1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.0.0 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.0.0.rc1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-2.0.0.beta1 app/controllers/spree/admin/option_types_controller.rb