Bug 38712 - Order My Lists options alphabetically
Summary: Order My Lists options alphabetically
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Chloe Zermatten
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-16 13:02 UTC by Chloe Zermatten
Modified: 2025-01-29 14:26 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the display of the lists menu on the OPAC header - public and private lists (when logged in) are now listed in alphabetical order, instead of the date created.
Version(s) released in:
Circulation function:


Attachments
Bug 38712: order My Lists options alphabetically (2.28 KB, patch)
2024-12-16 13:19 UTC, Chloe Zermatten
Details | Diff | Splinter Review
Bug 38712: Order public and private lists alphabetically (2.45 KB, patch)
2024-12-16 23:59 UTC, David Nind
Details | Diff | Splinter Review
Bug 38712: order My Lists options alphabetically (2.49 KB, patch)
2024-12-17 08:55 UTC, Chloe Zermatten
Details | Diff | Splinter Review
Bug 38712: order My Lists options alphabetically (3.48 KB, patch)
2024-12-18 11:12 UTC, Chloe Zermatten
Details | Diff | Splinter Review
Bug 38712: order My Lists options alphabetically (3.19 KB, patch)
2024-12-18 11:26 UTC, Chloe Zermatten
Details | Diff | Splinter Review
Bug 38712: order My Lists options alphabetically (3.24 KB, patch)
2024-12-18 21:22 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Chloe Zermatten 2024-12-16 13:02:06 UTC
In the top header navigation menu on the Koha OPAC, sets the order of the 'My Lists' dropdown to be sorted alphabetically instead of by modification date.
Comment 1 Chloe Zermatten 2024-12-16 13:19:45 UTC Comment hidden (obsolete)
Comment 2 David Cook 2024-12-16 23:09:01 UTC
Probably a sensible thing to do.
Comment 3 David Nind 2024-12-16 23:59:03 UTC
Created attachment 175583 [details] [review]
Bug 38712: Order public and private lists alphabetically

In the OPAC top header navigation menu, public and private lists
are ordered by the date created, instead of alphabetically.

Test plan:
1. On the Koha OPAC, login and navigate to Your account > Lists
   (/cgi-bin/koha/opac-shelves.pl).
2. Create a few public and private lists.
3. Open the lists dropdown in the top navigation menu.
4. Notice that the lists appear in the order they were created.
5. Apply the patch.
6. Refresh the page and open the lists dropdown in the top
   navigation.
7. Notice that the lists are now sorted alphabetically.
8. Log out and notice that the lists are now sorted
   alphabetically.
Comment 4 David Nind 2024-12-17 00:03:10 UTC
Hi Chloe.

This is a good idea - as it matches how the lists are ordered under Your account > Lists.

I amended the patch commit message and was going to sign off.

However, I noted that if you log out, you get an error and the OPAC is unusable:

  Can't use an undefined value as a HASH reference at /kohadevbox/koha/Koha/
  Virtualshelves.pm line 200
  ....

So I've changed the status to Failed QA.

David Nind
Comment 5 Chloe Zermatten 2024-12-17 08:55:12 UTC
Created attachment 175596 [details] [review]
Bug 38712: order My Lists options alphabetically

In the top header navigation menu, sets the order of the 'My Lists' dropdown to be alphabetical.

Note: this patch was updated to also handle cases where $params->{search_attributes} is not defined.

Test plan:

- on the Koha OPAC, navigate to /cgi-bin/koha/opac-shelves.pl
- create a few public and private lists
- open the 'My List' dropdown in the top navigation menu
- notice that the lists appear in the order they were created

- apply the patch

- open the 'My List' dropdown in the top navigation
- notice that the lists are now sorted alphabetically

fix: handle undefined search attributes
Comment 6 Chloe Zermatten 2024-12-17 09:00:16 UTC
Hello David,

Thank you for the feedback! I have amended the patch accordingly - hopefully this should take care of the issue
Comment 7 David Nind 2024-12-17 19:53:29 UTC
(In reply to Chloe Zermatten from comment #6)
> Hello David,
> 
> Thank you for the feedback! I have amended the patch accordingly - hopefully
> this should take care of the issue

Thanks Chloe!

I've retested, and that fixes the error.

However, if you are logged out, the public lists aren't sorted alphabetically 8-(...

David
Comment 8 Chloe Zermatten 2024-12-18 11:12:37 UTC
Created attachment 175643 [details] [review]
Bug 38712: order My Lists options alphabetically

In the top header navigation menu, sets the order of the 'My Lists' dropdown to be alphabetical.

Note: this patch was updated to also handle cases where $params->{search_attributes} is not defined,
and also to ensure that it also applies to the list of public lists show to users who are not logged in.

Test plan:

- on the Koha OPAC, navigate to /cgi-bin/koha/opac-shelves.pl
- create a few public and private lists
- open the 'My List' dropdown in the top navigation menu
- notice that the lists appear in the order they were created

- apply the patch

- open the 'My List' dropdown in the top navigation
- notice that the lists are now sorted alphabetically
Comment 9 Chloe Zermatten 2024-12-18 11:26:06 UTC
Created attachment 175646 [details] [review]
Bug 38712: order My Lists options alphabetically

In the top header navigation menu, sets the order of the 'My Lists' dropdown to be alphabetical.

Note: this patch was updated to also handle cases where $params->{search_attributes} is not defined,
and well as ordering public lists when the user is not logged in.

Test plan:

- on the Koha OPAC, navigate to /cgi-bin/koha/opac-shelves.pl
- create a few public and private lists
- open the 'My List' dropdown in the top navigation menu
- notice that the lists appear in the order they were created

- apply the patch

- open the 'My List' dropdown in the top navigation
- notice that the lists are now sorted alphabetically

fix: handle undefined search attributes

order list when logged out
Comment 10 David Nind 2024-12-18 21:22:31 UTC
Created attachment 175681 [details] [review]
Bug 38712: order My Lists options alphabetically

In the top header navigation menu, sets the order of the 'My Lists' dropdown to be alphabetical.

Note: this patch was updated to also handle cases where $params->{search_attributes} is not defined,
and well as ordering public lists when the user is not logged in.

Test plan:

- on the Koha OPAC, navigate to /cgi-bin/koha/opac-shelves.pl
- create a few public and private lists
- open the 'My List' dropdown in the top navigation menu
- notice that the lists appear in the order they were created

- apply the patch

- open the 'My List' dropdown in the top navigation
- notice that the lists are now sorted alphabetically

fix: handle undefined search attributes

order list when logged out

Signed-off-by: David Nind <david@davidnind.com>
Comment 11 David Nind 2024-12-18 21:28:29 UTC
Thanks Chloe!

I've added a release note, and changed this to a normal bug, instead of an enhancement.

I would suggest formatting the commit message using the commit message guidelines https://wiki.koha-community.org/wiki/Commit_messages, for example:
- Sentence case for the bug title
- Number the test plan steps
(See comment# 3 for how I previously updated the commit message.)

Good luck with the QA step!

David
Comment 12 Emily Lamancusa (emlam) 2024-12-19 20:01:14 UTC
Thanks for submitting the bug report and patch, Chloe!

For changes to .pm files, we also require unit tests (see https://wiki.koha-community.org/wiki/Coding_Guidelines#PERL17:_Unit_tests_are_required and https://wiki.koha-community.org/wiki/Unit_Tests).

It seems odd to me to make a sorting change in pm files instead of at the script or templating level, so you might want to look into that possibility (if you haven't already) before investing time on unit tests. I'm afraid I'm not familiar enough with My Lists or these parts of the code to comment on that with any certainty, though.
Comment 13 Chloe Zermatten 2024-12-20 10:30:39 UTC
Hi Emily and David, 

Thank you both for the feedback! I will be on leave over the holiday period, so I will pick this back up once I get back.