Bug 22753: Fix hold priority adjustment, move to top
authorNick Clemens <nick@bywatersolutions.com>
Tue, 23 Apr 2019 18:03:33 +0000 (18:03 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 26 Apr 2019 15:05:17 +0000 (16:05 +0100)
Since the holds table can be split we need to calculate the
first priority for each table. However, currently we use the
first in the loop, not taking into account the waiting status.
This patchset sets the first_priority to the first non-found hold

Additionally, some clean-up is done to not display the alter
priority arrows for waiting holds.

To test:
1 - Place several holds on a title
2 - Confirm one of the holds to be waiting
3 - Attempt to move the last hold to the top
4 - Nothing happens
5 - Apply patch
6 - Note that the waiting hold has no options to move in the list
7 - Attempt to move the last hold to the top
8 - It moves as expected!
9 - Split the holds queue by pickup library
10 - PLace some holds for pickup at another branch
11 - Confirm moving these holds works within their own table
12 - Unsplit the queue
13 - Ensure the holds end where you expect (moving in a split
     table didn't move above holds form another table)

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

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

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit eb956eb4cf3d44f45ad54be58fe95d7355a2b8bf)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc

index 5a50892..8eee953 100644 (file)
         [% IF SuspendHoldsIntranet %]<th>&nbsp;</th><!-- Suspend Holds Column Header -->[% END %]
     </tr>
 
+    [% SET first_priority = 0 %]
+    [% SET last_priority  = holds.last.priority %]
+
     [% FOREACH hold IN holds %]
+    [% IF !hold.found && first_priority == 0 %][% first_priority = hold.priority %][% END %]
         <tr>
             <td>
                 <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" />
             </td>
 
             [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-                [% SET first_priority = holds.first.priority %]
-                [% SET last_priority  = holds.last.priority %]
-                [% SET prev_priority  = loop.prev.priority %]
-                [% SET next_priority  = loop.next.priority %]
-                [% holds.index | html %]
-
-                <td style="white-space:nowrap;">
-                    <a title="Move hold up" href="request.pl?action=move&amp;where=up&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
-                        <img src="[% interface | html %]/[% theme | html %]/img/go-up.png" alt="Go up" />
-                    </a>
-
-                    <a title="Move hold to top" href="request.pl?action=move&amp;where=top&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
-                        <img src="[% interface | html %]/[% theme | html %]/img/go-top.png" alt="Go top" />
-                    </a>
-
-                    <a title="Move hold to bottom" href="request.pl?action=move&amp;where=bottom&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
-                        <img src="[% interface | html %]/[% theme | html %]/img/go-bottom.png" alt="Go bottom" />
-                    </a>
-
-                    <a title="Move hold down" href="request.pl?action=move&amp;where=down&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
-                        <img src="[% interface | html %]/[% theme | html %]/img/go-down.png" alt="Go down" />
-                    </a>
-                </td>
+               [% UNLESS hold.found %]
+                    [% SET prev_priority  = loop.prev.priority %]
+                    [% SET next_priority  = loop.next.priority %]
+                    [% holds.index | html %]
+
+                    <td style="white-space:nowrap;">
+                        <a title="Move hold up" href="request.pl?action=move&amp;where=up&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
+                            <img src="[% interface | html %]/[% theme | html %]/img/go-up.png" alt="Go up" />
+                        </a>
+
+                        <a title="Move hold to top" href="request.pl?action=move&amp;where=top&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
+                            <img src="[% interface | html %]/[% theme | html %]/img/go-top.png" alt="Go top" />
+                        </a>
+
+                        <a title="Move hold to bottom" href="request.pl?action=move&amp;where=bottom&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
+                            <img src="[% interface | html %]/[% theme | html %]/img/go-bottom.png" alt="Go bottom" />
+                        </a>
+
+                        <a title="Move hold down" href="request.pl?action=move&amp;where=down&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
+                            <img src="[% interface | html %]/[% theme | html %]/img/go-down.png" alt="Go down" />
+                        </a>
+                    </td>
+               [% ELSE %]
+                   <td></td>
+               [% END %]
             [% END %]
 
             <td>
             </td>
 
             [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-                <td>
-                    <a title="Toggle lowest priority" href="request.pl?action=setLowestPriority&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
-                        [% IF ( hold.lowestPriority ) %]
-                            <img src="[% interface | html %]/[% theme | html %]/img/go-bottom.png" alt="Unset lowest priority" />
-                        [% ELSE %]
-                            <img src="[% interface | html %]/[% theme | html %]/img/go-down.png" alt="Set to lowest priority" />
-                        [% END %]
-                    </a>
-                </td>
+               [% UNLESS hold.found %]
+                    <td>
+                        <a title="Toggle lowest priority" href="request.pl?action=setLowestPriority&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
+                            [% IF ( hold.lowestPriority ) %]
+                                <img src="[% interface | html %]/[% theme | html %]/img/go-bottom.png" alt="Unset lowest priority" />
+                            [% ELSE %]
+                                <img src="[% interface | html %]/[% theme | html %]/img/go-down.png" alt="Set to lowest priority" />
+                            [% END %]
+                        </a>
+                    </td>
+               [% ELSE %]
+                   <td></td>
+               [% END %]
             [% END %]
 
             <td>