Avoid pagination when editing errored products

This commit is contained in:
David Cook
2024-04-04 16:06:03 +11:00
committed by Filipe
parent fd8be37a62
commit c4b7b76e64
3 changed files with 10 additions and 7 deletions

View File

@@ -12,7 +12,7 @@
.sixteen.columns
= render partial: 'sort', locals: { pagy: pagy, search_term: search_term, producer_id: producer_id, category_id: category_id }
= render partial: 'table', locals: { products: products }
- if pagy.pages > 1
- if pagy.present? && pagy.pages > 1
= render partial: 'admin/shared/stimulus_pagination', locals: { pagy: pagy }
- else
#no-products

View File

@@ -1,6 +1,6 @@
= form_with url: admin_products_path, id: "filters", method: :get, data: { remote: false, "search-target": "form" } do
= hidden_field_tag :page, @page, class: "page"
= hidden_field_tag :per_page, @per_page, class: "per-page"
= hidden_field_tag :page, nil, class: "page"
= hidden_field_tag :per_page, nil, class: "per-page"
.query
.search-input

View File

@@ -1,12 +1,15 @@
#sort
%div
= t(".pagination.total_html", total: pagy.count, from: pagy.from, to: pagy.to)
- if pagy.present?
= t(".pagination.total_html", total: pagy.count, from: pagy.from, to: pagy.to)
- if search_term.present? || producer_id.present? || category_id.present?
%a{ href: url_for(per_page: @per_page, page: @page), class: "button disruptive" }
= t(".pagination.clear_search")
%a{ href: url_for(page: 1), class: "button disruptive" }
= t(".pagination.clear_search")
%form.with-dropdown
= t(".pagination.per_page.show")
= select_tag :per_page,
options_for_select([15, 25, 50, 100].collect{|i| [t('.pagination.per_page.per_page', num: i), i]}, pagy.items),
options_for_select([15, 25, 50, 100].collect{|i| [t('.pagination.per_page.per_page', num: i), i]}, pagy&.items),
class: "no-input per-page",
data: { controller: "tom-select search", action: "change->search#changePerPage", "tom-select-options-value": '{ "plugins": [] }'}