Lines 1756-1782
Link Here
|
1756 |
}); |
1756 |
}); |
1757 |
var prev_rank_request; |
1757 |
var prev_rank_request; |
1758 |
$("select[name=rank-request]").on("focus", function() { |
1758 |
$("select[name=rank-request]").on("focus", function() { |
1759 |
prev_rank_request = $(this).val(); |
1759 |
prev_rank_request = parseInt($(this).val()); |
1760 |
var row = $(this).parents("tr:first"); |
|
|
1761 |
}).change(function() { |
1760 |
}).change(function() { |
1762 |
var row = $(this).parents("tr:first"); |
1761 |
var this_rank = $(this); |
1763 |
var value = parseInt($(this).val()); |
1762 |
var new_rank = parseInt(this_rank.val()); |
1764 |
var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found |
1763 |
var old_rank = prev_rank_request; |
1765 |
if( !isNaN(value) ) { //If moved to 'del' |
1764 |
|
1766 |
var after = row.parent().find(`tr:nth-child(${value+found_holds})`); //Go to the row 1 after the new value (and skip found holds) |
1765 |
//if new_rank is NaN, bail |
1767 |
if (prev_rank_request > value) { |
1766 |
if ( isNaN( new_rank ) ) return; |
1768 |
row.insertBefore(after); |
1767 |
|
1769 |
} else { |
1768 |
if ( isNaN( old_rank ) ) { |
1770 |
row.insertAfter(after); |
1769 |
$("select[name=rank-request]").not('[disabled]').not(this_rank).each(function() { |
1771 |
} |
1770 |
var current_rank = parseInt($(this).val()); |
|
|
1771 |
if ( !isNaN(current_rank) && current_rank >= new_rank ) { |
1772 |
$(this).val(current_rank + 1); |
1773 |
} |
1774 |
}); |
1775 |
prev_rank_request = new_rank; |
1776 |
return; |
1772 |
} |
1777 |
} |
1773 |
|
1778 |
|
1774 |
var next_priority = 1; |
1779 |
if ( new_rank === old_rank ) return; |
1775 |
$("select[name=rank-request]").each(function () { |
1780 |
|
1776 |
if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds |
1781 |
// Adjust ranks |
1777 |
$(this).val(next_priority); |
1782 |
$("select[name=rank-request]").not('[disabled]').not(this).each(function() { |
1778 |
next_priority++; |
1783 |
var current_rank = parseInt($(this).val()); |
|
|
1784 |
//if current_rank is NaN, bail |
1785 |
if ( isNaN( current_rank ) ) return; |
1786 |
|
1787 |
if ( old_rank > new_rank ) { |
1788 |
if ( current_rank >= new_rank && current_rank < old_rank ) { |
1789 |
$(this).val(current_rank + 1); |
1790 |
} |
1791 |
} else { |
1792 |
if ( current_rank > old_rank && current_rank <= new_rank ) { |
1793 |
$(this).val(current_rank - 1); |
1794 |
} |
1795 |
} |
1779 |
}); |
1796 |
}); |
|
|
1797 |
|
1798 |
prev_rank_request = new_rank; |
1780 |
}); |
1799 |
}); |
1781 |
|
1800 |
|
1782 |
$(".clear-date").on("click",function(e){ |
1801 |
$(".clear-date").on("click",function(e){ |
1783 |
- |
|
|