From e821f50b4e49abc5a6f07b007e353b98632d6f2c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 17 Sep 2021 13:59:25 +0000 Subject: [PATCH] Bug 29049: Simplify holds priority dropdown logic on request.pl MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch makes a few changes: 1 - If we are not splitting the queue ( HoldsSplitQueue == 'nothing' ) then there are no changes for 'virtual' vs 'actual' numbering 2 - If we are splitting the queue you cannot use the dropdown, so we do not need to process the options 3 - If the hold is 'found' we do not need to process the options 4 - We can simply use the 'last priority' to build the options, we do not need to process in the script 5 - We can use a block to build the options 6 - Remove a stray holds.index To test: 1 - Place 5 holds on a bib 2 - 'Find' two of the holds i.e. check them in to set status to 'transit' or 'waiting' 3 - View the holds page for the biblio 4 - Inspect the priorty dropdown for the found holds, note they have options for 1-5 but are disabled 5 - Note the dropdowns for other holds have options 1-5 6 - Note options 4&5 in the dropdowns have no effect 7 - Apply patch 8 - Inspect the priority dopdowns on the found holds 9 - Note they only show their found status 10 - Note the other dropdowns only show options 1-3 11 - Test with other HoldsSplitQueue options and HoldsSplitQueueNumbering 12 - When holds queue is split, no dropdowns should be active and should show only their current priority 13 - When HoldsSplitQueueNumbering is 'virtual' the dropdown should be disabled and correctly count the number of unfound holds in the list Signed-off-by: Andrew Fuerste-Henry JK: Fixed grammar in commit title Signed-off-by: Joonas Kylmälä JD: Remove trailing 'i' Bug 29049: (QA follow-up) Remove excessive whitespace Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- .../prog/en/includes/holds_table.inc | 65 ++++++++++--------- reserve/request.pl | 12 ---- 2 files changed, 34 insertions(+), 43 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 59f33cd2a0..b2325a409c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -25,8 +25,29 @@ [% SET first_priority = 0 %] [% SET last_priority = holds.last.priority %] + [% BLOCK priority_dropdown %] + [% SET loop_priority = 1 %] + [% WHILE loop_priority <= last_priority %] + [% IF this_priority == loop_priority %] + + [% ELSE %] + + [% END %] + [% loop_priority = loop_priority + 1 %] + [% END %] + [% END %] + + [% FOREACH hold IN holds %] - [% IF !hold.found && first_priority == 0 %][% first_priority = hold.priority %][% END %] + [% 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 %] @@ -34,10 +55,17 @@ [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %] [% ELSE %] + + [% END %] [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] [% UNLESS hold.found %] [% SET prev_priority = loop.prev.priority %] [% SET next_priority = loop.next.priority %] - [% holds.index | html %] diff --git a/reserve/request.pl b/reserve/request.pl index 85357158b2..347c2a2391 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -661,17 +661,6 @@ foreach my $biblionumber (@biblionumbers) { { my $priority = $res->priority(); my %reserve; - my @optionloop; - for ( my $i = 1 ; $i <= $totalcount ; $i++ ) { - push( - @optionloop, - { - num => $i, - selected => ( $i == $priority ), - } - ); - } - if ( $res->is_found() ) { $reserve{'holdingbranch'} = $res->item()->holdingbranch(); $reserve{'biblionumber'} = $res->item()->biblionumber(); @@ -704,7 +693,6 @@ foreach my $biblionumber (@biblionumbers) { $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef; $reserve{'priority'} = $res->priority(); $reserve{'lowestPriority'} = $res->lowestPriority(); - $reserve{'optionloop'} = \@optionloop; $reserve{'suspend'} = $res->suspend(); $reserve{'suspend_until'} = $res->suspend_until(); $reserve{'reserve_id'} = $res->reserve_id(); -- 2.39.5