Bug 29713

Summary: Make item table when placing an item level hold sortable
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: OPACAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, kyle, lucas
Version: master   
Hardware: All   
OS: All   
URL: /cgi-bin/koha/opac-reserve.pl?biblionumber=
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00
Bug Depends on:    
Bug Blocks: 31355    
Attachments: Bug 29713: Make item table when placing an item level hold sortable
Bug 29713: Make item table when placing an item level hold sortable
Bug 29713: Make item table when placing an item level hold sortable
Bug 29713: Make item table when placing an item level hold sortable
Bug 29713: Make item table when placing an item level hold sortable
Bug 29713: Make item table when placing an item level hold sortable
Bug 29713: Make item table when placing an item level hold sortable

Description Katrin Fischer 2021-12-16 15:29:47 UTC
For serial records where the items are different volumes and issues, item level holds make sense, but there are often a lot of items to pick from too. It would be great if the item form on the hold request page in the OPAC had sorting and filter options to make picking the correct item easier.

The table is already sortable in the staff interface.
Comment 1 Owen Leonard 2022-01-25 18:47:08 UTC Comment hidden (obsolete)
Comment 2 Lucas Gass 2022-01-25 20:30:35 UTC Comment hidden (obsolete)
Comment 3 Lucas Gass 2022-01-25 20:33:04 UTC
This works well and I am signing off on it but thought it would be worth mentioning that the QA tool says: 

FAIL	koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
FAIL	  forbidden patterns
		forbidden pattern: Font Awesome icons need the aria-hidden attribute for accessibility purpose (see bug 25166)  (line 378)


I don't quite understand what would be wrong because the FA icon on line 378 does have the aria-hidden attribute:

<i class="fa fa-remove danger" aria-hidden="true" title="Cannot be put on hold"></i>
Comment 4 Lucas Gass 2022-01-31 14:39:04 UTC
*** Bug 29972 has been marked as a duplicate of this bug. ***
Comment 5 Jonathan Druart 2022-02-01 15:30:53 UTC
CONFLICT (content): Merge conflict in koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
Comment 6 Owen Leonard 2022-02-01 16:36:25 UTC Comment hidden (obsolete)
Comment 7 Jonathan Druart 2022-02-18 15:23:11 UTC Comment hidden (obsolete)
Comment 8 Jonathan Druart 2022-02-18 15:23:37 UTC
Not a big deal but I don't understand how the "Information" column is sorted: https://snipboard.io/zkms9E.jpg


QA script raises an error, but it's not a regression:
forbidden pattern: Font Awesome icons need the aria-hidden attribute for accessibility purpose (see bug 25166)  (line 379)
Comment 9 Fridolin Somers 2022-02-23 20:32:47 UTC
Arf sorry patch does not apply anymore.
Looks like it is because of Bug 29660.
Comment 10 Katrin Fischer 2022-02-26 16:31:35 UTC
I tried... but it's way too confusing for me. :(
Comment 11 Jonathan Druart 2022-02-28 17:17:20 UTC
I don't have the time right now, but here is the result of the -w version of the local branch I have. That should make the patch easier to rewrite.

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
index 2d84cdffb44..424a26bac19 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
@@ -345,6 +345,7 @@
                                             [% IF bibitemloo.itemholdable %]
                                                 <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber | html %]">
                                                     <caption>Select a specific item:</caption>
+                                                    <thead>
                                                         <tr>
                                                             <th>Copy number</th>
                                                             [% IF ( item_level_itypes ) %]
@@ -365,10 +366,11 @@
                                                             <th>Notes</th>
                                                             <th>Information</th>
                                                         </tr>
-
+                                                    </thead>
+                                                    <tbody>
                                                         [% FOREACH itemLoo IN bibitemloo.itemLoop %]
                                                             <tr class="[% itemLoo.backgroundcolor | html %]">
-                                                            <td class="copynumber">
+                                                                <td class="copynumber" data-order="[% itemLoo.copynumber | html %]">
                                                                     [% IF ( itemLoo.available ) %]
                                                                         <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
                                                                     [% ELSE %]
@@ -451,6 +453,7 @@
                                                                 </td>
                                                             </tr>
                                                         [% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
+                                                    </tbody>
                                                 </table> <!-- / #copiesrow_[% bibitemloo.biblionumber | html %] -->
                                             [% END # / IF ( bibitemloo.itemholdable )%]
                                         </div> <!-- / #hold-options-[% bibitemloo.biblionumber | html %] -->
@@ -472,6 +475,7 @@
 [% INCLUDE 'opac-bottom.inc' %]
 [% BLOCK jsinclude %]
 [% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'datatables.inc' %]
 <script>
     var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
 
@@ -673,6 +677,11 @@
             return true;
         });
 
+        $(".copiesrow").each(function(){
+            $(this).DataTable({
+                dom: "t"
+            });
+        });
     });
 </script>
 [% END %]
Comment 12 Owen Leonard 2022-03-01 19:09:44 UTC
Created attachment 131206 [details] [review]
Bug 29713: Make item table when placing an item level hold sortable

This patch modifies the holds page in the OPAC so that users selecting a
specific item to place a hold on can sort the table of items.

This patch also removes some obsolete JavaScript left over from before
Flatpickr.

To test, apply the patch and go to Administration -> Circulation and
fine rules to make sure at least one item type in your system has
"OPAC item level holds" set to "allow."

- Log in to the OPAC as a user who can place holds.
- Search the catalog for items which will accept item-level holds.
- Place a hold on one of the results, and click the "Show more options"
  link on the holds page.
  - Check the "specific item" radio button.
  - A table of items should be displayed. Confirm that the table is
    sortable.
  - The first entry in the table should be selected.
  - Perform the same test when placing a hold on multiple titles.
    Confirm that each table of items is sortable.
Comment 13 Katrin Fischer 2022-03-06 13:29:58 UTC
Created attachment 131410 [details] [review]
Bug 29713: Make item table when placing an item level hold sortable

This patch modifies the holds page in the OPAC so that users selecting a
specific item to place a hold on can sort the table of items.

This patch also removes some obsolete JavaScript left over from before
Flatpickr.

To test, apply the patch and go to Administration -> Circulation and
fine rules to make sure at least one item type in your system has
"OPAC item level holds" set to "allow."

- Log in to the OPAC as a user who can place holds.
- Search the catalog for items which will accept item-level holds.
- Place a hold on one of the results, and click the "Show more options"
  link on the holds page.
  - Check the "specific item" radio button.
  - A table of items should be displayed. Confirm that the table is
    sortable.
  - The first entry in the table should be selected.
  - Perform the same test when placing a hold on multiple titles.
    Confirm that each table of items is sortable.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 14 Katrin Fischer 2022-03-06 13:30:07 UTC
This works nicely, thx for rescuing the patch, Owen!

Only 'nit-pick' I have that we offer sorting on the first column with the checkboxes, but that doesn't appear to work, so we might want to remove the sorting option there altogether. (QA follow-up?)
Comment 15 Jonathan Druart 2022-03-22 10:33:07 UTC
Created attachment 132002 [details] [review]
Bug 29713: Make item table when placing an item level hold sortable

This patch modifies the holds page in the OPAC so that users selecting a
specific item to place a hold on can sort the table of items.

This patch also removes some obsolete JavaScript left over from before
Flatpickr.

To test, apply the patch and go to Administration -> Circulation and
fine rules to make sure at least one item type in your system has
"OPAC item level holds" set to "allow."

- Log in to the OPAC as a user who can place holds.
- Search the catalog for items which will accept item-level holds.
- Place a hold on one of the results, and click the "Show more options"
  link on the holds page.
  - Check the "specific item" radio button.
  - A table of items should be displayed. Confirm that the table is
    sortable.
  - The first entry in the table should be selected.
  - Perform the same test when placing a hold on multiple titles.
    Confirm that each table of items is sortable.

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 16 Fridolin Somers 2022-03-25 00:25:12 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄