Lines 1663-1668
Link Here
|
1663 |
} |
1663 |
} |
1664 |
} |
1664 |
} |
1665 |
|
1665 |
|
|
|
1666 |
/** |
1667 |
* Process the value of the NumSavedReports system preference for use as |
1668 |
a DataTable pageLenth option |
1669 |
* @param {string} pageLength - The value of the NumSavedReports system |
1670 |
preference, passed via the template during table initiation |
1671 |
* @return {number} - The number of results to show by default in the |
1672 |
DataTable (-1 for "all") |
1673 |
*/ |
1674 |
function getPageLength( pageLength ){ |
1675 |
if( pageLength !== "" ){ |
1676 |
if( Number( pageLength ) > 0 ){ |
1677 |
return Number( pageLength ); |
1678 |
} else { |
1679 |
return 20; /* Negative or non-numeric value passed. Use default 20 */ |
1680 |
} |
1681 |
} else { |
1682 |
return -1; |
1683 |
} |
1684 |
} |
1685 |
|
1686 |
/** |
1687 |
* Rebuild the DataTable's lengthMenu array, adding the value of the NumSavedReports |
1688 |
system preference |
1689 |
* @param {string} pageLength - The value of the NumSavedReports system |
1690 |
preference, passed via the template during table initiation |
1691 |
* @return {Array} - An array of two arrays: 1. The numeric values for |
1692 |
options in the pageLenth <select>; 2. The text values for options in |
1693 |
the pageLength <select>; |
1694 |
*/ |
1695 |
function buildLengthMenu( num ){ |
1696 |
var lengthMenu = dataTablesDefaults.lengthMenu; |
1697 |
var pageLength = getPageLength( num ); |
1698 |
if( !lengthMenu[0].includes( pageLength ) ){ |
1699 |
/* extend lengthMenu with custom value */ |
1700 |
lengthMenu.forEach( function( item ){ |
1701 |
item.pop(); /* Remove the last entry, "all" */ |
1702 |
item.push( Number( pageLength ) ); /* Add the value from NumSavedReports */ |
1703 |
item.sort(function( a, b ){ /* Re-sort the values */ |
1704 |
return a - b; |
1705 |
}); |
1706 |
}); |
1707 |
lengthMenu[0].push(-1); /* Add the numeric "all" option */ |
1708 |
lengthMenu[1].push( _("All") ); /* Add the textual "all" option */ |
1709 |
} |
1710 |
return lengthMenu; |
1711 |
} |
1712 |
|
1666 |
$(document).ready(function(){ |
1713 |
$(document).ready(function(){ |
1667 |
|
1714 |
|
1668 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
1715 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
Lines 1838-1850
Link Here
|
1838 |
|
1885 |
|
1839 |
[% IF (saved1) %] |
1886 |
[% IF (saved1) %] |
1840 |
var rtable = KohaTable("table_reports", { |
1887 |
var rtable = KohaTable("table_reports", { |
1841 |
'pageLength': [% Koha.Preference('NumSavedReports') | html %], |
1888 |
"pageLength": getPageLength( "[% Koha.Preference('NumSavedReports') | html %]" ), |
|
|
1889 |
"lengthMenu": buildLengthMenu( "[% Koha.Preference('NumSavedReports') | html %]" ), |
1842 |
'bAutoWidth': false, |
1890 |
'bAutoWidth': false, |
1843 |
'sPaginationType': 'full', |
1891 |
'sPaginationType': 'full', |
1844 |
'aaSorting': [[ 1, "asc" ]], |
1892 |
'aaSorting': [[ 1, "asc" ]], |
1845 |
'oLanguage': { |
1893 |
'oLanguage': { |
1846 |
'sZeroRecords': _("No matching reports found") |
1894 |
'sZeroRecords': _("No matching reports found") |
1847 |
}, |
1895 |
} |
1848 |
}, columns_settings); |
1896 |
}, columns_settings); |
1849 |
|
1897 |
|
1850 |
var rtabs = $("#tabs").tabs({ |
1898 |
var rtabs = $("#tabs").tabs({ |
1851 |
- |
|
|