Sha256: 5804e0a7a5e94924ea99fe2aa136781f1a8e123fbab2b6602af859f1cd865912

Contents?: true

Size: 1.21 KB

Versions: 27

Compression:

Stored size: 1.21 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 :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.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

27 entries across 27 versions & 2 rubygems

Version Path
solidus_backend-1.0.7 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.6 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.5 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.4 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.3 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.2 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.4.10 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.1 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.0 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.0.rc2 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.0.rc1 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.4.9 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.0.pre3 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.0.pre2 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.4.8 app/controllers/spree/admin/option_types_controller.rb
solidus_backend-1.0.0.pre app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.4.7 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.4.6 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.4.5 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.4.4 app/controllers/spree/admin/option_types_controller.rb