human-essentials icon indicating copy to clipboard operation
human-essentials copied to clipboard

Distribution export -- item columns are no longer in alphbetical order. Fix it.

Open cielf opened this issue 1 year ago • 5 comments

Summary

The items columns in the distribution export should be in lower-case alphabetical order.

Why?

Findability and stability.

Details

To recreate, sign in as [email protected]. Choose Distributions, then click "Export Distributions". If you look at the entire set of columns for the items, you will see that some of them are not in alphabetical order (they're probably in added-to-the-database order).
The columns relating to items should be in lower-case alphabetical order.

Criteria for completion

  • [ ] Item-related Columns are in lower-case alphabetical order in the distribution export
  • [ ] automated tests to confirm this.

cielf avatar Aug 11 '24 15:08 cielf

I'd like to give this issue a try if no one has taken it yet.

auliafaizahr avatar Aug 14 '24 12:08 auliafaizahr

It's yours!

cielf avatar Aug 14 '24 13:08 cielf

so I just found that the item columns are not in alphabetical order since it shows in index page it was ordered by 'issued_at'

https://github.com/rubyforgood/human-essentials/blob/d648cb3fad29456633a927226bd1f0453e4e405c/app/controllers/distributions_controller.rb#L44C4-L48C75

@distributions = current_organization
                     .distributions
                     .includes(:partner, :storage_location, line_items: [:item])
                     .order('issued_at DESC')
                     .apply_filters(filter_params, helpers.selected_range)

image

my question is, should we also order the items by partner name alphabetically on the index page, or should we keep the current ordering by 'issued_at' there, and only apply alphabetical ordering for the CSV export?

Looking forward to your thoughts! Thank you!

auliafaizahr avatar Aug 15 '24 10:08 auliafaizahr

The rows in the distribution index are sorted by issued at, in reverse chronological order, and that's correct.

We want to reorder the columns for the items in the export, not the rows. I.e., the columns which correspond to items should appear in lower case alphabetical from left to right.

Hope that helps!

cielf avatar Aug 15 '24 11:08 cielf

Oh, I got it, so it need to reorder columns for the items like Adult Briefs (Medium/Large), Adult Briefs (Small/Medium), Adult Briefs (XXL), Adult Briefs (XXXL), Adult Briefs (XS/Small) etc alphabetically from left to right, sorry for the misunderstanding earlier 😅 I'll try my best on resolving this accordingly, thank you for your patience!

auliafaizahr avatar Aug 15 '24 12:08 auliafaizahr