@@ -, +, @@ --- admin/columns_settings.yml | 2 + .../data/mysql/atomicupdate/bug_29648.pl | 23 ++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../prog/en/includes/columns_settings.inc | 4 +- .../modules/reports/guided_reports_start.tt | 53 +------------------ 5 files changed, 29 insertions(+), 54 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29648.pl --- a/admin/columns_settings.yml +++ a/admin/columns_settings.yml @@ -1055,6 +1055,8 @@ modules: saved-sql: table_reports: + default_display_length: 20 + default_sort_order: 0 columns: - columnname: selection --- a/installer/data/mysql/atomicupdate/bug_29648.pl +++ a/installer/data/mysql/atomicupdate/bug_29648.pl @@ -0,0 +1,23 @@ +use Modern::Perl; + +return { + bug_number => "29648", + description => "Move NumSavedReports to table settings", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + my $NumSavedReports = C4::Context->preference('NumSavedReports'); + $dbh->do(q{ + DELETE FROM systempreferences + WHERE variable="NumSavedReports" + }); + + if ( $NumSavedReports ) { + $dbh->do(q{ + INSERT IGNORE INTO tables_settings (module, page, tablename, default_display_length, default_sort_order) + VALUES('reports', 'saved-sql', 'table_reports', ?, 1) + }, undef, $NumSavedReports); + } + }, +} --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/installer/data/mysql/mandatory/sysprefs.sql @@ -378,7 +378,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('NovelistSelectView','tab','tab|above|below|right','Where to display Novelist Select content','Choice'), ('NumberOfSuggestionDays','',NULL,'Number of days that will be used to determine the MaxTotalSuggestions limit','Free'), ('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'), -('NumSavedReports', '20', NULL, 'By default, show this number of saved reports.', 'Integer'), ('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'), ('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff interface search results','YesNo'), ('numSearchRSSResults','50',NULL,'Specify the maximum number of results to display on a RSS page of results','Integer'), --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -184,10 +184,10 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { }); } - if ( table_settings.hasOwnProperty('default_display_length') ) { + if ( table_settings.hasOwnProperty('default_display_length') && table_settings['default_display_length'] != null ) { new_parameters["pageLength"] = table_settings['default_display_length']; } - if ( table_settings.hasOwnProperty('default_sort_order') ) { + if ( table_settings.hasOwnProperty('default_sort_order') && table_settings['default_sort_order'] != null ) { new_parameters["order"] = [[ table_settings['default_sort_order'], 'asc' ]]; } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -1680,53 +1680,6 @@ } } - /** - * Process the value of the NumSavedReports system preference for use as - a DataTable pageLenth option - * @param {string} pageLength - The value of the NumSavedReports system - preference, passed via the template during table initiation - * @return {number} - The number of results to show by default in the - DataTable (-1 for "all") - */ - function getPageLength( pageLength ){ - if( pageLength !== "" ){ - if( Number( pageLength ) > 0 ){ - return Number( pageLength ); - } else { - return 20; /* Negative or non-numeric value passed. Use default 20 */ - } - } else { - return -1; - } - } - - /** - * Rebuild the DataTable's lengthMenu array, adding the value of the NumSavedReports - system preference - * @param {string} pageLength - The value of the NumSavedReports system - preference, passed via the template during table initiation - * @return {Array} - An array of two arrays: 1. The numeric values for - options in the pageLenth ; - */ - function buildLengthMenu( num ){ - var lengthMenu = dataTablesDefaults.lengthMenu; - var pageLength = getPageLength( num ); - if( !lengthMenu[0].includes( pageLength ) ){ - /* extend lengthMenu with custom value */ - lengthMenu.forEach( function( item ){ - item.pop(); /* Remove the last entry, "all" */ - item.push( Number( pageLength ) ); /* Add the value from NumSavedReports */ - item.sort(function( a, b ){ /* Re-sort the values */ - return a - b; - }); - }); - lengthMenu[0].push(-1); /* Add the numeric "all" option */ - lengthMenu[1].push( _("All") ); /* Add the textual "all" option */ - } - return lengthMenu; - } - $(document).ready(function(){ var activeTab = localStorage.getItem("sql_reports_activetab"); @@ -1851,7 +1804,6 @@ [% END %] $('[data-toggle="tooltip"]').tooltip(); - var columns_settings = [% TablesSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %]; $('#limit').change(function() { $('#limitselect').submit(); @@ -1901,16 +1853,15 @@ }); [% IF (saved1) %] + var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %]; var rtable = KohaTable("table_reports", { - "pageLength": getPageLength( "[% Koha.Preference('NumSavedReports') | html %]" ), - "lengthMenu": buildLengthMenu( "[% Koha.Preference('NumSavedReports') | html %]" ), 'bAutoWidth': false, 'sPaginationType': 'full', 'aaSorting': [[ 1, "asc" ]], 'oLanguage': { 'sZeroRecords': _("No matching reports found") } - }, columns_settings); + }, table_settings); var rtabs = $("#tabs").tabs({ create: function( e, ui ){ --