Sha256: 843dcf3942c73892ba589a84ba69fab80aabcfb5b2e6b08cef98e9e398b7e729

Contents?: true

Size: 1.26 KB

Versions: 20

Compression:

Stored size: 1.26 KB

Contents

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

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

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

      protected

        def location_after_save
          if @option_type.created_at == @option_type.updated_at
            edit_admin_option_type_url(@option_type)
          else
            admin_option_types_url
          end
        end


      private
        def load_product
          @product = Product.friendly.find(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.not(id: @product.option_type_ids)
          else
            OptionType.all
          end
        end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
goca-spree-backend-3.1.14.rails.5.0 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.14 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.13 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.12 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.11 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.10 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.9 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.8 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.7 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.6 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.5 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.4 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.3 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.2 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.1 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.0 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.0.rc4 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.0.rc3 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.0.rc2 app/controllers/spree/admin/option_types_controller.rb
spree_backend-3.1.0.rc1 app/controllers/spree/admin/option_types_controller.rb