Lines 165-185
function checkMultiHold() {
Link Here
|
165 |
}); |
165 |
}); |
166 |
var prev_rank_request; |
166 |
var prev_rank_request; |
167 |
$("select[name=rank-request]").on("focus", function() { |
167 |
$("select[name=rank-request]").on("focus", function() { |
168 |
prev_rank_request = $(this).val(); |
168 |
prev_rank_request = parseInt($(this).val()); |
|
|
169 |
if( isNaN(prev_rank_request ) ){ |
170 |
//Here we figure out how far behind the '1st' position we are |
171 |
var first_priority_position = parseInt($('option[value="1"][selected="selected"]').closest('tr').attr('data-position')); |
172 |
prev_rank_request = parseInt( $(this).closest('tr').attr('data-position') ) - first_priority_position+1; |
173 |
} |
169 |
}).change(function() { |
174 |
}).change(function() { |
170 |
var row = $(this).parents("tr:first"); |
175 |
if( prev_rank_request < 0 ) { |
|
|
176 |
//If we came from a non numeric position, we need to add an option to the priority |
177 |
var del_row = $(this).children('option:last'); |
178 |
$("select[name='rank-request']").children('option[value="del"]').remove(); |
179 |
var add_lowest_priority = parseInt($(this).children('option:last').val()) + 1; |
180 |
$("select[name='rank-request']").append('<option value="'+add_lowest_priority+'">'+add_lowest_priority+'</option>').append(del_row); |
181 |
} |
182 |
//Go to the table row for the select |
183 |
var row = $(this).closest("tr"); |
184 |
//Get the value that was just set |
171 |
var value = parseInt($(this).val()); |
185 |
var value = parseInt($(this).val()); |
172 |
var after = row.parent().find("tr:nth-child("+(value+1)+")"); |
186 |
console.log(value); |
|
|
187 |
var new_pos = parseInt(row.attr('data-position'))-(prev_rank_request-value); |
188 |
if ( isNaN(value) ){ |
189 |
//if we move to a non-numeric position we need to remove and option from priority |
190 |
var del_row = $(this).children('option:last'); |
191 |
$("select[name='rank-request']").children('option[value="del"]').remove(); |
192 |
var remove_lowest_priority = parseInt($(this).children('option:last').val()); |
193 |
$("select[name='rank-request']").children('option[value="'+remove_lowest_priority+'"]').remove(); |
194 |
$("select[name='rank-request']").append(del_row); |
195 |
new_pos = 1; |
196 |
value = 0; |
197 |
} |
198 |
|
199 |
//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 |
200 |
var after = $('tr[data-position="'+new_pos+'"]'); |
173 |
|
201 |
|
174 |
if (prev_rank_request > value) { |
202 |
//If our value was lowered insert before the row previously at this value |
|
|
203 |
if (prev_rank_request > value || prev_rank_request < 0) { |
175 |
row.insertBefore(after); |
204 |
row.insertBefore(after); |
176 |
} else { |
205 |
} else { |
|
|
206 |
//otherwise after the one prevously here |
177 |
row.insertAfter(after); |
207 |
row.insertAfter(after); |
178 |
} |
208 |
} |
179 |
|
209 |
|
|
|
210 |
//Reset all the priorities, starting at the first row with value one |
180 |
var next_priority = 1; |
211 |
var next_priority = 1; |
181 |
$("select[name=rank-request]").each(function () { |
212 |
$("select[name=rank-request]").each(function (i) { |
182 |
$(this).val(next_priority); |
213 |
$(this).closest('tr').attr('data-position',i+1); |
|
|
214 |
if( isNaN($(this).val()) ) { return true; } |
215 |
$(this).parent('tr').attr('data-position',i+i); |
216 |
$(this).val(next_priority) |
217 |
$(this).find('option[selected="selected"]').attr('selected',false); |
218 |
$(this).find('option[value="'+next_priority+'"]').attr('selected',true); |
183 |
next_priority++; |
219 |
next_priority++; |
184 |
}); |
220 |
}); |
185 |
}); |
221 |
}); |
Lines 752-758
function checkMultiHold() {
Link Here
|
752 |
[% IF SuspendHoldsIntranet %]<th> </th><!-- Suspend Holds Column Header -->[% END %] |
788 |
[% IF SuspendHoldsIntranet %]<th> </th><!-- Suspend Holds Column Header -->[% END %] |
753 |
</tr> |
789 |
</tr> |
754 |
[% FOREACH reserveloo IN biblioloo.reserveloop %] |
790 |
[% FOREACH reserveloo IN biblioloo.reserveloop %] |
755 |
<tr> |
791 |
<tr data-position="[% loop.count %]"> |
756 |
<td> |
792 |
<td> |
757 |
<input type="hidden" name="reserve_id" value="[% reserveloo.reserve_id %]" /> |
793 |
<input type="hidden" name="reserve_id" value="[% reserveloo.reserve_id %]" /> |
758 |
<input type="hidden" name="borrowernumber" value="[% reserveloo.borrowernumber %]" /> |
794 |
<input type="hidden" name="borrowernumber" value="[% reserveloo.borrowernumber %]" /> |
Lines 765-771
function checkMultiHold() {
Link Here
|
765 |
<option value="W" selected="selected">Waiting</option> |
801 |
<option value="W" selected="selected">Waiting</option> |
766 |
[% END %] |
802 |
[% END %] |
767 |
[% END %] |
803 |
[% END %] |
768 |
|
|
|
769 |
[% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] |
804 |
[% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] |
770 |
[% FOREACH optionloo IN reserveloo.optionloop %] |
805 |
[% FOREACH optionloo IN reserveloo.optionloop %] |
771 |
[% IF ( optionloo.selected ) %] |
806 |
[% IF ( optionloo.selected ) %] |