Module: MaquinaComponents::PaginationHelper
- Defined in:
- app/helpers/maquina_components/pagination_helper.rb
Overview
Pagination Helper
Provides convenient methods for creating pagination components with Pagy integration.
Instance Method Summary collapse
-
#paginated_path(route_helper, pagy, page, extra_params = {}) ⇒ String
Build paginated path with page param.
-
#pagination_nav(pagy, route_helper, params: {}, turbo: {action: :replace}, show_labels: true, css_classes: "", **html_options) ⇒ String
Renders a complete pagination navigation from a Pagy object.
-
#pagination_simple(pagy, route_helper, params: {}, turbo: {action: :replace}, css_classes: "", **html_options) ⇒ String
Simpler pagination with just Previous/Next (no page numbers).
Instance Method Details
#paginated_path(route_helper, pagy, page, extra_params = {}) ⇒ String
Build paginated path with page param
78 79 80 81 82 83 84 |
# File 'app/helpers/maquina_components/pagination_helper.rb', line 78 def paginated_path(route_helper, pagy, page, extra_params = {}) page_param = pagy.vars[:page_param] || Pagy::DEFAULT[:page_param] query_params = request.query_parameters.except(page_param.to_s).merge(extra_params) query_params[page_param] = page send(route_helper, query_params) end |
#pagination_nav(pagy, route_helper, params: {}, turbo: {action: :replace}, show_labels: true, css_classes: "", **html_options) ⇒ String
Renders a complete pagination navigation from a Pagy object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/maquina_components/pagination_helper.rb', line 37 def pagination_nav(pagy, route_helper, params: {}, turbo: {action: :replace}, show_labels: true, css_classes: "", **) return if pagy.pages <= 1 render "components/pagination", css_classes: css_classes, ** do render "components/pagination/content" do safe_join([ pagination_previous_item(pagy, route_helper, params, turbo, show_labels), pagination_page_items(pagy, route_helper, params, turbo), pagination_next_item(pagy, route_helper, params, turbo, show_labels) ]) end end end |
#pagination_simple(pagy, route_helper, params: {}, turbo: {action: :replace}, css_classes: "", **html_options) ⇒ String
Simpler pagination with just Previous/Next (no page numbers)
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/helpers/maquina_components/pagination_helper.rb', line 58 def pagination_simple(pagy, route_helper, params: {}, turbo: {action: :replace}, css_classes: "", **) return if pagy.pages <= 1 render "components/pagination", css_classes: css_classes, ** do render "components/pagination/content" do safe_join([ pagination_previous_item(pagy, route_helper, params, turbo, true), pagination_next_item(pagy, route_helper, params, turbo, true) ]) end end end |