Module: Katalyst::Tables::Collection::Pagination

Extended by:
ActiveSupport::Concern
Included in:
Base, Filter
Defined in:
app/models/concerns/katalyst/tables/collection/pagination.rb

Overview

Adds pagination support for a collection.

Pagination will be applied if the collection is configured to paginate by either specifying ‘config.paginate = true` or passing `paginate: true` to the initializer.

If the value given to ‘paginate` is a hash, it will be passed to the `pagy` gem as options.

If ‘page` is present in params it will be passed to pagy.

Defined Under Namespace

Classes: Paginate

Instance Method Summary collapse

Instance Method Details

#initialize(paginate: self.class.config.paginate) ⇒ Object



25
26
27
28
29
# File 'app/models/concerns/katalyst/tables/collection/pagination.rb', line 25

def initialize(paginate: self.class.config.paginate, **)
  super(**)

  @paginate = paginate.freeze
end

#paginate?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/concerns/katalyst/tables/collection/pagination.rb', line 31

def paginate?
  !!@paginate
end

#paginate_optionsObject



35
36
37
38
39
40
41
42
43
44
# File 'app/models/concerns/katalyst/tables/collection/pagination.rb', line 35

def paginate_options
  opts = @paginate.is_a?(Hash) ? @paginate : {}
  opts = opts.dup

  if PagyNavComponent.pagy_pre_8?
    opts[:anchor_string] ||= "data-turbo-action=\"replace\""
  end

  opts
end