openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.12k stars 724 forks source link

Back Office Product List - Hide search field and filters when there are no products in list #12957

Open sigmundpetersen opened 3 weeks ago

sigmundpetersen commented 3 weeks ago

When a new person signs up and goes to the admin for the first time, they likely won't have any product.

We want them to really focus on creating new ones or importing them. at the moment in the list we still show the section with search and filters, which is not relevant to people. Let's hide it when there are no products.

Image

saunmanoj888 commented 1 week ago

hii @sigmundpetersen I'd love to work on this issue as a way to ease back into open source after a break. Could you please assign it to me?

sigmundpetersen commented 1 week ago

Sure, thanks @saunmanoj888 👍

saunmanoj888 commented 1 week ago

hii @sigmundpetersen

I have started working on above issue. I have one small query. When there are a list of product available and user searches for a product which is not available, we show the message No product found, in such scenario we still want to keep the search and filters right? The current behaviour is as follow Screenshot 2024-11-17 003932

If we want to achieve above I was thinking of below solution

When user visits product page for the first time, no product is present, search_term is empty, cateogory_id is also nil, we will hide the search and filters section

When products are present, user searches for some product which is not available, search_term is present, cateogory might be selected, @products object will be empty since searched product is not there, we will still show the search and filters section

the condition that i can use in html.haml file is

 - if products.any? || search_term.present? || cateogory_id.present?
  // show  search and filters section

please let me know your thought on above

sigmundpetersen commented 1 week ago

Let's hear from our @openfoodfoundation/core-devs , @RachL , @filipefurtad0 :)

chahmedejaz commented 1 week ago

When there are a list of product available and user searches for a product which is not available, we show the message No product found, in such scenario we still want to keep the search and filters right?

Thanks, @saunmanoj888 for bringing this case. Let's keep it in this scenario; it would make sense. Thanks.

the condition that i can use in html.haml file is

  • if products.any? || search_term.present? || cateogory_id.present? // show search and filters section

I think it would be fine. Thanks.