effective_bootstrap 1.23.0 → 1.25.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8525fb430647548ed163f61aacb3d1a5a582cbb6e5bf7182d2c69374cd4e5082
4
- data.tar.gz: b5ba63ca4c4162696b289599106c8476ac3d1eceb557eff451b707ac4b9aa608
3
+ metadata.gz: 7572ab1d47d1e96b9821418d4d2718f381157f03811e697226e2ebd0d7c3c02e
4
+ data.tar.gz: 81e074f7747ce04274991347bc47217c8dff89ff833332ee4b38c7eb08eed1c6
5
5
  SHA512:
6
- metadata.gz: 9763f0b4a0e4a728d9601dcd9872fcd4ff921b7e6f55f31387a6a5be1c5fa2a0b6aac561c9b0d6203d83667455232804acb49342576cb1068e767d6c026ea598
7
- data.tar.gz: 3dbec9987fc1bfaba4130ad9b4668cd5e1f462d0fd12ee5307d2a7dd4c2d45bf4ea4ee6faa9c21089fffb800428b52b526f6511b780ee3dff8ec4acb8050c9fc
6
+ metadata.gz: 8ea6f0ab85c69dbf20c420241b28f9620beacbdf78476185ca3b199a51a61167cd8f699cae1daccb32d9781171bbc451cb603dca00da408adae2d181c8406ea5
7
+ data.tar.gz: 7f26421b025f8a150c7ab016059729a52dff4fa3a25a19d366dbe53d0a98b662260cfbed638ca7e722d52b3b21d6fa7e4be6681dcc64351b862580497784cd6b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Effective Bootstrap
2
2
 
3
- Everything your Ruby on Rails 5.1+ application needs to get working with [Twitter Bootstrap 4](https://getbootstrap.com/).
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).to_i
136
- offset = [(page - 1), 0].max * per_page
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).to_i
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
 
@@ -17,7 +17,7 @@ this.EffectiveBootstrap ||= new class
17
17
  $element.addClass('initialized')
18
18
 
19
19
  $ -> EffectiveBootstrap.initialize()
20
- $(document).on 'turbolinks:load', -> EffectiveBootstrap.initialize()
20
+ $(document).on 'turbolinks:load turbo:load', -> EffectiveBootstrap.initialize()
21
21
  $(document).on 'cocoon:after-insert', -> EffectiveBootstrap.initialize()
22
22
  $(document).on 'effective-bootstrap:initialize', (event) -> EffectiveBootstrap.initialize(event.currentTarget)
23
23
 
@@ -15,4 +15,5 @@ initialize = ->
15
15
  $buttons.addClass('initialized')
16
16
 
17
17
  $ -> initialize()
18
- $(document).on 'turbolinks:load', -> initialize()
18
+ $(document).on 'turbolinks:load turbo:load', -> initialize()
19
+ $(document).on 'turbolinks:before-cache turbo:before-cache', -> $('.btn-clipboard-copy.initialized').removeClass('initialized')
@@ -1,5 +1,5 @@
1
1
  //= require ../moment/moment
2
2
  //= require ../effective_datetime/bootstrap-datetimepicker
3
3
  //= require ../effective_datetime/overrides
4
- //= require ../effective_datetime/turbolinks
4
+ //= require ../effective_datetime/navigation
5
5
  //= require ./initialize
@@ -1,5 +1,5 @@
1
1
  //= require ../moment/moment
2
2
  //= require ./bootstrap-datetimepicker
3
3
  //= require ./overrides
4
- //= require ./turbolinks
4
+ //= require ./navigation
5
5
  //= require ./initialize
@@ -1,4 +1,4 @@
1
- $(document).on 'turbolinks:before-cache', ->
1
+ $(document).on 'turbolinks:before-cache turbo:before-cache', ->
2
2
  $('input.initialized.effective_date_time_picker').each (i, element) ->
3
3
  $input = $(element)
4
4
  $input.datetimepicker('destroy') if $input.data('datetimepicker')
@@ -62,7 +62,7 @@ effectiveMatch = (params, data) ->
62
62
  $select.data('select2').$container.addClass(options['containerClass']) if options['containerClass']
63
63
  $select.data('select2').$dropdown.addClass(options['dropdownClass']) if options['dropdownClass']
64
64
 
65
- $(document).on 'turbolinks:before-cache', ->
65
+ $(document).on 'turbolinks:before-cache turbo:before-cache', ->
66
66
  $('select.effective_select.initialized').each (i, element) ->
67
67
  $input = $(element)
68
68
  $input.select2('destroy') if $input.data('select2')
@@ -1,5 +1,5 @@
1
1
  //= require ../moment/moment
2
2
  //= require ../effective_datetime/bootstrap-datetimepicker
3
3
  //= require ../effective_datetime/overrides
4
- //= require ../effective_datetime/turbolinks
4
+ //= require ../effective_datetime/navigation
5
5
  //= require ./initialize
@@ -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).to_i
501
- # offset = [(page - 1), 0].max * per_page
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 = (params[:page] || 1).to_i
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.
@@ -19,6 +19,7 @@ module EffectiveFormBuilderHelper
19
19
  end
20
20
 
21
21
  options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this)')
22
+ options[:html]['data-turbo'] = false
22
23
  options[:local] = true unless options.key?(:local)
23
24
 
24
25
  if respond_to?(:inline_datatable?) && inline_datatable?
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '1.23.0'.freeze
2
+ VERSION = '1.25.0'.freeze
3
3
  end
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.23.0
4
+ version: 1.25.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: 4.0.0
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: 4.0.0
25
+ version: 7.0.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bootstrap
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -459,8 +459,8 @@ files:
459
459
  - app/assets/javascripts/effective_datetime/bootstrap-datetimepicker.js
460
460
  - app/assets/javascripts/effective_datetime/initialize.js.coffee
461
461
  - app/assets/javascripts/effective_datetime/input.js
462
+ - app/assets/javascripts/effective_datetime/navigation.js.coffee
462
463
  - app/assets/javascripts/effective_datetime/overrides.js.coffee
463
- - app/assets/javascripts/effective_datetime/turbolinks.js.coffee
464
464
  - app/assets/javascripts/effective_editor/image-drop-and-paste.js
465
465
  - app/assets/javascripts/effective_editor/image-resize.js
466
466
  - app/assets/javascripts/effective_editor/initialize.js.coffee