Bug 29922 - Group of libraries are now displayed in alphabetical order
Summary: Group of libraries are now displayed in alphabetical order
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: The Minh Luong
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-21 13:48 UTC by The Minh Luong
Modified: 2023-12-28 20:42 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the display of library groups in the advanced search (Groups of libraries) for the OPAC and staff interface so that they correctly sort in alphabetical order. Before this: - OPAC: were sorted in the order library groups were added, group names with diacritics and umlauts (such as Ä or À) came last (after something starting with Z) - Staff interface: were sorted correctly, but had the same issue as the OPAC for group names with diacritics and umlauts
Version(s) released in:
22.11.00, 22.05.05, 21.11.12
Circulation function:


Attachments
cam13844 - Groups of libraries displayed in alphabetical order (884 bytes, text/plain)
2022-01-21 14:31 UTC, The Minh Luong
Details
Bug 29922 - Group of libraries are now displayed in alphabetical order (1.57 KB, text/plain)
2022-01-21 14:43 UTC, The Minh Luong
Details
Bug 29922: Group of libraries are now displayed in alphabetical order (1.56 KB, patch)
2022-01-24 20:41 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 29922: Group of libraries are now displayed in alphabetical order (1.61 KB, patch)
2022-01-24 20:47 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 29922: Group of libraries are now displayed in alphabetical order (1.64 KB, patch)
2022-02-17 19:00 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 29922: Group of libraries are now displayed in alphabetical order (1.64 KB, patch)
2022-03-03 17:53 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29922: Sorting works for accents (1.64 KB, patch)
2022-03-07 16:40 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 29922: Make get_search_groups return results sorted by title (1.41 KB, patch)
2022-06-27 15:32 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 29922: Make get_search_groups return results sorted by title (1.46 KB, patch)
2022-07-02 22:34 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 29922: (follow-up) Remove extra sort (723 bytes, patch)
2022-07-04 13:21 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 29922: (follow-up) Remove extra sort (771 bytes, patch)
2022-07-04 13:24 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 29922: Make get_search_groups return results sorted by title (1.51 KB, patch)
2022-07-07 15:19 UTC, David Nind
Details | Diff | Splinter Review
Bug 29922: (follow-up) Remove extra sort (820 bytes, patch)
2022-07-07 15:19 UTC, David Nind
Details | Diff | Splinter Review
Bug 29922: Make get_search_groups return results sorted by title (1.57 KB, patch)
2022-07-08 11:23 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 29922: (follow-up) Remove extra sort (878 bytes, patch)
2022-07-08 11:23 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description The Minh Luong 2022-01-21 13:48:53 UTC
This patch modifies the OPAC's "Group of libraries" field in Advanced search tab. When the select button under the text "Groups of libraries" is clicked, the library groups are now displayed in alphabetical orders. 

To test, start by creating multiple libraries (At least 5). Then, create library groups (At least 5) in non-alphabetical order. (Make sure "Use for OPAC search groups" is checked when creating a library group).

- Example: CGroup,DGroup,AGroup,EGroup,BGroup (These are the Titles)

From there, follow these steps:

1 - Go in OPAC, then Advanced search, then 

2 - Under "Groups of librairies" , click the select button.

3 - Notice that the library groups are not in alphabetical order.

4 - Apply the patch.

5 - Notice that the library groups are in alphabetical order.
Comment 1 The Minh Luong 2022-01-21 14:31:50 UTC
Created attachment 129698 [details]
cam13844 - Groups of libraries displayed in alphabetical order

OPAC's "Groups of libraries field" is now displayed in alphabetical order.
Comment 2 The Minh Luong 2022-01-21 14:43:46 UTC
Created attachment 129699 [details]
Bug 29922 - Group of libraries are now displayed in alphabetical order

This patch modifies the OPAC's "Group of libraries" field in Advanced search tab. When the select button under the text "Groups of libraries" is clicked, the library groups are now displayed in alphabetical orders.

To test, start by creating multiple libraries (At least 5). Then, create library groups (At least 5) in non-alphabetical order. (Make sure "Use for OPAC search groups" is checked when creating a library group).

- Example: CGroup,DGroup,AGroup,EGroup,BGroup (These are the Titles)

From there, follow these steps:

1 - Go in OPAC, then Advanced search, then

2 - Under "Groups of librairies" , click the select button.

3 - Notice that the library groups are not in alphabetical order.

4 - Apply the patch.

5 - Notice that the library groups are in alphabetical order.
Comment 3 Lucas Gass (lukeg) 2022-01-24 18:56:20 UTC
Everything here works perfect and now is consistent with the behavior on the staff client. Awesome! The only problem now is in the commit message which must start as:

Bug 29922:

You can see the QA tool says:

Commit title does not start with 'Bug XXXXX: ' - b9e3fec7c3


Can that be fixed please?
Comment 4 The Minh Luong 2022-01-24 20:41:30 UTC
Created attachment 129737 [details] [review]
Bug 29922: Group of libraries are now displayed in alphabetical order

This patch modifies the OPAC's "Group of libraries" field in Advanced search tab. When the select button under the text "Groups of libraries" is clicked, the library groups are now displayed in alphabetical orders.

To test, start by creating multiple libraries (At least 5). Then, create library groups (At least 5) in non-alphabetical order. (Make sure "Use for OPAC search groups" is checked when creating a library group).

- Example: CGroup,DGroup,AGroup,EGroup,BGroup (These are the Titles)

From there, follow these steps:

1 - Go in OPAC, then Advanced search.

2 - Under "Groups of librairies" , click the select button.

3 - Notice that the library groups are not in alphabetical order.

4 - Apply the patch.

5 - Notice that the library groups are in alphabetical order.
Comment 5 Lucas Gass (lukeg) 2022-01-24 20:47:27 UTC
Created attachment 129738 [details] [review]
Bug 29922: Group of libraries are now displayed in alphabetical order

This patch modifies the OPAC's "Group of libraries" field in Advanced search tab. When the select button under the text "Groups of libraries" is clicked, the library groups are now displayed in alphabetical orders.

To test, start by creating multiple libraries (At least 5). Then, create library groups (At least 5) in non-alphabetical order. (Make sure "Use for OPAC search groups" is checked when creating a library group).

- Example: CGroup,DGroup,AGroup,EGroup,BGroup (These are the Titles)

From there, follow these steps:

1 - Go in OPAC, then Advanced search.

2 - Under "Groups of librairies" , click the select button.

3 - Notice that the library groups are not in alphabetical order.

4 - Apply the patch.

5 - Notice that the library groups are in alphabetical order.

https://bugs.koha-community.org/show_bug.cgi?id=29922

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 6 Jonathan Druart 2022-02-01 15:20:06 UTC
Please have a look at https://wiki.koha-community.org/wiki/Commit_messages
Comment 7 The Minh Luong 2022-02-17 19:00:54 UTC
Created attachment 130767 [details] [review]
Bug 29922: Group of libraries are now displayed in alphabetical order

This patch modifies the OPAC's "Group of libraries" field in Advanced search tab. When the select button under the text "Groups of libraries" is clicked, the library groups are now displayed in alphabetical orders.

To test, start by creating multiple libraries (At least 5). Then, create library groups (At least 5) in non-alphabetical order. (Make sure "Use for OPAC search groups" is checked when creating a library group).
- Example: CGroup,DGroup,AGroup,EGroup,BGroup (These are the Titles)
From there, follow these steps:
1 - Go in OPAC, then Advanced search.
2 - Under "Groups of librairies" , click the select button.
3 - Notice that the library groups are not in alphabetical order.
4 - Apply the patch.
5 - Notice that the library groups are in alphabetical order.

https://bugs.koha-community.org/show_bug.cgi?id=29922

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 Owen Leonard 2022-03-03 17:53:09 UTC
Created attachment 131343 [details] [review]
Bug 29922: Group of libraries are now displayed in alphabetical order

This patch modifies the OPAC's "Group of libraries" field in Advanced
search tab. When the select button under the text "Groups of libraries"
is clicked, the library groups are now displayed in alphabetical
orders.

To test, start by creating multiple libraries (At least 5). Then,
create library groups (At least 5) in non-alphabetical order. (Make
 sure "Use for OPAC search groups" is checked when creating a library
group).
- Example: CGroup,DGroup,AGroup,EGroup,BGroup (These are the Titles)

From there, follow these steps:
1 - Go in OPAC, then Advanced search.
2 - Under "Groups of librairies" , click the select button.
3 - Notice that the library groups are not in alphabetical order.
4 - Apply the patch.
5 - Notice that the library groups are in alphabetical order.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 9 Katrin Fischer 2022-03-06 13:17:15 UTC
This doesn't work quite right for diacritics and umlauts.

Ä or À will always sort to the bottom (after something starting with Z). Google suggests that this can be fixed by use locale - but I have to admit I am not sure where you'd add that and about the consequences. As this might also be an issue for French, it might be worth investigating a bit more.

But it looks like this might be kind of a global issue :( I notice that sorting tables also puts the Ä at the bottom. So ready to pass QA on this being an improvement.
Comment 10 Katrin Fischer 2022-03-06 13:23:37 UTC
I wonder if this could also be down to a server setting for locale (so might only be an issue in my dev env?) If someone could shed some light it would be nice!
Comment 11 The Minh Luong 2022-03-07 16:40:53 UTC
Created attachment 131444 [details] [review]
Bug 29922: Sorting works for accents

This patch sorts groups of libraries in alphabetical order, with the accents too.
I've used the setlocale() function to set the ordering for comparison (LC_COLLATE) to the one used in french language.

TO TEST:
1. Follow the steps in the previous patch
NOTE: Have some groups of libraries that starts with accented letters (ex. ÉGroup, ÄGroup, ...)
2. Go in the OPAC, then Advanced search and click on the "Groups of libraries" dropdown.
3. Notice that the groups are sorted in alphabetical order.
NOTE: Accented groups are sorted too !

Although this patch can sort the groups as described, I have read that locale might not be available on all computers.
Comment 12 Katrin Fischer 2022-06-25 21:15:21 UTC
Thx a lot for your work on this! 

I am a little worried about hardcoding the fr_CA with this solution. Then I remembered we had a similar problem somewhere else and the solution found there is a little simpler, but appears to also work nicely in my tests:

Bug 29946 - Sort profiles alphabetically when staging MARC records for import 

Could you have a look please?
Comment 13 Shi Yao Wang 2022-06-27 15:32:03 UTC
Created attachment 136612 [details] [review]
Bug 29922: Make get_search_groups return results sorted by title

get_search_groups from Koha/Library/Groups.pm returns library groups sorted by title.

Test plan:
1- Go to administration > library groups and create multiple library groups with different names (e.g. AGroup, BGroup, ÄGroup, etc.). Make sure to tick "Use for OPAC search groups" checkbox.
2- Go to advanced search in OPAC.
3- Under "Groups of librairies" , click the select button.
4- Notice that the library groups are not in alphabetical order.
5- Apply the patch.
6- Notice that the library groups are in alphabetical order.
7- Run `prove t/db_dependent/LibraryGroups.t` and all test should pass.
Comment 14 Katrin Fischer 2022-07-02 22:34:21 UTC
Created attachment 137045 [details] [review]
Bug 29922: Make get_search_groups return results sorted by title

get_search_groups from Koha/Library/Groups.pm returns library groups sorted by title.

Test plan:
1- Go to administration > library groups and create multiple library groups with different names (e.g. AGroup, BGroup, ÄGroup, etc.). Make sure to tick "Use for OPAC search groups" checkbox.
2- Go to advanced search in OPAC.
3- Under "Groups of librairies" , click the select button.
4- Notice that the library groups are not in alphabetical order.
5- Apply the patch.
6- Notice that the library groups are in alphabetical order.
7- Run `prove t/db_dependent/LibraryGroups.t` and all test should pass.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 15 Katrin Fischer 2022-07-02 22:34:44 UTC
The sorting is now correct in the OPAC, but still wrong in the staff interface. We could make file a separate bug for the staff interface or we could add a follow-up here and adjust the bug description.
Comment 16 Shi Yao Wang 2022-07-04 13:21:55 UTC
Created attachment 137063 [details] [review]
Bug 29922: (follow-up) Remove extra sort
Comment 17 Shi Yao Wang 2022-07-04 13:24:52 UTC
Created attachment 137064 [details] [review]
Bug 29922: (follow-up) Remove extra sort

Remove wrong sort in staff advanced search page
Comment 18 Shi Yao Wang 2022-07-04 13:25:49 UTC
It should now sort properly in the staff interface.
Comment 19 David Nind 2022-07-07 15:19:19 UTC
Created attachment 137325 [details] [review]
Bug 29922: Make get_search_groups return results sorted by title

get_search_groups from Koha/Library/Groups.pm returns library groups sorted by title.

Test plan:
1- Go to administration > library groups and create multiple library groups with different names (e.g. AGroup, BGroup, ÄGroup, etc.). Make sure to tick "Use for OPAC search groups" checkbox.
2- Go to advanced search in OPAC.
3- Under "Groups of librairies" , click the select button.
4- Notice that the library groups are not in alphabetical order.
5- Apply the patch.
6- Notice that the library groups are in alphabetical order.
7- Run `prove t/db_dependent/LibraryGroups.t` and all test should pass.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: David Nind <david@davidnind.com>
Comment 20 David Nind 2022-07-07 15:19:24 UTC
Created attachment 137326 [details] [review]
Bug 29922: (follow-up) Remove extra sort

Remove wrong sort in staff advanced search page

Signed-off-by: David Nind <david@davidnind.com>
Comment 21 Katrin Fischer 2022-07-08 11:23:48 UTC
Created attachment 137405 [details] [review]
Bug 29922: Make get_search_groups return results sorted by title

get_search_groups from Koha/Library/Groups.pm returns library groups sorted by title.

Test plan:
1- Go to administration > library groups and create multiple library groups with different names (e.g. AGroup, BGroup, ÄGroup, etc.). Make sure to tick "Use for OPAC search groups" checkbox.
2- Go to advanced search in OPAC.
3- Under "Groups of librairies" , click the select button.
4- Notice that the library groups are not in alphabetical order.
5- Apply the patch.
6- Notice that the library groups are in alphabetical order.
7- Run `prove t/db_dependent/LibraryGroups.t` and all test should pass.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 22 Katrin Fischer 2022-07-08 11:23:58 UTC
Created attachment 137406 [details] [review]
Bug 29922: (follow-up) Remove extra sort

Remove wrong sort in staff advanced search page

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 23 Katrin Fischer 2022-07-08 11:24:25 UTC
Happy to see this one finished, thanks your for your perseverance!
Comment 24 Tomás Cohen Arazi (tcohen) 2022-07-18 18:16:31 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 25 Lucas Gass (lukeg) 2022-08-23 19:34:10 UTC
Backported to 22.05.x for 22.05.05
Comment 26 Arthur Suzuki 2022-08-30 09:25:50 UTC
thx pushed to 21.11.x for 21.11.12
Comment 27 Victor Grousset/tuxayo 2022-09-14 19:22:24 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.

Nothing to document, marking resolved.