Sha256: 275c1812c5470302efb999a78c003cbc1ad2fd96575fb5f92bee73d7c0dafcf5

Contents?: true

Size: 1.22 KB

Versions: 69

Compression:

Stored size: 1.22 KB

Contents

module Spree
  module Admin
    class OptionTypesController < ResourceController
      before_filter :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

69 entries across 69 versions & 3 rubygems

Version Path
spree_backend-2.3.13 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.14 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.12 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.13 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.11 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.12 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.10 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.9 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.11 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.10 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.8 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.7 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.9 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.1.12 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.6 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.8 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.1.11 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.3.5 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.2.7 app/controllers/spree/admin/option_types_controller.rb
spree_backend-2.1.10 app/controllers/spree/admin/option_types_controller.rb