Bugzilla – Attachment 185605 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: Fix how rank/priority is adjusted when changing from the UI
Bug-40654-Fix-how-rankpriority-is-adjusted-when-ch.patch (text/plain), 4.83 KB, created by
Emily Lamancusa (emlam)
on 2025-08-20 20:46:50 UTC
(
hide
)
Description:
Bug 40654: Fix how rank/priority is adjusted when changing from the UI
Filename:
MIME Type:
Creator:
Emily Lamancusa (emlam)
Created:
2025-08-20 20:46:50 UTC
Size:
4.83 KB
patch
obsolete
>From d1fc43db897c3dea2d73076da241933d97c16fce 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: 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/modules/reserve/request.tt | 62 ++++++++++++++----- > 1 file changed, 46 insertions(+), 16 deletions(-) > >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 f0e3e2c18c..e50c188a02 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1756,27 +1756,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.34.1
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