openfoodfoundation / openfoodnetwork

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

[BUU] Change the order of products in my catalogue by name #11058

Closed mariocarabotta closed 5 days ago

mariocarabotta commented 11 months ago

Context

This issue introduces the ability to change the order of the products by Name (A>Z to Z>A).

Description

- As an: enterprise user - On page: /admin/products - I want to be able to: reorder my products - So that: I can see the ones at the end of the list

Acceptance Criteria & Tests

Scenario 1: Trigger reorder Given that I am in /admin/products And I have products in the list When I click on the Name column header Then the list reloads And I see a loading indicator

Scenario 2: List reordered Given that I have triggered reordering of the list When the list is reloaded successfully Then I see the updated list

Scenario 3: Colour notes for text links Currently the table header uses $dark-blue (Sherpa-blue), but it's probably better to reserve blue colors just for interactive links and elements. With that in mind:

Design specs

Figma screens are available here > https://www.figma.com/file/v1zbrWDZSRd3Nqoe0SJ2Sm/Engineering-Delivery---Back-Office?type=design&node-id=470%3A5244&mode=design&t=lfLRiAUQwuEU9fNX-1

New components and styles

Component Example
Link with icon Screenshot 2023-07-27 at 16 08 17
mariocarabotta commented 9 months ago

assigned to David for now since he's working on some other elements of the table that relate to this issue

mariocarabotta commented 9 months ago

at the moment the list is displayed Z>A, should be the opposite way around

dacook commented 2 months ago

Estimate

0.5 days

dacook commented 1 week ago

We are now using the "search" Stimulus controller (search_controller.js) which has already been built to help manage column sorting. This helps maintain the other filters (search, producer, category) when reloading the sorted data. It was developed by Matt-Yorkley for the admin/orders page, you can check it out there to see how it works. On that page it doesn't use Turbo, but on the Products page I've set it up to use a Turbo Frame for nice reloading. (FYI I configured the frame targeting the whole page by default, but the form submits with Turbo due to this setting: <form data-turbo-frame="_self")

So I suggest looking at the orders page and trying to copy that: https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/views/spree/admin/orders/_table.html.haml#L10-L22 For this issue, we only need to implement for the Name column, so there's no need for the loop.

chahmedejaz commented 1 week ago

Thanks David, I'd used that controller and it was so nice. It's almost the replica of the order page, however the product 's page uses Turbo and Orders page does not. When I use the sort for the first time after page reloading, it works just fine. But when I try again without reloading, it gives the error of Disconnected Form or something. I'll share more after working on this error. :)

chahmedejaz commented 1 week ago

Update:

chahmedejaz commented 1 week ago

The PR is ready for review now. Thanks