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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 45c5fe64e0ad5ad3bfdeedefa752875c8dc3100d902d39870e43f9978621431f
|
4
|
+
data.tar.gz: d7edee57426ed7926cfa540b627611b0c180738056217f4bbe147b7e5356549b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 726d3da4a6c1d901f5e5b81d0a11798276c228539126bb10bbd88e04b7e12548220fa828603f6eeb58effcec236c514882a8cf6a6f91615bd4677c3017b0d0f4
|
7
|
+
data.tar.gz: c0a16a7e7367cdeec8fbd31cbe0aec9919d45d622d437fed6f5ee8112af904c23127f1bc337a35cee8ab0eb84fa496074d9fa24b977e4cadad79004040b52a79
|
@@ -0,0 +1,39 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
browser-tools: circleci/browser-tools@1.1
|
5
|
+
|
6
|
+
# Always take the latest version of the orb, this allows us to
|
7
|
+
# run specs against Solidus supported versions only without the need
|
8
|
+
# to change this configuration every time a Solidus version is released
|
9
|
+
# or goes EOL.
|
10
|
+
solidusio_extensions: solidusio/extensions@volatile
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
run-specs-with-postgres:
|
14
|
+
executor: solidusio_extensions/postgres
|
15
|
+
steps:
|
16
|
+
- browser-tools/install-browser-tools
|
17
|
+
- solidusio_extensions/run-tests
|
18
|
+
run-specs-with-mysql:
|
19
|
+
executor: solidusio_extensions/mysql
|
20
|
+
steps:
|
21
|
+
- browser-tools/install-browser-tools
|
22
|
+
- solidusio_extensions/run-tests
|
23
|
+
|
24
|
+
workflows:
|
25
|
+
"Run specs on supported Solidus versions":
|
26
|
+
jobs:
|
27
|
+
- run-specs-with-postgres
|
28
|
+
- run-specs-with-mysql
|
29
|
+
"Weekly run specs against master":
|
30
|
+
triggers:
|
31
|
+
- schedule:
|
32
|
+
cron: "0 0 * * 4" # every Thursday
|
33
|
+
filters:
|
34
|
+
branches:
|
35
|
+
only:
|
36
|
+
- master
|
37
|
+
jobs:
|
38
|
+
- run-specs-with-postgres
|
39
|
+
- run-specs-with-mysql
|
data/.gem_release.yml
ADDED
data/.github/stale.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Number of days of inactivity before an issue becomes stale
|
2
|
+
daysUntilStale: 60
|
3
|
+
# Number of days of inactivity before a stale issue is closed
|
4
|
+
daysUntilClose: false
|
5
|
+
# Issues with these labels will never be considered stale
|
6
|
+
exemptLabels:
|
7
|
+
- pinned
|
8
|
+
- security
|
9
|
+
# Label to use when marking an issue as stale
|
10
|
+
staleLabel: stale
|
11
|
+
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
|
+
markComment: >
|
13
|
+
This issue has been automatically marked as stale because it has not had
|
14
|
+
recent activity. It might be closed if no further activity occurs. Thank you
|
15
|
+
for your contributions.
|
16
|
+
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
+
closeComment: false
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require:
|
2
|
+
- solidus_dev_support/rubocop
|
3
|
+
|
4
|
+
inherit_gem:
|
5
|
+
solidus_dev_support: .rubocop.yml
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
NewCops: disable
|
9
|
+
Exclude:
|
10
|
+
- bin/*
|
11
|
+
- spec/dummy/**/*
|
12
|
+
- vendor/**/*
|
13
|
+
|
14
|
+
Rails/SkipsModelValidations:
|
15
|
+
Exclude:
|
16
|
+
- db/migrate/**/*
|
17
|
+
|
18
|
+
Gemspec/OrderedDependencies:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
RSpec/NestedGroups:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
RSpec/MultipleExpectations:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
RSpec/NamedSubject:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
RSpec/ContextWording:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
RSpec/LeadingSubject:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
RSpec/MessageChain:
|
37
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Changelog
|
data/Gemfile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
+
|
6
|
+
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
7
|
+
|
8
|
+
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
|
9
|
+
%w[solidusio/solidus solidusio/solidus_frontend]
|
10
|
+
else
|
11
|
+
%w[solidusio/solidus] * 2
|
12
|
+
end
|
13
|
+
|
14
|
+
gem 'solidus', github: solidus_git, branch: branch
|
15
|
+
gem 'solidus_api', github: solidus_git, branch: branch
|
16
|
+
gem 'solidus_backend', github: solidus_git, branch: branch
|
17
|
+
gem 'solidus_core', github: solidus_git, branch: branch
|
18
|
+
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
|
19
|
+
gem 'solidus_sample', github: solidus_git, branch: branch
|
20
|
+
|
21
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
22
|
+
# otherwise it takes forever to resolve them.
|
23
|
+
# See https://github.com/bundler/bundler/issues/6677
|
24
|
+
gem 'rails', ENV.fetch('RAILS_VERSION', nil)
|
25
|
+
|
26
|
+
# Provides basic authentication functionality for testing parts of your engine
|
27
|
+
gem 'solidus_auth_devise'
|
28
|
+
|
29
|
+
case ENV.fetch('DB', nil)
|
30
|
+
when 'mysql'
|
31
|
+
gem 'mysql2'
|
32
|
+
when 'postgresql'
|
33
|
+
gem 'pg'
|
34
|
+
else
|
35
|
+
gem 'sqlite3'
|
36
|
+
end
|
37
|
+
|
38
|
+
group :test do
|
39
|
+
gem 'rails-controller-testing'
|
40
|
+
gem 'rspec-activemodel-mocks'
|
41
|
+
end
|
42
|
+
|
43
|
+
group :development, :test do
|
44
|
+
gem 'factory_bot', '> 4.10.0'
|
45
|
+
gem 'pry-rails'
|
46
|
+
end
|
47
|
+
|
48
|
+
gemspec
|
49
|
+
|
50
|
+
# Use a local Gemfile to include development dependencies that might not be
|
51
|
+
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
|
52
|
+
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2022 [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Solidus nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# Solidus Pagy
|
2
|
+
|
3
|
+
[![CircleCI](https://circleci.com/gh/jtapia/solidus_pagy.svg?style=shield)](https://circleci.com/gh/jtapia/solidus_pagy)
|
4
|
+
[![codecov](https://codecov.io/gh/jtapia/solidus_pagy/branch/master/graph/badge.svg)](https://codecov.io/gh/jtapia/solidus_pagy)
|
5
|
+
|
6
|
+
Add [Pagy](https://github.com/ddnexus/pagy) pagination ability to use on the Solidus Admin content.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add `solidus_pagy` to your Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'solidus_pagy', github: 'jtapia/solidus_pagy'
|
14
|
+
```
|
15
|
+
|
16
|
+
Bundle your dependencies and run the installation generator:
|
17
|
+
|
18
|
+
```shell
|
19
|
+
bin/rails generate solidus_pagy:install
|
20
|
+
```
|
21
|
+
|
22
|
+
## Solidus configuration
|
23
|
+
|
24
|
+
After the installation, inside the file `app/cofig/initializers/solidus_pagy` you will be able to setup the `Pagy` pagination options:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
28
|
+
# | Option | Helper | Path |
|
29
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
30
|
+
# | default | pagy_nav | |
|
31
|
+
# | bootstrap | pagy_bootstrap_nav | pagy/extras/bootstrap |
|
32
|
+
# | bulma | pagy_bulma_nav | pagy/extras/bulma |
|
33
|
+
# | foundation | pagy_foundation_nav | pagy/extras/foundation |
|
34
|
+
# | materialize| pagy_materialize_nav | pagy/extras/materialize |
|
35
|
+
# | semantic | pagy_semantic_nav | pagy/extras/semantic |
|
36
|
+
# | uikit | pagy_uikit_nav | pagy/extras/uikit |
|
37
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
38
|
+
|
39
|
+
SolidusPagy.configure do |config|
|
40
|
+
config.nav_helper = 'pagy_nav' # default
|
41
|
+
config.page = 1 # default
|
42
|
+
config.items = 20 # default
|
43
|
+
config.outset = 0 # default
|
44
|
+
config.orders_per_page = 15 # default
|
45
|
+
config.promotions_per_page = 15 # default
|
46
|
+
config.properties_per_page = 15 # default
|
47
|
+
config.admin_products_per_page = 10 # default
|
48
|
+
config.admin_variants_per_page = 20 # defaults
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
If you want to use `bootstrap` you need to require the path:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
require 'pagy/extras/bootstrap'
|
56
|
+
|
57
|
+
SolidusPagy.configure do |config|
|
58
|
+
config.nav_helper = 'pagy_bootstrap_nav'
|
59
|
+
...
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
## Usage
|
64
|
+
|
65
|
+
Include in your `application_controller.rb`:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
include Pagy::Backend
|
69
|
+
```
|
70
|
+
|
71
|
+
and in your `application_helper.rb`:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
include Pagy::Frontend
|
75
|
+
```
|
76
|
+
|
77
|
+
## Development
|
78
|
+
|
79
|
+
### Testing the extension
|
80
|
+
|
81
|
+
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
|
82
|
+
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
|
83
|
+
`bin/rake extension:test_app`.
|
84
|
+
|
85
|
+
```shell
|
86
|
+
bin/rake
|
87
|
+
```
|
88
|
+
|
89
|
+
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
|
90
|
+
|
91
|
+
```shell
|
92
|
+
bundle exec rubocop
|
93
|
+
```
|
94
|
+
|
95
|
+
When testing your application's integration with this extension you may use its factories.
|
96
|
+
Simply add this require statement to your `spec/spec_helper.rb`:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
require 'solidus_pagy/testing_support/factories'
|
100
|
+
```
|
101
|
+
|
102
|
+
Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
|
103
|
+
factories along with this extension's factories using this statement:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusPagy::Engine)
|
107
|
+
```
|
108
|
+
|
109
|
+
### Running the sandbox
|
110
|
+
|
111
|
+
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
112
|
+
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
|
113
|
+
`sandbox/bin/rails`.
|
114
|
+
|
115
|
+
Here's an example:
|
116
|
+
|
117
|
+
```
|
118
|
+
$ bin/rails server
|
119
|
+
=> Booting Puma
|
120
|
+
=> Rails 6.0.2.1 application starting in development
|
121
|
+
* Listening on tcp://127.0.0.1:3000
|
122
|
+
Use Ctrl-C to stop
|
123
|
+
```
|
124
|
+
|
125
|
+
### Updating the changelog
|
126
|
+
|
127
|
+
Before and after releases the changelog should be updated to reflect the up-to-date status of
|
128
|
+
the project:
|
129
|
+
|
130
|
+
```shell
|
131
|
+
bin/rake changelog
|
132
|
+
git add CHANGELOG.md
|
133
|
+
git commit -m "Update the changelog"
|
134
|
+
```
|
135
|
+
|
136
|
+
### Releasing new versions
|
137
|
+
|
138
|
+
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
|
139
|
+
|
140
|
+
## License
|
141
|
+
|
142
|
+
Copyright (c) 2022 [name of extension author], released under the New BSD License.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'pagy'
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module OrdersControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
def index
|
9
|
+
params[:q] ||= {}
|
10
|
+
params[:q][:completed_at_not_null] ||= '1' if ::Spree::Config[:show_only_complete_orders_by_default]
|
11
|
+
@show_only_completed = params[:q][:completed_at_not_null] == '1'
|
12
|
+
params[:q][:s] ||= @show_only_completed ? 'completed_at desc' : 'created_at desc'
|
13
|
+
params[:q][:completed_at_not_null] = '' unless @show_only_completed
|
14
|
+
|
15
|
+
# As date params are deleted if @show_only_completed, store
|
16
|
+
# the original date so we can restore them into the params
|
17
|
+
# after the search
|
18
|
+
created_at_gt = params[:q][:created_at_gt]
|
19
|
+
created_at_lt = params[:q][:created_at_lt]
|
20
|
+
|
21
|
+
params[:q].delete(:inventory_units_shipment_id_null) if params[:q][:inventory_units_shipment_id_null] == "0"
|
22
|
+
|
23
|
+
if params[:q][:created_at_gt].present?
|
24
|
+
params[:q][:created_at_gt] = begin
|
25
|
+
Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day
|
26
|
+
rescue StandardError
|
27
|
+
''
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if params[:q][:created_at_lt].present?
|
32
|
+
params[:q][:created_at_lt] = begin
|
33
|
+
Time.zone.parse(params[:q][:created_at_lt]).end_of_day
|
34
|
+
rescue StandardError
|
35
|
+
''
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if @show_only_completed
|
40
|
+
params[:q][:completed_at_gt] = params[:q].delete(:created_at_gt)
|
41
|
+
params[:q][:completed_at_lt] = params[:q].delete(:created_at_lt)
|
42
|
+
end
|
43
|
+
|
44
|
+
@search = ::Spree::Order.accessible_by(current_ability, :index).ransack(params[:q])
|
45
|
+
@result = pagy(
|
46
|
+
@search.result.includes([:user]),
|
47
|
+
page: params[:page],
|
48
|
+
items: params[:per_page] || ::SolidusPagy.config.orders_per_page
|
49
|
+
)
|
50
|
+
@pagy = @result.first
|
51
|
+
@orders = @result.second
|
52
|
+
|
53
|
+
# Restore dates
|
54
|
+
params[:q][:created_at_gt] = created_at_gt
|
55
|
+
params[:q][:created_at_lt] = created_at_lt
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
::Spree::Admin::OrdersController.prepend(self)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module PricesControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
def index
|
9
|
+
params[:q] ||= {}
|
10
|
+
|
11
|
+
@search = @product.prices
|
12
|
+
.accessible_by(current_ability, :index)
|
13
|
+
.ransack(params[:q])
|
14
|
+
master_prices_search_result(@search)
|
15
|
+
variant_prices_search_result(@search)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def master_prices_search_result(search)
|
21
|
+
@result = pagy(
|
22
|
+
search.result
|
23
|
+
.currently_valid
|
24
|
+
.for_master
|
25
|
+
.order(:variant_id, :country_iso, :currency),
|
26
|
+
page: params[:page],
|
27
|
+
items: Spree::Config.admin_variants_per_page
|
28
|
+
)
|
29
|
+
@pagy_master_prices = @result.first
|
30
|
+
@master_prices = @result.second
|
31
|
+
end
|
32
|
+
|
33
|
+
def variant_prices_search_result(search)
|
34
|
+
@result = pagy(
|
35
|
+
search.result
|
36
|
+
.currently_valid
|
37
|
+
.for_variant
|
38
|
+
.order(:variant_id, :country_iso, :currency),
|
39
|
+
page: params[:variants_page],
|
40
|
+
items: Spree::Config.admin_variants_per_page
|
41
|
+
)
|
42
|
+
@pagy_variant_prices = @result.first
|
43
|
+
@variant_prices = @result.second
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
::Spree::Admin::PricesController.prepend(self)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module ProductsControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def collection
|
11
|
+
return @collection if @collection
|
12
|
+
|
13
|
+
params[:q] ||= {}
|
14
|
+
params[:q][:s] ||= 'name asc'
|
15
|
+
# @search needs to be defined as this is passed to search_form_for
|
16
|
+
@search = super.ransack(params[:q])
|
17
|
+
@result = pagy(
|
18
|
+
@search.result.order(id: :asc)
|
19
|
+
.includes(product_includes),
|
20
|
+
page: params[:page],
|
21
|
+
items: ::SolidusPagy.config.admin_products_per_page
|
22
|
+
)
|
23
|
+
@pagy = @result.first
|
24
|
+
@collection = @result.second
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
::Spree::Admin::ProductsController.prepend(self)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module PromotionCodesControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
def index
|
9
|
+
@promotion = ::Spree::Promotion.accessible_by(current_ability, :show)
|
10
|
+
.find(params[:promotion_id])
|
11
|
+
@promotion_codes = @promotion.promotion_codes.order(:value)
|
12
|
+
|
13
|
+
respond_to do |format|
|
14
|
+
format.html do
|
15
|
+
@result = pagy(
|
16
|
+
@promotion_codes,
|
17
|
+
page: params[:page],
|
18
|
+
items: 50
|
19
|
+
)
|
20
|
+
@pagy = @result.first
|
21
|
+
@promotion_codes = @result.second
|
22
|
+
end
|
23
|
+
|
24
|
+
format.csv do
|
25
|
+
filename = "promotion-code-list-#{@promotion.id}.csv"
|
26
|
+
headers["Content-Type"] = "text/csv"
|
27
|
+
headers["Content-disposition"] = "attachment; filename=\"#{filename}\""
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
::Spree::Admin::PromotionCodesController.prepend(self)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module PromotionsControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def collection
|
11
|
+
return @collection if @collection
|
12
|
+
|
13
|
+
params[:q] ||= HashWithIndifferentAccess.new
|
14
|
+
params[:q][:s] ||= 'id desc'
|
15
|
+
|
16
|
+
@collection = super
|
17
|
+
@search = @collection.ransack(params[:q])
|
18
|
+
@result = pagy(
|
19
|
+
@search.result(distinct: true).includes(promotion_includes),
|
20
|
+
page: params[:page],
|
21
|
+
items: params[:per_page] || ::SolidusPagy.config.promotions_per_page
|
22
|
+
)
|
23
|
+
@pagy = @result.first
|
24
|
+
@collection = @result.second
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
::Spree::Admin::PromotionsController.prepend(self)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPagy
|
4
|
+
module Admin
|
5
|
+
module PropertiesControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
private
|
9
|
+
|
10
|
+
def collection
|
11
|
+
return @collection if @collection
|
12
|
+
|
13
|
+
# params[:q] can be blank upon pagination
|
14
|
+
params[:q] = {} if params[:q].blank?
|
15
|
+
|
16
|
+
@collection = super
|
17
|
+
@search = @collection.ransack(params[:q])
|
18
|
+
@result = pagy(
|
19
|
+
@search.result,
|
20
|
+
page: params[:page],
|
21
|
+
items: ::SolidusPagy.config.properties_per_page
|
22
|
+
)
|
23
|
+
@pagy = @result.first
|
24
|
+
@collection = @result.second
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
::Spree::Admin::PropertiesController.prepend(self)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|