Lines 798-826
Link Here
|
798 |
} |
798 |
} |
799 |
}); |
799 |
}); |
800 |
var prev_rank_request; |
800 |
var prev_rank_request; |
801 |
var priorities; |
|
|
802 |
$("select[name=rank-request]").on("focus", function() { |
801 |
$("select[name=rank-request]").on("focus", function() { |
803 |
prev_rank_request = $(this).val(); |
802 |
prev_rank_request = $(this).val(); |
804 |
var row = $(this).parents("tr:first"); |
803 |
var row = $(this).parents("tr:first"); |
805 |
priorities = row.parent().find("select[name=rank-request]").map( function() { |
|
|
806 |
return $(this).val(); |
807 |
}).get(); |
808 |
}).change(function() { |
804 |
}).change(function() { |
809 |
var row = $(this).parents("tr:first"); |
805 |
var row = $(this).parents("tr:first"); |
810 |
var value = parseInt($(this).val()); |
806 |
var value = parseInt($(this).val()); |
811 |
var rowsCount = row.parent().children('tr').length - 1; |
807 |
var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found |
812 |
value = value > rowsCount ? rowsCount : value; |
808 |
if( !isNaN(value) ) { //If moved to 'del' |
813 |
var after = row.parent().find("tr:nth-child("+(value+1)+")"); |
809 |
var after = row.parent().find("tr:nth-child("+(value+1+found_holds )+")"); //Go to the row 1 after the new value (and skip found holds) |
814 |
|
810 |
if (prev_rank_request > value) { |
815 |
if (prev_rank_request > value) { |
811 |
row.insertBefore(after); |
816 |
row.insertBefore(after); |
812 |
} else { |
817 |
} else { |
813 |
row.insertAfter(after); |
818 |
row.insertAfter(after); |
814 |
} |
819 |
} |
815 |
} |
820 |
|
816 |
|
821 |
var next_priority = 0; |
817 |
var next_priority = 1; |
822 |
row.parent().find("select[name=rank-request]").each(function () { |
818 |
$("select[name=rank-request]").each(function () { |
823 |
$(this).val(priorities[next_priority]); |
819 |
if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds |
|
|
820 |
$(this).val(next_priority); |
824 |
next_priority++; |
821 |
next_priority++; |
825 |
}); |
822 |
}); |
826 |
}); |
823 |
}); |
827 |
- |
|
|