Add "no results found" container

This commit is contained in:
Jean-Baptiste Bellet
2023-07-05 11:50:13 +02:00
parent 5a8a187f54
commit c378ad1d88
4 changed files with 22 additions and 6 deletions

View File

@@ -14,9 +14,4 @@
= render partial: 'admin/shared/v3/pagy', locals: { pagy: pagy, reflex: "click->Products#fetch" }
- else
#no-products
= t('.no_products_found')
#no-products-actions
%a{ href: "/admin/products/new", class: "button icon-plus", icon: "icon-plus" }
= t(:new_product)
%a{ href: "/admin/products/import", class: "button icon-upload secondary", icon: "icon-upload" }
= t(".import_products")
= render partial: "no_products", locals: { search_term: search_term, producer_id: producer_id, category_id: category_id }

View File

@@ -0,0 +1,11 @@
- if search_term.present? || producer_id.present? || category_id.present?
= t('.no_products_found_for_search')
%a{ href: "#", class: "button disruptive", data: { reflex: "click->products#clear_search" } }
= t("admin.products_v3.sort.pagination.clear_search")
- else
= t('.no_products_found')
#no-products-actions
%a{ href: "/admin/products/new", class: "button icon-plus", icon: "icon-plus" }
= t(:new_product)
%a{ href: "/admin/products/import", class: "button icon-upload secondary", icon: "icon-upload" }
= t(".import_products")

View File

@@ -784,8 +784,10 @@ en:
label: Categories
search: Search
content:
no_products:
no_products_found: No products found
import_products: Import multiple products
no_products_found_for_search: No products found for your search criteria
product_import:
title: Product Import
file_not_found: File not found or could not be opened

View File

@@ -131,6 +131,14 @@ describe 'As an admin, I can see the new product page' do
expect_products_count_to_be 15
end
end
context "no results" do
it "shows a message when there are no results" do
search_for "no results"
expect(page).to have_content "No products found for your search criteria"
expect(page).to have_link "Clear search"
end
end
end
def expect_page_to_be(page)