effective_bootstrap 1.23.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/app/helpers/effective_bootstrap_helper.rb +8 -3
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f683af3488f235baae5f7eee5f403ade629da5b32763d0ab4c9c80f02cdf6112
|
|
4
|
+
data.tar.gz: 9750a978f0fac5b8f4992fd7cf8393092f3eee6dbf36c8e12d24157ca955696f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52baeedf313df51b034f5f250ea1fbe637cd81525808473ec4cb515dff29f5545a28a44da823b2f6f1f0555fa9180bcee0064fc5bbd31d10981a5519eefa4bdf
|
|
7
|
+
data.tar.gz: bc935d0336edc537416f74e2d9361d1373c1d346fd69b4f2ba00e1ade6504605a66d41b5a1a9eae91fa8c3867af50b00fd11519efd972dcc536b51381293ec0d
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Effective Bootstrap
|
|
2
2
|
|
|
3
|
-
Everything your Ruby on Rails
|
|
3
|
+
Everything your Ruby on Rails 7.0+ application needs to get working with [Twitter Bootstrap 4](https://getbootstrap.com/).
|
|
4
4
|
|
|
5
5
|
- Bootstrap4 component view helpers.
|
|
6
6
|
- SVG icons based on [Inline SVG](https://github.com/jamesmartin/inline_svg), with [Feather Icons](https://feathericons.com) and [FontAwesome](https://fontawesome.com) svg icons to replace the old glyphicons.
|
|
@@ -124,6 +124,8 @@ Builds a pagination based on the given collection, current url and params[:page]
|
|
|
124
124
|
|
|
125
125
|
The collection must be an ActiveRecord relation.
|
|
126
126
|
|
|
127
|
+
Requests for an invalid page or a page beyond the collection raise `ActiveRecord::RecordNotFound` and return HTTP 404.
|
|
128
|
+
|
|
127
129
|
```haml
|
|
128
130
|
= paginate(@posts, per_page: 10)
|
|
129
131
|
```
|
|
@@ -132,8 +134,8 @@ Add this to your model:
|
|
|
132
134
|
|
|
133
135
|
```ruby
|
|
134
136
|
scope :paginate, -> (page: nil, per_page:) {
|
|
135
|
-
page = (page || 1
|
|
136
|
-
offset =
|
|
137
|
+
page = EffectiveResources.normalize_page(page) || 1
|
|
138
|
+
offset = (page - 1) * per_page
|
|
137
139
|
|
|
138
140
|
limit(per_page).offset(offset)
|
|
139
141
|
}
|
|
@@ -623,7 +625,7 @@ class Select2AjaxController < ApplicationController
|
|
|
623
625
|
|
|
624
626
|
# Paginate
|
|
625
627
|
per_page = 20
|
|
626
|
-
page = (params[:page] || 1
|
|
628
|
+
page = EffectiveResources.normalize_page(params[:page]) || 1
|
|
627
629
|
last = (collection.reselect(:id).count.to_f / per_page).ceil
|
|
628
630
|
more = page < last
|
|
629
631
|
|
|
@@ -492,13 +492,14 @@ module EffectiveBootstrapHelper
|
|
|
492
492
|
#
|
|
493
493
|
# https://getbootstrap.com/docs/4.0/components/pagination/
|
|
494
494
|
# Builds a pagination based on the given collection, current url and params[:page]
|
|
495
|
+
# Raises ActiveRecord::RecordNotFound when the requested page is invalid or exceeds the collection.
|
|
495
496
|
#
|
|
496
497
|
# = paginate(@posts, per_page: 10)
|
|
497
498
|
#
|
|
498
499
|
# Add this to your model
|
|
499
500
|
# scope :paginate, -> (page: nil, per_page: 10) {
|
|
500
|
-
# page = (page || 1
|
|
501
|
-
# offset =
|
|
501
|
+
# page = EffectiveResources.normalize_page(page) || 1
|
|
502
|
+
# offset = (page - 1) * per_page
|
|
502
503
|
|
|
503
504
|
# limit(per_page).offset(offset)
|
|
504
505
|
# }
|
|
@@ -514,7 +515,11 @@ module EffectiveBootstrapHelper
|
|
|
514
515
|
|
|
515
516
|
collection_count ||= collection.limit(nil).offset(nil).count # You can pass the total count, or not.
|
|
516
517
|
|
|
517
|
-
page = (
|
|
518
|
+
page = EffectiveResources.validate_page!(
|
|
519
|
+
params[:page],
|
|
520
|
+
collection_count: collection_count,
|
|
521
|
+
per_page: per_page
|
|
522
|
+
)
|
|
518
523
|
last = (collection_count.to_f / per_page).ceil
|
|
519
524
|
|
|
520
525
|
return unless (last > 1 || render_single_page) # If there's only 1 page, don't render a pagination at all.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: effective_bootstrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.24.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Code and Effect
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 7.0.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 7.0.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: bootstrap
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|