[Koha-bugs] [Bug 27565] Dropdowns in Item Search should be sorted alphabetically

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Apr 20 05:55:05 CEST 2021


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

David Cook <dcook at prosentient.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcook at prosentient.com.au

--- Comment #3 from David Cook <dcook at prosentient.com.au> ---
I can confirm, at the very least, that this is happening in master for Shelving
Location on the staff interface's /cgi-bin/koha/catalogue/itemsearch.pl page.

It appears to be sorting by the primary key instead of the description. 

Some relevant lines from the itemsearch.tt file:

[% locations = AuthorisedValues.GetDescriptionsByKohaField({ kohafield =
'items.location' }) %]
[% FOREACH loc IN locations %]
    [% loc.value = loc.authorised_value %]
    [% loc.label = loc.lib %]
[% END %]

Koha::Template::Plugin::AuthorisedValues leads to
Koha::AuthorisedValues->get_descriptions_by_koha_field

I'm seeing no sorting...

But I also don't see any obvious changes to this code in years...

By contrast, the Shelving Location is sorted on
/cgi-bin/koha/cataloguing/additem.pl as it uses a different module. It uses
C4::Koha::GetAuthorisedValues.

Looking at other instances of
Koha::AuthorisedValues->get_descriptions_by_koha_field, I see the method is
typically used to build an unsorted hashmap, and then that is used to build a
sorted array. I'm not sure why Matthias did it that way back in 2016, as it
seems inefficient for no gain. Also potentially adds some syntactical issues...

So there are 2 solutions:

1. Add sorting to Koha::AuthorisedValues
2. Add sorting to itemsearch.tt and itemsearch.pl (the data is fetched for
different dropdowns in different places)

The most efficient option would be to sort at the database level, so
Koha::AuthorisedValues, but it's the heaviest touch, and would require the most
testing. Changing itemsearch.pl would be easier although 

For what it's worth, I think that this has been an issue for at least 4 years. 

This is a bit too systemic to write a quick patch, so I'll leave this one for
someone with more time.

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list