@@ -, +, @@ existing priority numbers of the given table --- koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -164,24 +164,33 @@ function checkMultiHold() { } }); var prev_rank_request; + var priorities; $("select[name=rank-request]").on("focus", function() { prev_rank_request = $(this).val(); + + var row = $(this).parents("tr:first"); + priorities = row.parent().find("select[name=rank-request]").map( function() { + return $(this).val(); + }).get(); }).change(function() { var row = $(this).parents("tr:first"); + var value = parseInt($(this).val()); var rowsCount = row.parent().children('tr').length - 1; value = value > rowsCount ? rowsCount : value; var after = row.parent().find("tr:nth-child("+(value+1)+")"); + + if (prev_rank_request > value) { row.insertBefore(after); } else { row.insertAfter(after); } - var next_priority = 1; + var next_priority = 0; row.parent().find("select[name=rank-request]").each(function () { - $(this).val(next_priority); + $(this).val(priorities[next_priority]); next_priority++; }); }); --