Lines 1592-1597
Link Here
|
1592 |
} |
1592 |
} |
1593 |
} |
1593 |
} |
1594 |
|
1594 |
|
|
|
1595 |
/** |
1596 |
* Process the value of the NumSavedReports system preference for use as |
1597 |
a DataTable pageLenth option |
1598 |
* @param {string} pageLength - The value of the NumSavedReports system |
1599 |
preference, passed via the template during table initiation |
1600 |
* @return {number} - The number of results to show by default in the |
1601 |
DataTable (-1 for "all") |
1602 |
*/ |
1603 |
function getPageLength( pageLength ){ |
1604 |
if( pageLength !== "" ){ |
1605 |
if( Number( pageLength ) > 0 ){ |
1606 |
return Number( pageLength ); |
1607 |
} else { |
1608 |
return 20; /* Negative or non-numeric value passed. Use default 20 */ |
1609 |
} |
1610 |
} else { |
1611 |
return -1; |
1612 |
} |
1613 |
} |
1614 |
|
1615 |
/** |
1616 |
* Rebuild the DataTable's lengthMenu array, adding the value of the NumSavedReports |
1617 |
system preference |
1618 |
* @param {string} pageLength - The value of the NumSavedReports system |
1619 |
preference, passed via the template during table initiation |
1620 |
* @return {Array} - An array of two arrays: 1. The numeric values for |
1621 |
options in the pageLenth <select>; 2. The text values for options in |
1622 |
the pageLength <select>; |
1623 |
*/ |
1624 |
function buildLengthMenu( num ){ |
1625 |
var lengthMenu = dataTablesDefaults.lengthMenu; |
1626 |
var pageLength = getPageLength( num ); |
1627 |
if( !lengthMenu[0].includes( pageLength ) ){ |
1628 |
/* extend lengthMenu with custom value */ |
1629 |
lengthMenu.forEach( function( item ){ |
1630 |
item.pop(); /* Remove the last entry, "all" */ |
1631 |
item.push( Number( pageLength ) ); /* Add the value from NumSavedReports */ |
1632 |
item.sort(function( a, b ){ /* Re-sort the values */ |
1633 |
return a - b; |
1634 |
}); |
1635 |
}); |
1636 |
lengthMenu[0].push(-1); /* Add the numeric "all" option */ |
1637 |
lengthMenu[1].push( _("All") ); /* Add the textual "all" option */ |
1638 |
} |
1639 |
return lengthMenu; |
1640 |
} |
1641 |
|
1595 |
$(document).ready(function(){ |
1642 |
$(document).ready(function(){ |
1596 |
|
1643 |
|
1597 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
1644 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
Lines 1767-1779
Link Here
|
1767 |
|
1814 |
|
1768 |
[% IF (saved1) %] |
1815 |
[% IF (saved1) %] |
1769 |
var rtable = KohaTable("table_reports", { |
1816 |
var rtable = KohaTable("table_reports", { |
1770 |
'iDisplayLength': [% Koha.Preference('NumSavedReports') | html %], |
1817 |
"pageLength": getPageLength( "[% Koha.Preference('NumSavedReports') | html %]" ), |
|
|
1818 |
"lengthMenu": buildLengthMenu( "[% Koha.Preference('NumSavedReports') | html %]" ), |
1771 |
'bAutoWidth': false, |
1819 |
'bAutoWidth': false, |
1772 |
'sPaginationType': 'full', |
1820 |
'sPaginationType': 'full', |
1773 |
'aaSorting': [[ 1, "asc" ]], |
1821 |
'aaSorting': [[ 1, "asc" ]], |
1774 |
'oLanguage': { |
1822 |
'oLanguage': { |
1775 |
'sZeroRecords': _("No matching reports found") |
1823 |
'sZeroRecords': _("No matching reports found") |
1776 |
}, |
1824 |
} |
1777 |
}, columns_settings); |
1825 |
}, columns_settings); |
1778 |
|
1826 |
|
1779 |
var rtabs = $("#tabs").tabs({ |
1827 |
var rtabs = $("#tabs").tabs({ |
1780 |
- |
|
|