eivo-rails-api 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/eivo/concerns/pagination.rb +21 -11
- data/eivo-rails-api.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8362e17aaf35365ac1f318195f53ead6c07f67ae136f5d8330043582f293c5d
|
4
|
+
data.tar.gz: 15334f702a62f2f1ca0b8bb44ed28c0b20b74d87e6ef66139564f498abfdd0e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0941d7283903837f7e051039167872bd3c3ce9f118cd25883556155798373db0d53777ef6efc21d7d71d50635f9224de10d35358060caea7f834a3ff8c6b1a
|
7
|
+
data.tar.gz: 8396499cf5728012a59f3c9c4be2afbc53ff2b80250114c0663594230ff47a4376b95b6201fb32b49185cb35c78545ae7c87866139b2c0498b01fe12b02c1099
|
@@ -5,7 +5,7 @@ module EIVO
|
|
5
5
|
module Pagination
|
6
6
|
extend ::ActiveSupport::Concern
|
7
7
|
|
8
|
-
def paginate(collection)
|
8
|
+
def paginate(collection, options = {})
|
9
9
|
unless ::ActiveModel::Type::Boolean.new.cast(params[:pagination]) == false
|
10
10
|
limit = 50
|
11
11
|
if params[:limit]
|
@@ -22,22 +22,32 @@ module EIVO
|
|
22
22
|
def pagination_options(collection)
|
23
23
|
options = {
|
24
24
|
is_collection: true,
|
25
|
-
meta: {
|
26
|
-
total: collection.total_count,
|
27
|
-
pages: collection.total_pages
|
28
|
-
},
|
29
25
|
links: {
|
30
26
|
self: url_for(params.to_unsafe_h.merge(page: collection.current_page)),
|
31
27
|
first: url_for(params.to_unsafe_h.merge(page: 1)),
|
32
|
-
last: url_for(params.to_unsafe_h.merge(page: collection.total_pages))
|
33
28
|
}
|
34
29
|
}
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
31
|
+
# avoid count request on large table
|
32
|
+
if params[:pagination] == 'infinite'
|
33
|
+
options[:links][:next] = url_for(params.to_unsafe_h.merge(page: collection.current_page + 1))
|
34
|
+
|
35
|
+
if !collection.first_page?
|
36
|
+
options[:links][:prev] = url_for(params.to_unsafe_h.merge(page: collection.current_page - 1))
|
37
|
+
end
|
38
|
+
else
|
39
|
+
options[:links][:last] = url_for(params.to_unsafe_h.merge(page: collection.total_pages))
|
40
|
+
options[:meta] = {
|
41
|
+
total: collection.total_count,
|
42
|
+
pages: collection.total_pages
|
43
|
+
}
|
44
|
+
|
45
|
+
if !collection.out_of_range? && !collection.last_page?
|
46
|
+
options[:links][:next] = url_for(params.to_unsafe_h.merge(page: collection.next_page))
|
47
|
+
end
|
48
|
+
if !collection.out_of_range? && !collection.first_page?
|
49
|
+
options[:links][:prev] = url_for(params.to_unsafe_h.merge(page: collection.prev_page))
|
50
|
+
end
|
41
51
|
end
|
42
52
|
|
43
53
|
options
|
data/eivo-rails-api.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eivo-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan VUKOVICH-TRIBOUHARET
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -218,7 +218,7 @@ homepage: https://www.eivo.co
|
|
218
218
|
licenses:
|
219
219
|
- MIT
|
220
220
|
metadata: {}
|
221
|
-
post_install_message:
|
221
|
+
post_install_message:
|
222
222
|
rdoc_options: []
|
223
223
|
require_paths:
|
224
224
|
- lib
|
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
version: '0'
|
235
235
|
requirements: []
|
236
236
|
rubygems_version: 3.1.2
|
237
|
-
signing_key:
|
237
|
+
signing_key:
|
238
238
|
specification_version: 4
|
239
239
|
summary: EIVO Rails API
|
240
240
|
test_files: []
|