|
Lines 1663-1715
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 |
|
| 1713 |
$(document).ready(function(){ |
1666 |
$(document).ready(function(){ |
| 1714 |
|
1667 |
|
| 1715 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
1668 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
|
Lines 1834-1840
Link Here
|
| 1834 |
[% END %] |
1787 |
[% END %] |
| 1835 |
|
1788 |
|
| 1836 |
$('[data-toggle="tooltip"]').tooltip(); |
1789 |
$('[data-toggle="tooltip"]').tooltip(); |
| 1837 |
var columns_settings = [% TablesSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %]; |
|
|
| 1838 |
|
1790 |
|
| 1839 |
$('#limit').change(function() { |
1791 |
$('#limit').change(function() { |
| 1840 |
$('#limitselect').submit(); |
1792 |
$('#limitselect').submit(); |
|
Lines 1884-1899
Link Here
|
| 1884 |
}); |
1836 |
}); |
| 1885 |
|
1837 |
|
| 1886 |
[% IF (saved1) %] |
1838 |
[% IF (saved1) %] |
|
|
1839 |
var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %]; |
| 1887 |
var rtable = KohaTable("table_reports", { |
1840 |
var rtable = KohaTable("table_reports", { |
| 1888 |
"pageLength": getPageLength( "[% Koha.Preference('NumSavedReports') | html %]" ), |
|
|
| 1889 |
"lengthMenu": buildLengthMenu( "[% Koha.Preference('NumSavedReports') | html %]" ), |
| 1890 |
'bAutoWidth': false, |
1841 |
'bAutoWidth': false, |
| 1891 |
'sPaginationType': 'full', |
1842 |
'sPaginationType': 'full', |
| 1892 |
'aaSorting': [[ 1, "asc" ]], |
1843 |
'aaSorting': [[ 1, "asc" ]], |
| 1893 |
'oLanguage': { |
1844 |
'oLanguage': { |
| 1894 |
'sZeroRecords': _("No matching reports found") |
1845 |
'sZeroRecords': _("No matching reports found") |
| 1895 |
} |
1846 |
} |
| 1896 |
}, columns_settings); |
1847 |
}, table_settings); |
| 1897 |
|
1848 |
|
| 1898 |
var rtabs = $("#tabs").tabs({ |
1849 |
var rtabs = $("#tabs").tabs({ |
| 1899 |
create: function( e, ui ){ |
1850 |
create: function( e, ui ){ |
| 1900 |
- |
|
|