6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/decorators/controllers/solidus_pagy/admin/prices_controller_decorator.rb', line 6
def self.prepended(base)
base.class_eval do
def index
params[:q] ||= {}
@search = @product.prices
.accessible_by(current_ability, :index)
.ransack(params[:q])
master_prices_search_result(@search)
variant_prices_search_result(@search)
end
private
def master_prices_search_result(search)
@result = pagy(
search.result
.currently_valid
.for_master
.order(:variant_id, :country_iso, :currency),
page: params[:page],
items: Spree::Config.admin_variants_per_page
)
@pagy_master_prices = @result.first
@master_prices = @result.second
end
def variant_prices_search_result(search)
@result = pagy(
search.result
.currently_valid
.for_variant
.order(:variant_id, :country_iso, :currency),
page: params[:variants_page],
items: Spree::Config.admin_variants_per_page
)
@pagy_variant_prices = @result.first
@variant_prices = @result.second
end
end
end
|