Module: BetterUi::General::Components::Pagination::PaginationHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/better_ui/general/components/pagination/pagination_helper.rb

Instance Method Summary collapse

Instance Method Details

#bui_pagination(current_page:, total_pages:, path:, theme: :default, size: :medium, window: 2, show_info: false, per_page: nil, classes: '', form: nil, **options) ⇒ String

Genera un componente di navigazione paginata per liste e tabelle

Examples:

Uso base standalone

<%= bui_pagination(current_page: 3, total_pages: 10, path: '/products') %>

Con tema e dimensione personalizzati

<%= bui_pagination(
  current_page: 5, 
  total_pages: 20, 
  path: '/articles',
  theme: :blue,
  size: :large
) %>

Con informazioni sui risultati

<%= bui_pagination(
  current_page: 2,
  total_pages: 8,
  path: '/users',
  show_info: true,
  per_page: 25,
  theme: :green
) %>

Con finestra di pagine personalizzata

<%= bui_pagination(
  current_page: 10,
  total_pages: 50,
  path: '/orders',
  window: 3,
  size: :small
) %>

Con attributi HTML aggiuntivi

<%= bui_pagination(
  current_page: 1,
  total_pages: 5,
  path: '/dashboard',
  classes: 'my-4',
  data: { turbo_frame: 'content' }
) %>

Parameters:

  • current_page (Integer)

    La pagina corrente (1-indexed)

  • total_pages (Integer)

    Il numero totale di pagine

  • path (String)

    L’URL base per costruire i link di paginazione

  • theme (Symbol) (defaults to: :default)

    Il tema del componente (:default, :blue, :red, :green, :yellow, :violet, :orange, :rose, :white)

  • size (Symbol) (defaults to: :medium)

    La dimensione del componente (:small, :medium, :large)

  • window (Integer) (defaults to: 2)

    Il numero di pagine da mostrare intorno alla pagina corrente (default: 2)

  • show_info (Boolean) (defaults to: false)

    Se mostrare le informazioni sui risultati (default: false)

  • per_page (Integer) (defaults to: nil)

    Il numero di elementi per pagina (richiesto se show_info è true)

  • classes (String) (defaults to: '')

    Classi CSS aggiuntive

  • form (FormBuilder, nil) (defaults to: nil)

    Form builder per l’integrazione con Rails form (opzionale)

  • options (Hash)

    Attributi HTML aggiuntivi

Returns:

  • (String)

    Il markup HTML del componente pagination



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/helpers/better_ui/general/components/pagination/pagination_helper.rb', line 62

def bui_pagination(current_page:, total_pages:, path:, theme: :default, size: :medium,
                   window: 2, show_info: false, per_page: nil, classes: '', 
                   form: nil, **options)
  render BetterUi::General::Pagination::Component.new(
    current_page: current_page,
    total_pages: total_pages,
    path: path,
    theme: theme,
    size: size,
    window: window,
    show_info: show_info,
    per_page: per_page,
    classes: classes,
    **options
  )
end