Skip to content

Commit

Permalink
SAK-46113 Gradebook > Some columns don't sort properly in gradebooks …
Browse files Browse the repository at this point in the history
…with many columns (sakaiproject#9682)
  • Loading branch information
plukasew authored Aug 27, 2021
1 parent 27ee954 commit f014dc4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>

<script id="courseGradeHeaderTemplate" type="text/template">
<span class="colHeader hide">${col}</span>
<span class="colHeader hide" data-col-index="${col}">${col}</span>
<div class="relative">
<a class="gb-title">
<wicket:message key="column.header.coursegrade"/>
Expand Down Expand Up @@ -64,7 +64,7 @@
</div>
</script>
<script id="assignmentHeaderTemplate" type="text/template">
<span class="colHeader hide">${col}</span>
<span class="colHeader hide" data-col-index="${col}">${col}</span>
<div class="relative">
{if extraCredit}
<span class="gb-flag-extra-credit" wicket:message="title:label.gradeitem.extracredit"></span>
Expand Down Expand Up @@ -159,7 +159,7 @@
</div>
</script>
<script id="categoryScoreHeaderTemplate" type="text/template">
<span class="colHeader hide">${col}</span>
<span class="colHeader hide" data-col-index="${col}">${col}</span>
<div class="relative">
{if extraCredit}
<span class="gb-flag-extra-credit" wicket:message="title:label.gradeitem.extracreditcategory"></span>
Expand Down Expand Up @@ -206,7 +206,7 @@
</script>
<script id="studentHeaderTemplate" type="text/template">
<div class="relative">
<div class="colHeader">
<div class="colHeader" data-col-index="${col}">
<a class="gb-title">
<wicket:message key="column.header.students"/>
</a>
Expand All @@ -231,7 +231,7 @@
</script>
<script id="studentNumberHeaderTemplate" type="text/template">
<div class="relative">
<div class="colHeader">
<div class="colHeader" data-col-index="${col}">
<a class="gb-title">
<wicket:message key="column.header.studentNumber"/>
</a>
Expand All @@ -249,7 +249,7 @@
</script>
<script id="sectionsHeaderTemplate" type="text/template">
<div class="relative">
<div class="colHeader">
<div class="colHeader" data-col-index="${col}">
<a class="gb-title">
<wicket:message key="column.header.sections"/>
</a>
Expand Down
14 changes: 13 additions & 1 deletion gradebookng/tool/src/webapp/scripts/gradebook-gbgrade-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,19 @@ GbGradeTable.setupColumnSorting = function() {
$table.on("click", ".gb-title", function() {
var $handle = $(this);

var colIndex = $handle.closest("th").index();
let colIndex = -1;
const $colHeader = $handle.closest("th").find(".colHeader");
if ($colHeader.length > 0 && "colIndex" in $colHeader[0].dataset) {
const index = parseInt($colHeader[0].dataset.colIndex, 10);
if (!isNaN(index)) {
colIndex = index;
}
}

if (colIndex < 0) {
log.error("Unable to find column index for sorting.");
return;
}

if (GbGradeTable.currentSortColumn != colIndex) {
GbGradeTable.currentSortColumn = colIndex;
Expand Down

0 comments on commit f014dc4

Please sign in to comment.