|
Lines 1680-1732
Link Here
|
| 1680 |
} |
1680 |
} |
| 1681 |
} |
1681 |
} |
| 1682 |
|
1682 |
|
| 1683 |
/** |
|
|
| 1684 |
* Process the value of the NumSavedReports system preference for use as |
| 1685 |
a DataTable pageLenth option |
| 1686 |
* @param {string} pageLength - The value of the NumSavedReports system |
| 1687 |
preference, passed via the template during table initiation |
| 1688 |
* @return {number} - The number of results to show by default in the |
| 1689 |
DataTable (-1 for "all") |
| 1690 |
*/ |
| 1691 |
function getPageLength( pageLength ){ |
| 1692 |
if( pageLength !== "" ){ |
| 1693 |
if( Number( pageLength ) > 0 ){ |
| 1694 |
return Number( pageLength ); |
| 1695 |
} else { |
| 1696 |
return 20; /* Negative or non-numeric value passed. Use default 20 */ |
| 1697 |
} |
| 1698 |
} else { |
| 1699 |
return -1; |
| 1700 |
} |
| 1701 |
} |
| 1702 |
|
| 1703 |
/** |
| 1704 |
* Rebuild the DataTable's lengthMenu array, adding the value of the NumSavedReports |
| 1705 |
system preference |
| 1706 |
* @param {string} pageLength - The value of the NumSavedReports system |
| 1707 |
preference, passed via the template during table initiation |
| 1708 |
* @return {Array} - An array of two arrays: 1. The numeric values for |
| 1709 |
options in the pageLenth <select>; 2. The text values for options in |
| 1710 |
the pageLength <select>; |
| 1711 |
*/ |
| 1712 |
function buildLengthMenu( num ){ |
| 1713 |
var lengthMenu = dataTablesDefaults.lengthMenu; |
| 1714 |
var pageLength = getPageLength( num ); |
| 1715 |
if( !lengthMenu[0].includes( pageLength ) ){ |
| 1716 |
/* extend lengthMenu with custom value */ |
| 1717 |
lengthMenu.forEach( function( item ){ |
| 1718 |
item.pop(); /* Remove the last entry, "all" */ |
| 1719 |
item.push( Number( pageLength ) ); /* Add the value from NumSavedReports */ |
| 1720 |
item.sort(function( a, b ){ /* Re-sort the values */ |
| 1721 |
return a - b; |
| 1722 |
}); |
| 1723 |
}); |
| 1724 |
lengthMenu[0].push(-1); /* Add the numeric "all" option */ |
| 1725 |
lengthMenu[1].push( _("All") ); /* Add the textual "all" option */ |
| 1726 |
} |
| 1727 |
return lengthMenu; |
| 1728 |
} |
| 1729 |
|
| 1730 |
$(document).ready(function(){ |
1683 |
$(document).ready(function(){ |
| 1731 |
|
1684 |
|
| 1732 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
1685 |
var activeTab = localStorage.getItem("sql_reports_activetab"); |
|
Lines 1851-1857
Link Here
|
| 1851 |
[% END %] |
1804 |
[% END %] |
| 1852 |
|
1805 |
|
| 1853 |
$('[data-toggle="tooltip"]').tooltip(); |
1806 |
$('[data-toggle="tooltip"]').tooltip(); |
| 1854 |
var columns_settings = [% TablesSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %]; |
|
|
| 1855 |
|
1807 |
|
| 1856 |
$('#limit').change(function() { |
1808 |
$('#limit').change(function() { |
| 1857 |
$('#limitselect').submit(); |
1809 |
$('#limitselect').submit(); |
|
Lines 1901-1916
Link Here
|
| 1901 |
}); |
1853 |
}); |
| 1902 |
|
1854 |
|
| 1903 |
[% IF (saved1) %] |
1855 |
[% IF (saved1) %] |
|
|
1856 |
var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %]; |
| 1904 |
var rtable = KohaTable("table_reports", { |
1857 |
var rtable = KohaTable("table_reports", { |
| 1905 |
"pageLength": getPageLength( "[% Koha.Preference('NumSavedReports') | html %]" ), |
|
|
| 1906 |
"lengthMenu": buildLengthMenu( "[% Koha.Preference('NumSavedReports') | html %]" ), |
| 1907 |
'bAutoWidth': false, |
1858 |
'bAutoWidth': false, |
| 1908 |
'sPaginationType': 'full', |
1859 |
'sPaginationType': 'full', |
| 1909 |
'aaSorting': [[ 1, "asc" ]], |
1860 |
'aaSorting': [[ 1, "asc" ]], |
| 1910 |
'oLanguage': { |
1861 |
'oLanguage': { |
| 1911 |
'sZeroRecords': _("No matching reports found") |
1862 |
'sZeroRecords': _("No matching reports found") |
| 1912 |
} |
1863 |
} |
| 1913 |
}, columns_settings); |
1864 |
}, table_settings); |
| 1914 |
|
1865 |
|
| 1915 |
var rtabs = $("#tabs").tabs({ |
1866 |
var rtabs = $("#tabs").tabs({ |
| 1916 |
create: function( e, ui ){ |
1867 |
create: function( e, ui ){ |
| 1917 |
- |
|
|