Class: Spree::Admin::OptionTypesController
Instance Method Summary
collapse
belongs_to, create, #create, destroy, #destroy, #edit, #new, new_action, #update, update
included
Instance Method Details
#available ⇒ Object
6
7
8
9
|
# File 'app/controllers/spree/admin/option_types_controller.rb', line 6
def available
set_available_option_types
render :layout => false
end
|
#remove ⇒ Object
15
16
17
18
19
20
|
# File 'app/controllers/spree/admin/option_types_controller.rb', line 15
def remove
@product.option_types.delete(@option_type)
@product.save
flash.notice = I18n.t('notice_messages.option_type_removed')
redirect_to selected_admin_product_option_types_url(@product)
end
|
#select ⇒ Object
AJAX method for selecting an existing option type and associating with the current product
34
35
36
37
38
39
40
|
# File 'app/controllers/spree/admin/option_types_controller.rb', line 34
def select
@product = Product.find_by_param!(params[:product_id])
@product.option_types << OptionType.find(params[:id])
@product.reload
@option_types = @product.option_types
set_available_option_types
end
|
#selected ⇒ Object
11
12
13
|
# File 'app/controllers/spree/admin/option_types_controller.rb', line 11
def selected
@option_types = @product.option_types
end
|
#update_positions ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/spree/admin/option_types_controller.rb', line 22
def update_positions
params[:positions].each do |id, index|
OptionType.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
|