Class: Workarea::Admin::FeaturedProductsController
Instance Method Summary
collapse
#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model
Methods included from Publishing
#allow_publishing!, #set_publishing_options
Methods included from Visiting
#most_visited
Instance Method Details
#add ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/workarea/admin/featured_products_controller.rb', line 24
def add
product = Catalog::Product.find(params[:product_id])
@featurable.add_product(product.id)
flash[:success] = t(
'workarea.admin.featured_products.flash_messages.added',
name: product.name
)
render(
partial: 'workarea/admin/featured_products/selected',
locals: {
featurable: @featurable,
product: ProductViewModel.wrap(product)
}
)
end
|
#allow_publishing? ⇒ Boolean
60
61
62
|
# File 'app/controllers/workarea/admin/featured_products_controller.rb', line 60
def allow_publishing?
super || !@featurable.active?
end
|
#edit ⇒ Object
8
9
10
11
|
# File 'app/controllers/workarea/admin/featured_products_controller.rb', line 8
def edit
search = Search::AdminProducts.new(view_model_options)
@search = Admin::SearchViewModel.new(search, view_model_options)
end
|
#remove ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'app/controllers/workarea/admin/featured_products_controller.rb', line 42
def remove
product = Catalog::Product.find(params[:product_id])
@featurable.remove_product(product.id)
flash[:success] = t(
'workarea.admin.featured_products.flash_messages.removed',
name: product.name
)
render(
partial: 'workarea/admin/featured_products/unselected',
locals: {
featurable: @featurable,
product: ProductViewModel.wrap(product)
}
)
end
|
#select ⇒ Object
19
20
21
22
|
# File 'app/controllers/workarea/admin/featured_products_controller.rb', line 19
def select
search = Search::AdminProducts.new(view_model_options)
@search = Admin::SearchViewModel.new(search, view_model_options)
end
|
#update ⇒ Object
13
14
15
16
17
|
# File 'app/controllers/workarea/admin/featured_products_controller.rb', line 13
def update
@featurable.update_attributes(product_ids: params[:product_ids])
flash[:success] = t('workarea.admin.catalog_variants.flash_messages.saved')
head :ok
end
|