Sha256: d6ee73979ea6d84f5bf38307416ab7faef59376d779743ca5940a7a2c48adb39
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 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.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
4 entries across 4 versions & 1 rubygems