Replace will_paginate's view helpers with a custom prev/next + page dropdown control. Layout: [← Prev] [Page <select> of N] [Next →] - Prev/Next are regular links (work without JS) - Dropdown wrapped in <auto-submit-form> for JS-enhanced navigation - "Go" submit button appears when JS is disabled - Single pagination bar at top of results (removed bottom duplicate) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
33 lines
1.2 KiB
Text
33 lines
1.2 KiB
Text
- # Local variables:
|
|
- # - collection: The WillPaginate collection (e.g., @search_results)
|
|
- # - url_params: The URL params hash (e.g., @outfit.wardrobe_params.merge(q: params[:q]))
|
|
|
|
- if collection.total_pages > 1
|
|
.pagination-bar
|
|
- if collection.previous_page
|
|
= link_to "← Prev", url_params.merge(page: collection.previous_page), class: "pagination-prev"
|
|
- else
|
|
%span.pagination-prev.disabled ← Prev
|
|
|
|
%auto-submit-form
|
|
= form_with url: @wardrobe_path, method: :get do |f|
|
|
- url_params.each do |key, value|
|
|
- if value.is_a?(Array)
|
|
- value.each do |v|
|
|
= hidden_field_tag "#{key}[]", v, id: nil
|
|
- else
|
|
= hidden_field_tag key, value, id: nil
|
|
|
|
%label.pagination-page-selector
|
|
Page
|
|
= select_tag :page,
|
|
options_for_select((1..collection.total_pages).map { |p| [p, p] }, collection.current_page),
|
|
"aria-label": "Page number"
|
|
of #{collection.total_pages}
|
|
|
|
= submit_tag "Go", name: nil, class: "progressive-submit"
|
|
|
|
- if collection.next_page
|
|
= link_to "Next →", url_params.merge(page: collection.next_page), class: "pagination-next"
|
|
- else
|
|
%span.pagination-next.disabled Next →
|