Sha256: 6d3b1ee0e754b3e62fe4d2c883da2aa0649ddc710c3e6833c30049f68e0828d3

Contents?: true

Size: 841 Bytes

Versions: 10

Compression:

Stored size: 841 Bytes

Contents

module Spree
  module Admin
    class OptionTypesController < ResourceController
      include Translatable

      before_action :setup_new_option_value, only: :edit

      def update_values_positions
        ApplicationRecord.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 spree.admin_product_variants_url(params[:product_id]) }
          format.js { render plain: 'Ok' }
        end
      end

      protected

      def location_after_save
        edit_admin_option_type_url(@option_type)
      end

      private

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_backend-4.8.4 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.8.3 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.8.2 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.8.1 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.7.2 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.6.2 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.7.1 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.7.0 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.6.1 app/controllers/spree/admin/option_types_controller.rb
spree_backend-4.6.0 app/controllers/spree/admin/option_types_controller.rb