rubyforgood / human-essentials

Human Essentials is an inventory management system for diaper, incontinence, and period-supply banks. It supports them in distributing to partners, tracking inventory, and reporting stats and analytics.
https://humanessentials.app
MIT License
436 stars 449 forks source link

4219 Fixed Order of items in inventory adjustment #4380

Open iamronakgupta opened 1 month ago

iamronakgupta commented 1 month ago

Resolves #4219

iamronakgupta commented 1 month ago

I believe the appropriate place to make the change for the order of items for the inventory adjustments is the adjustments controller, not the storage location controller.

There is code there that appears to be alphabetizing the items -- but I believe it is not alphabetizing them by item name, so it ends up being in the order they were added.

Please also provide tests for your changes.

@cielf Thank you for the review.

After checking from logs, I find out that when we changes storage location from drop down, there is an ajax call happens GET /storage_locations/3/inventory.json?include_omitted_items=true which calls inventory action from storage_locations_controller and that's where items changes their order. So I think the issue is in storage_locations_controller and specifically in inventory action. Whats your thought?

iamronakgupta commented 1 month ago

Reference

@dorner yes I am working on this.

Just to confirm, I am working on storage_location_requests_spec here

Am I working at right place?

cielf commented 1 month ago

@iamronakgupta I fear that you are "barking up the wrong tree" -- working to solve the problem in the wrong place.

For clarity, here is the result when I manually tested it just now. You can see that the items dropdown in the Inventory Adjustments screen is not showing the items in alphabetical order.

Screenshot 2024-05-25 at 8 41 22 AM

The changes you have made so far would affect a different screen -- the storage locations view.

iamronakgupta commented 1 month ago

@iamronakgupta I fear that you are "barking up the wrong tree" -- working to solve the problem in the wrong place.

For clarity, here is the result when I manually tested it just now. You can see that the items dropdown in the Inventory Adjustments screen is not showing the items in alphabetical order.

Screenshot 2024-05-25 at 8 41 22 AM

The changes you have made so far would affect a different screen -- the storage locations view.

@cielf I think this is working because order and sort_by method puts words with lowercase at the bottom and uppercase at top

cielf commented 1 month ago

Yup. Looks like that is what it is doing, And it's what it was doing.

IMO, it should be a case insensitive sort because humans sort case insensitively - but that would currently make it inconsistent with the rest of the system.

iamronakgupta commented 1 month ago

Yup. Looks like that is what it is doing, And it's what it was doing.

IMO, it should be a case insensitive sort because humans sort case insensitively - but that would currently make it inconsistent with the rest of the system.

@cielf So, how should I implement it? with case sensitive or insensitive?

cielf commented 1 month ago

With case sensitive. We'd want to make all the sorts case insensitive at the same time.