Module: EasyAdmin::PagyHelper

Includes:
Pagy::Frontend
Defined in:
app/helpers/easy_admin/pagy_helper.rb

Instance Method Summary collapse

Instance Method Details

#pagy_info(pagy, **vars) ⇒ Object

iOS-style pagination info



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/easy_admin/pagy_helper.rb', line 11

def pagy_info(pagy, **vars)
  return '' if pagy.count == 0
  
  from, to, count = pagy.from, pagy.to, pagy.count
  
  if count == 1
    "Showing 1 result"
  elsif from == to
    "Showing result #{from} of #{count}"
  else
    "Showing #{from} to #{to} of #{count} results"
  end
end

#pagy_info_compact(pagy, **vars) ⇒ Object

Compact pagination info for mobile



26
27
28
# File 'app/helpers/easy_admin/pagy_helper.rb', line 26

def pagy_info_compact(pagy, **vars)
  "#{pagy.page} of #{pagy.pages}"
end

#pagy_nav(pagy, pagy_id: nil, link_extra: '', **vars) ⇒ Object

Override Pagy’s default nav method to use our custom component



6
7
8
# File 'app/helpers/easy_admin/pagy_helper.rb', line 6

def pagy_nav(pagy, pagy_id: nil, link_extra: '', **vars)
  EasyAdmin::PaginationComponent.new(pagy: pagy).call.html_safe
end