Bugzilla – Attachment 185630 Details for
Bug 40654
Sorting holds table can cause priority issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40654: [24.11.x] Fix how rank/priority is adjusted when changing from the UI
Bug-40654-2411x-Fix-how-rankpriority-is-adjusted-w.patch (text/plain), 13.56 KB, created by
Lucas Gass (lukeg)
on 2025-08-21 17:03:33 UTC
(
hide
)
Description:
Bug 40654: [24.11.x] Fix how rank/priority is adjusted when changing from the UI
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-08-21 17:03:33 UTC
Size:
13.56 KB
patch
obsolete
>From a92a05d328fc2c6818c6fb5e7ec952231d914f25 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 14 Aug 2025 18:42:17 +0000 >Subject: [PATCH] Bug 40654: [24.11.x] Fix how rank/priority is adjusted when > changing from the UI > >To test: >0 - APPLY PATCH >1 - Place 50 holds on a bib record >https://github.com/kidclamp/handy-koha-script/blob/main/randhold.pl >2 - View the holds page for the record >3 - Sort the holds alphabetically >4 - Change the dropdown priortiy for the alphabetically first hold to 1 >5 - All the priorities should now ajust accordingly but they will NOT be resorted on the fly >6 - Play with adjusting some priorities, making sure everything correctly adjusts. >7 - Click 'Update holds' to make sure the priorities adjust right >8 - Make sure you test with the 'del' option and the adjustments still work. > >Signed-off-by: David Flater <flaterdavid@gmail.com> >Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> >--- > .../prog/en/includes/holds_table.inc | 103 +++++++++--------- > .../prog/en/modules/reserve/request.tt | 70 +++++++++--- > 2 files changed, 107 insertions(+), 66 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index 36ca90c6cd4..11bc576f8cc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -35,61 +35,64 @@ > > <tbody> > [% FOREACH hold IN holds %] >- [%- IF !hold.found && first_priority == 0 -%] >- [%- first_priority = hold.priority -%] >- [%- found_holds = loop.index() -%] >- [%- END -%] >- [%- IF Koha.Preference('HoldsSplitQueueNumbering') == 'actual' -%] >- [%- this_priority = hold.priority -%] >- [%- ELSE -%] >- [%- this_priority = loop.count() - found_holds -%] >- [%- END -%] >- [% IF hold.suspend %] >- <tr class="suspend"> >- [% ELSE %] >- <tr> >- [% END %] >- <td><input type="checkbox" class="select_hold" data-id="[% hold.reserve_id | html %]"/></td> >- <td> >- <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" /> >- <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" /> >- <input type="hidden" name="biblionumber" value="[% hold.biblionumber | html %]" /> >- [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] >- [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %] >- <select name="rank-request" class="rank-request" data-hold-id="[% hold.reserve_id | html %]"> >- [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] >- [% FOREACH priority IN all_priorities %] >- [% IF priority == this_priority %] >- <option value="[% priority | html %]" selected="selected">[% priority | html %]</option> >- [% ELSIF priority > 0 %] >- <option value="[% priority | html %]">[% priority | html %]</option> >+ [%- IF !hold.found && first_priority == 0 -%] >+ [%- first_priority = hold.priority -%] >+ [%- found_holds = loop.index() -%] >+ [%- END -%] >+ [%- IF Koha.Preference('HoldsSplitQueueNumbering') == 'actual' -%] >+ [%- this_priority = hold.priority -%] >+ [%- ELSE -%] >+ [%- this_priority = loop.count() - found_holds -%] >+ [%- END -%] >+ [% SET tr_class = hold.suspend ? 'suspend' : '' %] >+ <tr class="[% tr_class | html %]"> >+ <td><input type="checkbox" class="select_hold" data-id="[% hold.reserve_id | html %]" /></td> >+ <td style="min-width:185px;" data-order="[% priority | html %]"> >+ <div> >+ <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" /> >+ <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" /> >+ <input type="hidden" name="biblionumber" value="[% hold.biblionumber | html %]" /> >+ [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] >+ [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %] >+ <label for="rank-request_[% hold.reserve_id | html %]">Change priority to:</label> >+ <select name="rank-request" id="rank-request_[% hold.reserve_id | html %]" class="rank-request" data-hold-id="[% hold.reserve_id | html %]"> >+ [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] >+ [% FOREACH priority IN all_priorities %] >+ [% IF priority == this_priority %] >+ <option value="[% priority | html %]" selected="selected">[% priority | html %]</option> >+ [% ELSIF priority > 0 %] >+ <option value="[% priority | html %]">[% priority | html %]</option> >+ [% END %] >+ [% END %] >+ [% ELSE %] >+ <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option> > [% END %] >- [% END %] >+ <option value="del">del</option> >+ </select> > [% ELSE %] >- <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option> >+ <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]" /> >+ <select name="rank-request" class="rank-request" disabled="disabled" data-hold-id="[% hold.reserve_id | html %]"> >+ [% IF ( hold.found ) %] >+ [% IF ( hold.intransit ) %] >+ <option value="T" selected="selected">In transit</option> >+ [% ELSIF (hold.inprocessing) %] >+ <option value="P" selected="selected">In processing</option> >+ [% ELSE %] >+ <option value="W" selected="selected">Waiting</option> >+ [% END %] >+ [% ELSE %] >+ <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option> >+ [% END %] >+ </select> > [% END %] >- <option value="del">del</option> >- </select> > [% ELSE %] >- <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]"> >- <select name="rank-request" class="rank-request" disabled="disabled" data-hold-id="[% hold.reserve_id | html %]"> >- [% IF ( hold.found ) %] >- [% IF ( hold.intransit ) %] >- <option value="T" selected="selected">In transit</option> >- [% ELSIF (hold.inprocessing) %] >- <option value="P" selected="selected">In processing</option> >- [% ELSE %] >- <option value="W" selected="selected">Waiting</option> >- [% END %] >- [% ELSE %] >- <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option> >- [% END %] >- </select> >+ <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]" /> > [% END %] >- [% ELSE %] >- <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]"> >- [% hold.priority | html %] >- [% END %] >+ <div> >+ <label for="current_priority_[% hold.reserve_id | html %]">Current priority: </label> >+ <span id="current_priority_[% hold.reserve_id | html %]" class="current_priority badge text-bg-info">[% hold.priority | html %]</span> >+ </div> >+ </div> > </td> > [%- IF ( CAN_user_reserveforothers_modify_holds_priority ) -%] > [%- UNLESS hold.found -%] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 3884124a9c0..13cfda885d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -102,6 +102,14 @@ > :disabled{ > opacity:0.5 > } >+ .current_priority { >+ width: 50px; >+ text-align: left; >+ margin-top: 5px; >+ } >+ .rank-request { >+ width: 50px; >+ } > </style> > [% END %] > </head> >@@ -1815,27 +1823,57 @@ > }); > var prev_rank_request; > $("select[name=rank-request]").on("focus", function() { >- prev_rank_request = $(this).val(); >- var row = $(this).parents("tr:first"); >+ prev_rank_request = parseInt($(this).val()); > }).change(function() { >- var row = $(this).parents("tr:first"); >- var value = parseInt($(this).val()); >- var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found >- if( !isNaN(value) ) { //If moved to 'del' >- var after = row.parent().find(`tr:nth-child(${value+found_holds})`); //Go to the row 1 after the new value (and skip found holds) >- if (prev_rank_request > value) { >- row.insertBefore(after); >- } else { >- row.insertAfter(after); >+ var this_rank = $(this); >+ var new_rank = parseInt(this_rank.val()); >+ var old_rank = prev_rank_request; >+ >+ if ( isNaN( old_rank ) ) { >+ $("select[name=rank-request]").not('[disabled]').not(this_rank).each(function() { >+ var current_rank = parseInt($(this).val()); >+ if ( !isNaN(current_rank) && current_rank >= new_rank ) { >+ $(this).val(current_rank + 1); >+ } >+ }); >+ prev_rank_request = new_rank; >+ return; >+ } >+ >+ if ( isNaN( new_rank ) ) { >+ if ( !isNaN( old_rank ) ) { >+ $("select[name=rank-request]").not('[disabled]').not(this).each(function() { >+ var current_rank = parseInt($(this).val()); >+ if ( !isNaN(current_rank) && current_rank > old_rank ) { >+ $(this).val(current_rank - 1); >+ } >+ }); > } >+ prev_rank_request = NaN; >+ return; > } > >- var next_priority = 1; >- $("select[name=rank-request]").each(function () { >- if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds >- $(this).val(next_priority); >- next_priority++; >+ //if new rank is old rank, don't continue >+ if ( new_rank === old_rank ) return; >+ >+ // Adjust ranks >+ $("select[name=rank-request]").not('[disabled]').not(this).each(function() { >+ var current_rank = parseInt($(this).val()); >+ //if current_rank is NaN, bail >+ if ( isNaN( current_rank ) ) return; >+ >+ if ( old_rank > new_rank ) { >+ if ( current_rank >= new_rank && current_rank < old_rank ) { >+ $(this).val(current_rank + 1); >+ } >+ } else { >+ if ( current_rank > old_rank && current_rank <= new_rank ) { >+ $(this).val(current_rank - 1); >+ } >+ } > }); >+ >+ prev_rank_request = new_rank; > }); > > $(".clear-date").on("click",function(e){ >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40654
:
185419
|
185477
|
185589
|
185590
|
185597
|
185600
|
185605
|
185606
| 185630