solidus_pagy 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +39 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.github_changelog_generator +2 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +37 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +52 -0
- data/LICENSE +26 -0
- data/README.md +142 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/spree/backend/solidus_pagy.js +1 -0
- data/app/assets/javascripts/spree/frontend/solidus_pagy.js +2 -0
- data/app/assets/stylesheets/spree/backend/solidus_pagy.css +7 -0
- data/app/assets/stylesheets/spree/frontend/solidus_pagy.css +4 -0
- data/app/decorators/controllers/solidus_pagy/admin/base_controller_decorator.rb +13 -0
- data/app/decorators/controllers/solidus_pagy/admin/orders_controller_decorator.rb +63 -0
- data/app/decorators/controllers/solidus_pagy/admin/prices_controller_decorator.rb +51 -0
- data/app/decorators/controllers/solidus_pagy/admin/products_controller_decorator.rb +32 -0
- data/app/decorators/controllers/solidus_pagy/admin/promotion_codes_controller_decorator.rb +37 -0
- data/app/decorators/controllers/solidus_pagy/admin/promotions_controller_decorator.rb +32 -0
- data/app/decorators/controllers/solidus_pagy/admin/properties_controller_decorator.rb +32 -0
- data/app/decorators/controllers/solidus_pagy/admin/stock_items_controller_decorator.rb +42 -0
- data/app/decorators/controllers/solidus_pagy/admin/stock_locations_controller_decorator.rb +25 -0
- data/app/decorators/controllers/solidus_pagy/admin/stock_movements_controller_decorator.rb +25 -0
- data/app/decorators/controllers/solidus_pagy/admin/tax_rates_controller_decorator.rb +27 -0
- data/app/decorators/controllers/solidus_pagy/admin/users_controller_decorator.rb +68 -0
- data/app/decorators/controllers/solidus_pagy/admin/variants_controller_decorator.rb +33 -0
- data/app/decorators/controllers/solidus_pagy/admin/zones_controller_decorator.rb +28 -0
- data/app/overrides/spree/admin/orders/index/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/prices/_master_variant_table/insert_pagy_pagination.rb +11 -0
- data/app/overrides/spree/admin/prices/_table/insert_pagy_pagination.rb +11 -0
- data/app/overrides/spree/admin/products/index/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/promotion_codes/index/insert_pagy_pagination.rb +19 -0
- data/app/overrides/spree/admin/promotions/index/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/properties/index/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/stock_items/_stock_management/insert_pagy_pagination.rb +11 -0
- data/app/overrides/spree/admin/stock_locations/index/insert_pagy_pagination.rb +11 -0
- data/app/overrides/spree/admin/stock_movements/index/insert_pagy_pagination.rb +11 -0
- data/app/overrides/spree/admin/tax_rates/index/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/users/index/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/users/items/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/users/orders/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/variants/_table/insert_pagy_pagination.rb +9 -0
- data/app/overrides/spree/admin/zones/index/insert_pagy_pagination.rb +9 -0
- data/bin/console +17 -0
- data/bin/rails +7 -0
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +86 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +5 -0
- data/lib/generators/solidus_pagy/install/install_generator.rb +18 -0
- data/lib/generators/solidus_pagy/install/templates/initializer.rb +30 -0
- data/lib/generators/solidus_pagy/install/templates/pagy.rb +235 -0
- data/lib/solidus_pagy/configuration.rb +27 -0
- data/lib/solidus_pagy/engine.rb +16 -0
- data/lib/solidus_pagy/testing_support/factories.rb +4 -0
- data/lib/solidus_pagy/version.rb +5 -0
- data/lib/solidus_pagy.rb +11 -0
- data/solidus_pagy.gemspec +44 -0
- data/spec/controllers/spree/admin/orders_controller_spec.rb +100 -0
- data/spec/controllers/spree/admin/prices_controller_spec.rb +80 -0
- data/spec/controllers/spree/admin/products_controller_spec.rb +57 -0
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +38 -0
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +90 -0
- data/spec/controllers/spree/admin/properties_controller_spec.rb +15 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +35 -0
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +26 -0
- data/spec/controllers/spree/admin/stock_movements_controller_spec.rb +81 -0
- data/spec/controllers/spree/admin/tax_rates_controller_spec.rb +15 -0
- data/spec/controllers/spree/admin/users_controller_spec.rb +117 -0
- data/spec/controllers/spree/admin/variants_controller_spec.rb +76 -0
- data/spec/controllers/spree/admin/zones_controller_spec.rb +15 -0
- data/spec/solidus_pagy/configuration_spec.rb +55 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/devise.rb +8 -0
- data/spec/support/pagy.rb.rb +8 -0
- data/spec/support/solidus.rb +16 -0
- metadata +248 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module StockItemsControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def load_stock_management_data
|
11
|
+
@stock_locations = ::Spree::StockLocation.accessible_by(current_ability)
|
12
|
+
@stock_item_stock_locations = if params[:stock_location_id].present?
|
13
|
+
@stock_locations.where(id: params[:stock_location_id])
|
14
|
+
else
|
15
|
+
@stock_locations
|
16
|
+
end
|
17
|
+
@variant_display_attributes = self.class.variant_display_attributes
|
18
|
+
@variants = ::Spree::Config.variant_search_class.new(
|
19
|
+
params[:variant_search_term], scope: variant_scope
|
20
|
+
).results
|
21
|
+
@variants = @variants.includes(
|
22
|
+
:images,
|
23
|
+
stock_items: :stock_location,
|
24
|
+
product: :variant_images
|
25
|
+
)
|
26
|
+
@variants = @variants.includes(option_values: :option_type)
|
27
|
+
|
28
|
+
@result = pagy(
|
29
|
+
@variants.order(id: :desc),
|
30
|
+
page: params[:page],
|
31
|
+
items: params[:per_page] || ::SolidusPagy.config.orders_per_page
|
32
|
+
)
|
33
|
+
@pagy = @result.first
|
34
|
+
@variants = @result.second
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
::Spree::Admin::StockItemsController.prepend(self)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module StockLocationsControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def collection
|
11
|
+
@result = pagy(
|
12
|
+
super,
|
13
|
+
page: params[:page],
|
14
|
+
items: ::SolidusPagy.config.admin_products_per_page
|
15
|
+
)
|
16
|
+
@pagy = @result.first
|
17
|
+
@collection = @result.second
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
::Spree::Admin::StockLocationsController.prepend(self)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module StockMovementsControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
def index
|
9
|
+
params[:q] ||= {}
|
10
|
+
|
11
|
+
@search = collection.ransack(params[:q])
|
12
|
+
@result = pagy(
|
13
|
+
@search.result,
|
14
|
+
page: params[:page]
|
15
|
+
)
|
16
|
+
@pagy = @result.first
|
17
|
+
@stock_movements = @result.second
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
::Spree::Admin::StockMovementsController.prepend(self)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module TaxRatesControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def collection
|
11
|
+
@search = Spree::TaxRate.ransack(params[:q])
|
12
|
+
@collection = @search.result
|
13
|
+
@result = pagy(
|
14
|
+
@collection.includes(:tax_categories).order(:zone_id),
|
15
|
+
page: params[:page],
|
16
|
+
items: ::SolidusPagy.config.admin_products_per_page
|
17
|
+
)
|
18
|
+
@pagy = @result.first
|
19
|
+
@collection = @result.second
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
::Spree::Admin::TaxRatesController.prepend(self)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module UsersControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
def orders
|
9
|
+
params[:q] ||= {}
|
10
|
+
|
11
|
+
@search = ::Spree::Order.reverse_chronological.ransack(
|
12
|
+
params[:q].merge(user_id_eq: @user.id)
|
13
|
+
)
|
14
|
+
|
15
|
+
@result = pagy(
|
16
|
+
@search.result,
|
17
|
+
page: params[:page],
|
18
|
+
items: ::SolidusPagy.config.admin_products_per_page
|
19
|
+
)
|
20
|
+
|
21
|
+
@pagy = @result.first
|
22
|
+
@orders = @result.second
|
23
|
+
end
|
24
|
+
|
25
|
+
def items
|
26
|
+
params[:q] ||= {}
|
27
|
+
|
28
|
+
@search = Spree::Order.includes(
|
29
|
+
line_items: {
|
30
|
+
variant: [:product, { option_values: :option_type }]
|
31
|
+
}
|
32
|
+
).ransack(params[:q].merge(user_id_eq: @user.id))
|
33
|
+
|
34
|
+
@result = pagy(
|
35
|
+
@search.result,
|
36
|
+
page: params[:page],
|
37
|
+
items: ::SolidusPagy.config.admin_products_per_page
|
38
|
+
)
|
39
|
+
|
40
|
+
@pagy = @result.first
|
41
|
+
@orders = @result.second
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def collection
|
47
|
+
return @collection if @collection
|
48
|
+
|
49
|
+
@search = super.ransack(params[:q])
|
50
|
+
@collection = @search.result.includes(:spree_roles)
|
51
|
+
@collection = @collection.includes(:spree_orders)
|
52
|
+
|
53
|
+
@result = pagy(
|
54
|
+
@collection,
|
55
|
+
page: params[:page],
|
56
|
+
items: params[:per_page]
|
57
|
+
)
|
58
|
+
|
59
|
+
@pagy = @result.first
|
60
|
+
@users = @result.second
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
::Spree::Admin::UsersController.prepend(self)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module VariantsControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def collection
|
11
|
+
base_variant_scope ||= super.with_discarded if params[:deleted] == 'on'
|
12
|
+
base_variant_scope ||= super
|
13
|
+
|
14
|
+
search = ::Spree::Config.variant_search_class.new(
|
15
|
+
params[:variant_search_term], scope: base_variant_scope
|
16
|
+
)
|
17
|
+
|
18
|
+
@result = pagy(
|
19
|
+
search.results.includes(variant_includes),
|
20
|
+
page: params[:page],
|
21
|
+
items: ::Spree::Config[:admin_variants_per_page]
|
22
|
+
)
|
23
|
+
|
24
|
+
@pagy = @result.first
|
25
|
+
@collection = @result.second
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
::Spree::Admin::VariantsController.prepend(self)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module ZonesControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def collection
|
11
|
+
params[:q] ||= {}
|
12
|
+
params[:q][:s] ||= 'name asc'
|
13
|
+
@search = super.ransack(params[:q])
|
14
|
+
@result = pagy(
|
15
|
+
@search.result,
|
16
|
+
page: params[:page],
|
17
|
+
items: params[:per_page]
|
18
|
+
)
|
19
|
+
@pagy = @result.first
|
20
|
+
@zones = @result.second
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
::Spree::Admin::ZonesController.prepend(self)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'orders/index/insert_pagy_pagination#list',
|
5
|
+
original: 'b7e52f69693d41381ad087c82d1d90e6bd700e30',
|
6
|
+
virtual_path: 'spree/admin/orders/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @orders")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "orders_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'prices/master_variant_table/insert_pagy_pagination#list',
|
5
|
+
original: '5280d1ae82211875dfa421b8a28a69011ffbb928',
|
6
|
+
virtual_path: 'spree/admin/prices/_master_variant_table',
|
7
|
+
replace: 'erb[loud]:contains("paginate master_prices")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym,
|
9
|
+
@pagy_master_prices,
|
10
|
+
pagy_id: "master_prices_pagination") if @pagy_master_prices.pages > 1 %>'
|
11
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'prices/table/insert_pagy_pagination#list',
|
5
|
+
original: '1200edf2531c8fa4f48a65f17788b77b6f414d73',
|
6
|
+
virtual_path: 'spree/admin/prices/_table',
|
7
|
+
replace: 'erb[loud]:contains("paginate variant_prices")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym,
|
9
|
+
@pagy_variant_prices,
|
10
|
+
pagy_id: "variant_prices_pagination") if @pagy_variant_prices.pages > 1 %>'
|
11
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'products/index/insert_pagy_pagination#list',
|
5
|
+
original: 'c2d3b41787ed2e7a731868e9a222898b1e62dfa9',
|
6
|
+
virtual_path: 'spree/admin/products/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @collection")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "products_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'promotion_codes/index/insert_pagy_pagination#info',
|
5
|
+
original: 'fdef17fe07f87ed1ddfe8ff8ae04a50afbe2b796',
|
6
|
+
virtual_path: 'spree/admin/promotion_codes/index',
|
7
|
+
replace: 'erb[loud]:contains("page_entries_info(@promotion_codes)")',
|
8
|
+
text: '<%== pagy_info(@pagy) %>'
|
9
|
+
)
|
10
|
+
|
11
|
+
Deface::Override.new(
|
12
|
+
name: 'promotion_codes/index/insert_pagy_pagination#list',
|
13
|
+
original: 'd95e6d826172f503b6d6201eed50298dcf4fd4ec',
|
14
|
+
virtual_path: 'spree/admin/promotion_codes/index',
|
15
|
+
replace: 'erb[loud]:contains("paginate @promotion_codes")',
|
16
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym,
|
17
|
+
@pagy,
|
18
|
+
pagy_id: "promotion_codes_pagination") if @pagy.pages > 1 %>'
|
19
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'promotions/index/insert_pagy_pagination#list',
|
5
|
+
original: 'e0314f1ec7a40d21ce037d74b77acf6c78faaf43',
|
6
|
+
virtual_path: 'spree/admin/promotions/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @promotions")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "promotions_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'properties/index/insert_pagy_pagination#list',
|
5
|
+
original: 'c2d3b41787ed2e7a731868e9a222898b1e62dfa9',
|
6
|
+
virtual_path: 'spree/admin/properties/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @collection")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "properties_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'stock_items/_stock_management/insert_pagy_pagination#list',
|
5
|
+
original: 'e47566029b18a9272fd4dd1d1e881754e9af5f79',
|
6
|
+
virtual_path: 'spree/admin/stock_items/_stock_management',
|
7
|
+
replace: 'erb[loud]:contains("paginate @variants")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym,
|
9
|
+
@pagy,
|
10
|
+
pagy_id: "stock_items_pagination") if @pagy.pages > 1 %>'
|
11
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'stock_locations/index/insert_pagy_pagination#list',
|
5
|
+
original: '70e191acf75f034d4e2348e8c88b15137de17a1e',
|
6
|
+
virtual_path: 'spree/admin/stock_locations/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @stock_locations")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym,
|
9
|
+
@pagy,
|
10
|
+
pagy_id: "stock_locations_pagination") if @pagy.pages > 1 %>'
|
11
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'stock_movements/index/insert_pagy_pagination#list',
|
5
|
+
original: 'fbfad74a653d52d8167dc2f081a6e98e20efa6c4',
|
6
|
+
virtual_path: 'spree/admin/stock_movements/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @stock_movements")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym,
|
9
|
+
@pagy,
|
10
|
+
pagy_id: "stock_movements_pagination") if @pagy.pages > 1 %>'
|
11
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'tax_rates/index/insert_pagy_pagination#list',
|
5
|
+
original: '0b28a26d9e429d793c31354061e6e795dafa8139',
|
6
|
+
virtual_path: 'spree/admin/tax_rates/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @tax_rates")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "tax_rates_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'users/index/insert_pagy_pagination#list',
|
5
|
+
original: '9df2b9817425d00013b15e0f58787b2563c2cbff',
|
6
|
+
virtual_path: 'spree/admin/users/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @users")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "users_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'users/items/insert_pagy_pagination#list',
|
5
|
+
original: 'b7e52f69693d41381ad087c82d1d90e6bd700e30',
|
6
|
+
virtual_path: 'spree/admin/users/items',
|
7
|
+
replace: 'erb[loud]:contains("paginate @orders")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "users_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'users/orders/insert_pagy_pagination#list',
|
5
|
+
original: 'b7e52f69693d41381ad087c82d1d90e6bd700e30',
|
6
|
+
virtual_path: 'spree/admin/users/orders',
|
7
|
+
replace: 'erb[loud]:contains("paginate @orders")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "users_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'variants/_table/insert_pagy_pagination#list',
|
5
|
+
original: '0a28fcda35c7d2c7b41b7bc35d0e0fce394cdb6c',
|
6
|
+
virtual_path: 'spree/admin/variants/_table',
|
7
|
+
replace: 'erb[loud]:contains("paginate variants")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "variants_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
name: 'zones/index/insert_pagy_pagination#list',
|
5
|
+
original: '52486164557b59e1bc70c5a486ffd63584294d84',
|
6
|
+
virtual_path: 'spree/admin/zones/index',
|
7
|
+
replace: 'erb[loud]:contains("paginate @zones")',
|
8
|
+
text: '<%== send(SolidusPagy.config.nav_helper.to_sym, @pagy, pagy_id: "zones_pagination") if @pagy.pages > 1 %>'
|
9
|
+
)
|
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require "solidus_pagy"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
|
11
|
+
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
+
# require "pry"
|
14
|
+
# Pry.start
|
15
|
+
|
16
|
+
require "irb"
|
17
|
+
IRB.start(__FILE__)
|
data/bin/rails
ADDED
data/bin/rails-engine
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path('../lib/solidus_pagy/engine', __dir__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
11
|
+
|
12
|
+
require 'rails/all'
|
13
|
+
require 'rails/engine/commands'
|
data/bin/rails-sandbox
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
app_root = 'sandbox'
|
4
|
+
|
5
|
+
unless File.exist? "#{app_root}/bin/rails"
|
6
|
+
warn 'Creating the sandbox app...'
|
7
|
+
Dir.chdir "#{__dir__}/.." do
|
8
|
+
system "#{__dir__}/sandbox" or begin
|
9
|
+
warn 'Automatic creation of the sandbox app failed'
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir.chdir app_root
|
16
|
+
exec 'bin/rails', *ARGV
|
data/bin/rake
ADDED
data/bin/sandbox
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
case "$DB" in
|
6
|
+
postgres|postgresql)
|
7
|
+
RAILSDB="postgresql"
|
8
|
+
;;
|
9
|
+
mysql)
|
10
|
+
RAILSDB="mysql"
|
11
|
+
;;
|
12
|
+
sqlite|'')
|
13
|
+
RAILSDB="sqlite3"
|
14
|
+
;;
|
15
|
+
*)
|
16
|
+
echo "Invalid DB specified: $DB"
|
17
|
+
exit 1
|
18
|
+
;;
|
19
|
+
esac
|
20
|
+
|
21
|
+
if [ ! -z $SOLIDUS_BRANCH ]
|
22
|
+
then
|
23
|
+
BRANCH=$SOLIDUS_BRANCH
|
24
|
+
else
|
25
|
+
BRANCH="master"
|
26
|
+
fi
|
27
|
+
|
28
|
+
extension_name="solidus_pagy"
|
29
|
+
|
30
|
+
# Stay away from the bundler env of the containing extension.
|
31
|
+
function unbundled {
|
32
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
|
33
|
+
}
|
34
|
+
|
35
|
+
rm -rf ./sandbox
|
36
|
+
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
|
37
|
+
--skip-bundle \
|
38
|
+
--skip-git \
|
39
|
+
--skip-keeps \
|
40
|
+
--skip-rc \
|
41
|
+
--skip-spring \
|
42
|
+
--skip-test \
|
43
|
+
--skip-javascript
|
44
|
+
|
45
|
+
if [ ! -d "sandbox" ]; then
|
46
|
+
echo 'sandbox rails application failed'
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
|
50
|
+
cd ./sandbox
|
51
|
+
cat <<RUBY >> Gemfile
|
52
|
+
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
|
53
|
+
gem 'solidus_auth_devise', '>= 2.1.0'
|
54
|
+
gem 'rails-i18n'
|
55
|
+
gem 'solidus_i18n'
|
56
|
+
|
57
|
+
gem '$extension_name', path: '..'
|
58
|
+
|
59
|
+
group :test, :development do
|
60
|
+
platforms :mri do
|
61
|
+
gem 'pry-byebug'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
RUBY
|
65
|
+
|
66
|
+
unbundled bundle install --gemfile Gemfile
|
67
|
+
|
68
|
+
unbundled bundle exec rake db:drop db:create
|
69
|
+
|
70
|
+
unbundled bundle exec rails generate solidus:install \
|
71
|
+
--auto-accept \
|
72
|
+
--user_class=Spree::User \
|
73
|
+
--enforce_available_locales=true \
|
74
|
+
--with-authentication=false \
|
75
|
+
--payment-method=none \
|
76
|
+
$@
|
77
|
+
|
78
|
+
unbundled bundle exec rails generate solidus:auth:install
|
79
|
+
unbundled bundle exec rails generate ${extension_name}:install
|
80
|
+
|
81
|
+
echo
|
82
|
+
echo "🚀 Sandbox app successfully created for $extension_name!"
|
83
|
+
echo "🚀 Using $RAILSDB and Solidus $BRANCH"
|
84
|
+
echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
|
85
|
+
echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
|
86
|
+
echo "🚀 This app is intended for test purposes."
|
data/bin/setup
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
|
8
|
+
def copy_initializer
|
9
|
+
template 'initializer.rb', 'config/initializers/solidus_pagy.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_stylesheets
|
13
|
+
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_pagy\n", before: %r{\*/}, verbose: true
|
14
|
+
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_pagy\n", before: %r{\*/}, verbose: true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|