Skip to content

Commit

Permalink
SAK-48128 Tests & Questions: persist the "results per page" selected …
Browse files Browse the repository at this point in the history
…value to localStorage
  • Loading branch information
josecebe authored and Miguel Pellicer committed Nov 28, 2022
1 parent 5a004bf commit 605222b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion samigo/samigo-app/src/webapp/jsf/author/authorIndex_content.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
<script type="text/javascript" src="/samigo-app/js/sortHelper.js"></script>
<script>
$(document).ready(function() {
function getPageLength() {
const pageLength = localStorage.getItem(`samigo-pageLength-\${portal.user.id}`);
return pageLength === null ? 20 : parseInt(pageLength);
}
function setPageLength(pageLength) {
localStorage.setItem(`samigo-pageLength-\${portal.user.id}`, pageLength);
}
var notEmptyTableTd = $("#authorIndexForm\\:coreAssessments td:not(:empty)").length;
var assessmentSortingColumn = <h:outputText value="'#{author.assessmentSortingColumn}'"/>;
Expand All @@ -51,7 +61,7 @@
var table = $("#authorIndexForm\\:coreAssessments").DataTable({
"paging": true,
"lengthMenu": [[5, 10, 20, 50, 100, 200, -1], [5, 10, 20, 50, 100, 200, <h:outputText value="'#{authorFrontDoorMessages.assessment_view_all}'" />]],
"pageLength": 20,
"pageLength": getPageLength(),
"aaSorting": [[parseInt(assessmentSortingColumn), "desc"]],
"columns": [
{"bSortable": true, "bSearchable": true, "type": "span"},
Expand Down Expand Up @@ -140,6 +150,10 @@
updateRemoveButton();
});
table.on('length.dt', function (e, settings, len) {
setPageLength(len);
});
$("#authorIndexForm\\:filter-type").change(function() {
spanClassName = $(this).val();
filterBy();
Expand Down

0 comments on commit 605222b

Please sign in to comment.