From c4b7b76e6481aa6f003443637ce72fd6e7df0339 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 4 Apr 2024 16:06:03 +1100 Subject: [PATCH] Avoid pagination when editing errored products --- app/views/admin/products_v3/_content.html.haml | 2 +- app/views/admin/products_v3/_filters.html.haml | 4 ++-- app/views/admin/products_v3/_sort.html.haml | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/views/admin/products_v3/_content.html.haml b/app/views/admin/products_v3/_content.html.haml index b9a5625e84..64e6620ef9 100644 --- a/app/views/admin/products_v3/_content.html.haml +++ b/app/views/admin/products_v3/_content.html.haml @@ -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 diff --git a/app/views/admin/products_v3/_filters.html.haml b/app/views/admin/products_v3/_filters.html.haml index ec13f12c90..30a95abc08 100644 --- a/app/views/admin/products_v3/_filters.html.haml +++ b/app/views/admin/products_v3/_filters.html.haml @@ -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 diff --git a/app/views/admin/products_v3/_sort.html.haml b/app/views/admin/products_v3/_sort.html.haml index 848710fe58..8bd5b249bc 100644 --- a/app/views/admin/products_v3/_sort.html.haml +++ b/app/views/admin/products_v3/_sort.html.haml @@ -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": [] }'}