[Bug 9458] New: Add sorting to lists
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Bug ID: 9458 Summary: Add sorting to lists Classification: Unclassified Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Lists Assignee: gmcharlt@gmail.com Reporter: kyle@bywatersolutions.com CC: m.de.rooy@rijksmuseum.nl Add the ability to sort results on lists. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #1 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 14781 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=14781&action=edit Bug 9458 - Add sorting to lists Test Plan: 1) Apply patch 2) View list in staff interface, try sorting by title, then author 3) Repeat 2 with same list in OPAC -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #2 from Owen Leonard <oleonard@myacpl.org> --- I have some issues with this: In the staff client: - Sortable columns do not have a visual indicator that they are sortable. They should have an icon like JavaScript-sorted table headers do. - Only DESC sorting is implemented. This is contrary to user expectations based on how table sorting is handled everywhere else in Koha. - How do you sort by call number if there can be any number of call numbers attached to a particular title? In the OPAC: - Sorting depends on JavaScript, but isn't hidden if JavaScript is disabled. Two options here: 1. Hide the sorting form by default and reveal it via JS. 2. Add a submit button to the sort form and hide it with JS. - The call number sort here is just as problematic as in the staff client. I assume that server-side sorting was chosen because these interfaces have server-side pagination. Although it depends on JavaScript, I like the DataTables option for sorting, particularly in the staff client, because it keeps things consistent. I wouldn't reject a patch for not using DataTables, but I think it should be considered. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #3 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Just a remark about the multiple items: See bug report 8032. The sorting on call number works on the first item (just an arbitrary choice). But all call numbers are listed. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Change sponsored?|--- |Sponsored --- Comment #4 from Kyle M Hall <kyle@bywatersolutions.com> --- (In reply to comment #3)
Just a remark about the multiple items: See bug report 8032. The sorting on call number works on the first item (just an arbitrary choice). But all call numbers are listed.
You are correct. However, the callnumber is what the sponsor specifically wants. I'd say it's better than nothing, and in many cases the items will all have the same callnumber which makes the issue moot. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #5 from Kyle M Hall <kyle@bywatersolutions.com> ---
In the staff client:
- Sortable columns do not have a visual indicator that they are sortable. They should have an icon like JavaScript-sorted table headers do. - Only DESC sorting is implemented. This is contrary to user expectations based on how table sorting is handled everywhere else in Koha.
I'll amend the patch to make it follow the conventions more closely.
- How do you sort by call number if there can be any number of call numbers attached to a particular title?
I believe it's sorted by the callnumber highest ranked for that sorting.
In the OPAC:
- Sorting depends on JavaScript, but isn't hidden if JavaScript is disabled. Two options here:
1. Hide the sorting form by default and reveal it via JS. 2. Add a submit button to the sort form and hide it with JS.
I'll go with two since it will keep the feature for non-js enabled browsers.
I assume that server-side sorting was chosen because these interfaces have server-side pagination. Although it depends on JavaScript, I like the DataTables option for sorting, particularly in the staff client, because it keeps things consistent. I wouldn't reject a patch for not using DataTables, but I think it should be considered.
I wanted to use datatables, but when I discovered the server side paging I had to change my method. The best way to handle this would be to rip it out completely and rewrite is as an AJAX-calling DataTable, but that would require some serious development which is a bit out of line with just adding the ability to sort the results. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #14781|0 |1 is obsolete| | --- Comment #6 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 14790 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=14790&action=edit Bug 9458 - Add sorting to lists Test Plan: 1) Apply patch 2) View list in staff interface, try sorting by title, then author 3) Repeat 2 with same list in OPAC -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #14790|0 |1 is obsolete| | --- Comment #7 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 14791 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=14791&action=edit Bug 9458 - Add sorting to lists Test Plan: 1) Apply patch 2) View list in staff interface, try sorting by title, then author 3) Repeat 2 with same list in OPAC -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #14791|0 |1 is obsolete| | --- Comment #8 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 14792 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=14792&action=edit Bug 9458 - Add sorting to lists Test Plan: 1) Apply patch 2) View list in staff interface, try sorting by title, then author 3) Repeat 2 with same list in OPAC -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Paul Poulain <paul.poulain@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off CC| |paul.poulain@biblibre.com --- Comment #9 from Paul Poulain <paul.poulain@biblibre.com> --- Patch tested with a sandbox, by Delaye Stephane <stephane.delaye@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Paul Poulain <paul.poulain@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #14792|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #10 from Paul Poulain <paul.poulain@biblibre.com> --- Created attachment 15363 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15363&action=edit Bug 9458 - Add sorting to lists Test Plan: 1) Apply patch 2) View list in staff interface, try sorting by title, then author 3) Repeat 2 with same list in OPAC Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@biblibre.co | |m --- Comment #11 from Jonathan Druart <jonathan.druart@biblibre.com> --- 3 small remarks: - At the OPAC, the user does not know what is the default sorting. At the intranet, same thing, maybe we would like to add the arrows (up and down) according to the default sorting. - We cannot sort by copyright date. - We cannot choose a direction (asc/desc) on editing a list. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #12 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 15543 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15543&action=edit Bug 9458 - Add sorting to lists - QA Followup -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #15543|0 |1 is obsolete| | --- Comment #13 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 15545 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15545&action=edit Bug 9458 - Add sorting to lists - QA Followup -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #14 from Kyle M Hall <kyle@bywatersolutions.com> --- (In reply to comment #11)
3 small remarks: - At the OPAC, the user does not know what is the default sorting. At the intranet, same thing, maybe we would like to add the arrows (up and down)
Fixed for Intranet. For the OPAC, the sorting is shown in the "Sort by:" pulldown.
- We cannot sort by copyright date.
Fixed!
- We cannot choose a direction (asc/desc) on editing a list.
This one is a bit out of scope for this bug. It would require a database change. I'm going to file a separate bug report for it and attach this one as a blocker. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |9661 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #15 from Jonathan Druart <jonathan.druart@biblibre.com> --- (In reply to comment #14)
(In reply to comment #11)
3 small remarks: - At the OPAC, the user does not know what is the default sorting. At the intranet, same thing, maybe we would like to add the arrows (up and down)
Fixed for Intranet. For the OPAC, the sorting is shown in the "Sort by:" pulldown.
Thanks. There is an issue about arrows: [% IF direction == 'asc' %][% direction = 'desc' %][% ELSE %][% direction = 'asc' %][% END %] So there is an inversion on them. When the 'asc' is needed, the desc.gif is displayed.
- We cannot choose a direction (asc/desc) on editing a list.
This one is a bit out of scope for this bug. It would require a database change. I'm going to file a separate bug report for it and attach this one as a blocker.
Yep! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #15545|0 |1 is obsolete| | --- Comment #16 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 15554 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15554&action=edit Bug 9458 - Add sorting to lists - QA Followup -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #17 from Kyle M Hall <kyle@bywatersolutions.com> ---
There is an issue about arrows: [% IF direction == 'asc' %][% direction = 'desc' %][% ELSE %][% direction = 'asc' %][% END %]
So there is an inversion on them. When the 'asc' is needed, the desc.gif is displayed.
Good catch! Fixed in this new replacement followup! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA Patch complexity|Trivial patch |Small patch QA Contact| |jonathan.druart@biblibre.co | |m --- Comment #18 from Jonathan Druart <jonathan.druart@biblibre.com> --- QA comment: Works fine. This patch adds sorting to lists at the OPAC and the intranet. A great improvement would be to add links on arrows. Marked as Passed QA. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #15363|0 |1 is obsolete| | Attachment #15554|0 |1 is obsolete| | --- Comment #19 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 15674 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15674&action=edit Bug 9458 - Add sorting to lists Test Plan: 1) Apply patch 2) View list in staff interface, try sorting by title, then author 3) Repeat 2 with same list in OPAC Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #20 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 15675 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15675&action=edit Bug 9458 - Add sorting to lists - QA Followup Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #21 from Jared Camins-Esakov <jcamins@cpbibliography.com> --- I am concerned about the way $sortfield is included directly in the query. Does it provide an SQL injection vector? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #22 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 15694 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15694&action=edit Bug 9458 - Add sorting to lists - QA Followup 2 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #23 from Kyle M Hall <kyle@bywatersolutions.com> --- Good catch! We cannot use a placeholder for ORDER BY fields, but we *can* escape it using quote_identifier to ensure it cannot be used for SQL injection attacks. I've attached a second followup to add this. (In reply to comment #21)
I am concerned about the way $sortfield is included directly in the query. Does it provide an SQL injection vector?
-- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #24 from Jared Camins-Esakov <jcamins@cpbibliography.com> --- Comment on attachment 15675 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15675 Bug 9458 - Add sorting to lists - QA Followup Review of attachment 15675: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=9458&attachment=15675) ----------------------------------------------------------------- ::: C4/VirtualShelves/Page.pm @@ +249,4 @@
my $items; my $tag_quantity; my $sortfield = ( $sorton ? $sorton : 'title' ); + $sortfield = $query->param('sort') || $sortfield || 'title'; ## Passed in sorting overrides default sorting
I am a little bit perplexed by this line. Why did you add the || 'title' when $sortfield has already been set? Or, equivalently, why did you set $sortfield previously? I would have thought the simplest way to get the desired results would be: my $sortfield = $query->param('sort') || $sorton || 'title'; My chief concern is, is there some sort of side-effect in the code that you're trying to work around with this? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #25 from Kyle M Hall <kyle@bywatersolutions.com> ---
I am a little bit perplexed by this line. Why did you add the || 'title' when $sortfield has already been set? Or, equivalently, why did you set $sortfield previously? I would have thought the simplest way to get the desired results would be: my $sortfield = $query->param('sort') || $sorton || 'title';
My chief concern is, is there some sort of side-effect in the code that you're trying to work around with this?
Nope, that's just me being stupid ; ) I'll post a small followup to fix that. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #26 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 15891 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15891&action=edit Bug 9458 - Add sorting to lists - QA Followup 3 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #27 from Jared Camins-Esakov <jcamins@cpbibliography.com> --- I've noticed something very odd about sorting on the staff client: if I choose to sort by title (for example), it always defaults to sorting in *descending* order, from Z-A. Is there any way to fix that so that it sorts according to what we might expect? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #28 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 15952 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15952&action=edit Bug 9458 - Add sorting to lists - QA Followup 4 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 --- Comment #29 from Kyle M Hall <kyle@bywatersolutions.com> --- Good catch! This latest followup fixes that. I've also simplified some of the presentation logic. (In reply to comment #27)
I've noticed something very odd about sorting on the staff client: if I choose to sort by title (for example), it always defaults to sorting in *descending* order, from Z-A. Is there any way to fix that so that it sorts according to what we might expect?
-- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Jared Camins-Esakov <jcamins@cpbibliography.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Failed QA --- Comment #30 from Jared Camins-Esakov <jcamins@cpbibliography.com> --- (In reply to comment #29)
Good catch! This latest followup fixes that. I've also simplified some of the presentation logic.
There's a problem with your latest follow-up: it inserts unsanitized user input into the page. I checked and it seems that most browsers catch the XSS if you try to insert Javascript, but I'd rather not depend on that if we don't have to. To see what I mean, try a link like: /cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=55&sort=title&direction=%22%3Ehere's%20some%20text%3Cspan%20style=%22 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #15952|0 |1 is obsolete| | --- Comment #31 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 16031 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=16031&action=edit Bug 9458 - Add sorting to lists - QA Followup 4 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Passed QA --- Comment #32 from Kyle M Hall <kyle@bywatersolutions.com> ---
There's a problem with your latest follow-up: it inserts unsanitized user input into the page. I checked and it seems that most browsers catch the XSS if you try to insert Javascript, but I'd rather not depend on that if we don't have to. To see what I mean, try a link like: /cgi-bin/koha/virtualshelves/shelves. pl?viewshelf=55&sort=title&direction=%22%3Ehere's%20some%20text%3Cspan%20styl e=%22
Fixed! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Jared Camins-Esakov <jcamins@cpbibliography.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #33 from Jared Camins-Esakov <jcamins@cpbibliography.com> --- This patch has been pushed to master. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9458 Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bgkriegel@gmail.com --- Comment #34 from Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> --- On request, a slightly modified version of this is included in 3.10.x, it changes a little, only add sort capability to lists by Author/Title. Pushed to 3.10.x, will be in 3.10.8 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org