Bugzilla – Attachment 80933 Details for
Bug 21608
Arranging holds priority with dropdowns is faulty when there are waiting/intransit holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21608: WIP - attempt to fix priority dropdowns (18.05 based)
Bug-21608-WIP---attempt-to-fix-priority-dropdowns-.patch (text/plain), 5.53 KB, created by
Nick Clemens
on 2018-10-19 12:54:51 UTC
(
hide
)
Description:
Bug 21608: WIP - attempt to fix priority dropdowns (18.05 based)
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2018-10-19 12:54:51 UTC
Size:
5.53 KB
patch
obsolete
>From 154772dd7ffb944bfc9c1e3f5e07c8314f4ea8b5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 19 Oct 2018 12:54:30 +0000 >Subject: [PATCH] Bug 21608: WIP - attempt to fix priority dropdowns (18.05 > based) > >--- > .../prog/en/modules/reserve/request.tt | 51 ++++++++++++++++++---- > reserve/request.pl | 3 +- > 2 files changed, 45 insertions(+), 9 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 91e9e5b..b948274 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -165,21 +165,57 @@ function checkMultiHold() { > }); > var prev_rank_request; > $("select[name=rank-request]").on("focus", function() { >- prev_rank_request = $(this).val(); >+ prev_rank_request = parseInt($(this).val()); >+ if( isNaN(prev_rank_request ) ){ >+ //Here we figure out how far behind the '1st' position we are >+ var first_priority_position = parseInt($('option[value="1"][selected="selected"]').closest('tr').attr('data-position')); >+ prev_rank_request = parseInt( $(this).closest('tr').attr('data-position') ) - first_priority_position+1; >+ } > }).change(function() { >- var row = $(this).parents("tr:first"); >+ if( prev_rank_request < 0 ) { >+ //If we came from a non numeric position, we need to add an option to the priority >+ var del_row = $(this).children('option:last'); >+ $("select[name='rank-request']").children('option[value="del"]').remove(); >+ var add_lowest_priority = parseInt($(this).children('option:last').val()) + 1; >+ $("select[name='rank-request']").append('<option value="'+add_lowest_priority+'">'+add_lowest_priority+'</option>').append(del_row); >+ } >+ //Go to the table row for the select >+ var row = $(this).closest("tr"); >+ //Get the value that was just set > var value = parseInt($(this).val()); >- var after = row.parent().find("tr:nth-child("+(value+1)+")"); >+ console.log(value); >+ var new_pos = parseInt(row.attr('data-position'))-(prev_rank_request-value); >+ if ( isNaN(value) ){ >+ //if we move to a non-numeric position we need to remove and option from priority >+ var del_row = $(this).children('option:last'); >+ $("select[name='rank-request']").children('option[value="del"]').remove(); >+ var remove_lowest_priority = parseInt($(this).children('option:last').val()); >+ $("select[name='rank-request']").children('option[value="'+remove_lowest_priority+'"]').remove(); >+ $("select[name='rank-request']").append(del_row); >+ new_pos = 1; >+ value = 0; >+ } >+ >+ //Find the row at position of new value plus one one by going to the first row, getting the parent object (table), then the nth tr child >+ var after = $('tr[data-position="'+new_pos+'"]'); > >- if (prev_rank_request > value) { >+ //If our value was lowered insert before the row previously at this value >+ if (prev_rank_request > value || prev_rank_request < 0) { > row.insertBefore(after); > } else { >+ //otherwise after the one prevously here > row.insertAfter(after); > } > >+ //Reset all the priorities, starting at the first row with value one > var next_priority = 1; >- $("select[name=rank-request]").each(function () { >- $(this).val(next_priority); >+ $("select[name=rank-request]").each(function (i) { >+ $(this).closest('tr').attr('data-position',i+1); >+ if( isNaN($(this).val()) ) { return true; } >+ $(this).parent('tr').attr('data-position',i+i); >+ $(this).val(next_priority) >+ $(this).find('option[selected="selected"]').attr('selected',false); >+ $(this).find('option[value="'+next_priority+'"]').attr('selected',true); > next_priority++; > }); > }); >@@ -752,7 +788,7 @@ function checkMultiHold() { > [% IF SuspendHoldsIntranet %]<th> </th><!-- Suspend Holds Column Header -->[% END %] > </tr> > [% FOREACH reserveloo IN biblioloo.reserveloop %] >- <tr> >+ <tr data-position="[% loop.count %]"> > <td> > <input type="hidden" name="reserve_id" value="[% reserveloo.reserve_id %]" /> > <input type="hidden" name="borrowernumber" value="[% reserveloo.borrowernumber %]" /> >@@ -765,7 +801,6 @@ function checkMultiHold() { > <option value="W" selected="selected">Waiting</option> > [% END %] > [% END %] >- > [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] > [% FOREACH optionloo IN reserveloo.optionloop %] > [% IF ( optionloo.selected ) %] >diff --git a/reserve/request.pl b/reserve/request.pl >index 2902de0..12d6af3 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -268,8 +268,9 @@ foreach my $biblionumber (@biblionumbers) { > } > > >+ my $totalcount = Koha::Holds->search( { biblionumber => $biblionumber , found => undef } )->count(); > my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count(); >- my $totalcount = $count; >+#my $totalcount = $count; > > # FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not > # make priorities options >-- >2.1.4
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 21608
:
80933
|
81131
|
81134
|
81272
|
81835
|
82157
|
82322
|
82652
|
82956
|
82957
|
82958
|
82959
|
83541