Skip to content

[Grid view] Display product as a grid#14345

Open
rioug wants to merge 34 commits into
openfoodfoundation:masterfrom
rioug:14000-grid-view
Open

[Grid view] Display product as a grid#14345
rioug wants to merge 34 commits into
openfoodfoundation:masterfrom
rioug:14000-grid-view

Conversation

@rioug

@rioug rioug commented May 28, 2026

Copy link
Copy Markdown
Collaborator

⚠️ use clockify code Roadmap 2026: #84 - Grid view when working on this ⚠️

What? Why?

First step of Grid view, this PR show a basic grid view limited to one page and 10 products max. There are now variant information for now. This PR also include some refactor around tooltip, it makes the TooltipComponent available to the frontend.

What should we test?

Make sure to enable the product_grid_view feature

With a shop with one order cycle open:

  • Load the shop page
    -> products should be displayed as a grid
gird_desktop
  • Click on image/text
    -> product overlay should display product information
  • Hover over product or enterprise property
    -> Tool tip shows
desktop-overlay

With a shop with multiple order cycle open:

  • Load the shop page and choose an order cycle
    -> products should be displayed as a grid
  • Change the selected order cycle
    -> product list should update and products should be displayed as a grid

Try with different grid size, mobile examples :

grid_mobile mobile_overlay

Tooltip

This PR includes some changes around tooltip :

  • check they are still displaying as expected in the backoffice (enterprise edit page is a good place to check).

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

rioug added 2 commits May 22, 2026 16:35
It makes product grid view feature flag available to angularJS
@github-project-automation github-project-automation Bot moved this to All the things 💤 in OFN Delivery board May 28, 2026
@rioug rioug added the feature toggled These pull requests' changes are invisible by default and are grouped in release notes label May 28, 2026
@rioug rioug moved this from All the things 💤 to In Progress ⚙ in OFN Delivery board May 28, 2026
@rioug

rioug commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

@mariocarabotta For the product overlay, I reused the template from the product preview in the backoffice, so it's slightly different. The main difference is the close button instead of the X in the corner we have currently.
Current overlay:
current_overlay

@rioug rioug marked this pull request as ready for review May 28, 2026 06:07
@rioug rioug force-pushed the 14000-grid-view branch from 5be52c1 to 6c101f0 Compare May 28, 2026 06:08
@rioug rioug moved this from In Progress ⚙ to Code review 🔎 in OFN Delivery board May 28, 2026
rioug added 14 commits May 28, 2026 16:09
It renders a mostly empty turbo-frame for now. It's going to be used to
wire the product grid view to the frontend
We don't need to load the product, as they will be displayed via the
ProductsController. This is a bit hacky and we might still need to load
products, time will tell.
The turbo-frame will load data automatically, and it will refresh when
the order cycle is changed. It nicely leverage turbo-frame so we don't
have to load data via "manually" adding AJAX request.
Which incidentally makes the spec better, we can now remove the use of
`__send__`
We reuse the ProductsRenderer to keep the same loading logic. For
experimentation purposes, we only load one page with 10 products.
I have tried leveraging modern CSS/Sass
It re uses the template created for the product preview, which is now in
its own partial.
- Make it a bit rounded
- Start at the start of the parent element, so it doesn't disappear when
  parent element next to the modal border. shift() middleware doesn't
  seem to work as expected
I am not exactly sure how to test that product don't load when the
feature is enabled, but I don't want to waste time trying to figure it
out.
@mariocarabotta

mariocarabotta commented May 28, 2026

Copy link
Copy Markdown
Collaborator

@mariocarabotta For the product overlay, I reused the template from the product preview in the backoffice, so it's slightly different. The main difference is the close button instead of the X in the corner we have currently. Current overlay: current_overlay

got it! I will review better when it comes through to testing, for now it sounds good. I didn't realise you would have had to rebuild the overlay too. @chahmedejaz is also touching that part of the code for the multiple images carousel. Is that going to be an issue?

@chahmedejaz

Copy link
Copy Markdown
Collaborator

I think we may have a bit of conflict, @mariocarabotta but it shouldn't be that serious. So we should be able to handle it. 👍🏻

@mkllnk mkllnk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice commit history. And it seems to be a good entry point to choose the product rendering layout on order cycle select. Just one question about caching below.

Comment thread app/helpers/injection_helper.rb Outdated
Comment thread app/views/shop/products/_form.html.haml Outdated
@@ -1,5 +1,5 @@
- # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml
= cache_with_locale do
= cache_with_locale(current_order_cycle&.id) do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to cache by feature toggle as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should, now that I think about it a bit more I am not sure the order cycle is needed but I'll double check that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the cache key and made it feature aware, see: 24f3fbe

Comment thread spec/requests/products_spec.rb Outdated
Comment thread app/webpacker/controllers/product_grid_view_controller.js

@dacook dacook left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for your responses!

Comment thread app/webpacker/css/darkswarm/product-grid.scss Outdated
@dacook dacook moved this from Code review 🔎 to Test Ready 🧪 in OFN Delivery board Jun 2, 2026
@dacook dacook changed the title [Grid view] Diplay product as a grid [Grid view] Display product as a grid Jun 2, 2026
@mariocarabotta mariocarabotta added the pr-staged-au staging.openfoodnetwork.org.au label Jun 2, 2026
@mariocarabotta

mariocarabotta commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

thanks, this is looking great already, very exciting!!

some notes, feel free to pick up only what you think is reasonable for now, and we might address some of it later:

  • the grid lines are a bit of a problem when there are empty tiles. I thought this was going to be easy with the grid layout, but after doing a bit of research it seems like there is no straightforward solution to that. I'd say let's keep them for now, but we'l likely have to remove them at some point, and maybe work with more white spacing instead. Let's add more elements to the tiles in here and then we'll decide
Screenshot 2026-06-03 at 9 15 16

edit: adding this as a possible option to address this issue. Haven't looked into it too much but it seems to work with last row having fewer items

  • is it possible to grab the alt text of the image (set in the admin) and use it in the thumbnail?
  • if possible, it would be great to still have 2 tiles up until 360px screen size. we can also postpone this once we have more fields in the tile, grid layouts get a bit fiddly at times
Screenshot 2026-06-03 at 9 32 36
  • in the product details overlay, I am not sure what the product properties are supposed to do when hovering/clicking. this is also not working in production either. if there's nothing they should do, then let's remove the link tag

@mariocarabotta mariocarabotta removed the pr-staged-au staging.openfoodnetwork.org.au label Jun 3, 2026
It allows 2 tiles till 360px wide.
@rioug rioug moved this from Test Ready 🧪 to Code review 🔎 in OFN Delivery board Jun 3, 2026
@rioug rioug requested review from dacook and mkllnk June 3, 2026 05:22
@rioug rioug force-pushed the 14000-grid-view branch from ba568de to ae3651c Compare June 3, 2026 05:38

@dacook dacook left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change requested as there's an unnecessary html attribute.

%a{"data-tooltip-target": "element", href: @link, class: @link_class}
= @link_text
- if @no_link_element
%span{"data-tooltip-target": "element", href: @link, class: @link_class}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not a link, then href isn't needed here and could be removed.

In fact, instead of adding a new parameter no_link_element, why not just branch if @link.present?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch !
There are many places where the tooltip doesn't have a link ie :

= render AdminTooltipComponent.new(text: t('.owner_tip'), link_text: %[<i class="fa fa-question-circle"></i>].html_safe, link: nil)

We could probably review that but I think that's out of scope of this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's other tooltips that have an <a href="">? That seems like the same case that you are implementing here, so think it would be better to clean up now and unify with the existing tooltips instead of adding a parameter and code branch for a new case.

Or if we don't clean up the old ones, can this new tooltip work with the existing <a href=""> form?

Sorry to be a pain but I think it's worth avoiding too many switches on a component, because we end up with lots of different usages and more room for bugs to hide, or visual inconsistencies.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, this PR makes the tooltip component available on the frontend. That's great, and in that case it would be a great opportunity to also remove "admin" from the name, which would make it nice and succinct.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to not got there, but I guess that was inevitable once I had to actually make change to the component. Anyway, it's fixed now. it starts here : ab3e1ac

@github-project-automation github-project-automation Bot moved this from Code review 🔎 to In Progress ⚙ in OFN Delivery board Jun 3, 2026
@rioug rioug requested a review from dacook June 5, 2026 01:37
@rioug rioug moved this from In Progress ⚙ to Code review 🔎 in OFN Delivery board Jun 5, 2026
rioug added 5 commits June 14, 2026 10:47
Do not use a link tag if no link provided
Replace old angular tooltip by the new stimulus based one.
And fix the styling for product preview
Update all "What's this ?" by the new component on the admin enterprise
form.
@rioug rioug force-pushed the 14000-grid-view branch from 405d7cf to b070c3a Compare June 14, 2026 00:48

@dacook dacook left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for continuing the clean up, looks like a good end result! 👍

@dacook dacook moved this from Code review 🔎 to Test Ready 🧪 in OFN Delivery board Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature toggled These pull requests' changes are invisible by default and are grouped in release notes

Projects

Status: Test Ready 🧪

Development

Successfully merging this pull request may close these issues.

As a shopper I want to see products in shops as a grid

5 participants