View | Details | Raw Unified | Return to bug 29648
Collapse All | Expand All

(-)a/admin/columns_settings.yml (+2 lines)
Lines 1055-1060 modules: Link Here
1055
1055
1056
    saved-sql:
1056
    saved-sql:
1057
      table_reports:
1057
      table_reports:
1058
        default_display_length: 20
1059
        default_sort_order: 0
1058
        columns:
1060
        columns:
1059
            -
1061
            -
1060
              columnname: selection
1062
              columnname: selection
(-)a/installer/data/mysql/atomicupdate/bug_29648.pl (+23 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "29648",
5
    description => "Move NumSavedReports to table settings",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        my $NumSavedReports = C4::Context->preference('NumSavedReports');
11
        $dbh->do(q{
12
            DELETE FROM systempreferences
13
            WHERE variable="NumSavedReports"
14
        });
15
16
        if ( $NumSavedReports ) {
17
            $dbh->do(q{
18
                INSERT IGNORE INTO tables_settings (module, page, tablename, default_display_length, default_sort_order)
19
                VALUES('reports', 'saved-sql', 'table_reports', ?, 1)
20
            }, undef, $NumSavedReports);
21
        }
22
    },
23
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 lines)
Lines 378-384 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
378
('NovelistSelectView','tab','tab|above|below|right','Where to display Novelist Select content','Choice'),
378
('NovelistSelectView','tab','tab|above|below|right','Where to display Novelist Select content','Choice'),
379
('NumberOfSuggestionDays','',NULL,'Number of days that will be used to determine the MaxTotalSuggestions limit','Free'),
379
('NumberOfSuggestionDays','',NULL,'Number of days that will be used to determine the MaxTotalSuggestions limit','Free'),
380
('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'),
380
('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'),
381
('NumSavedReports', '20', NULL, 'By default, show this number of saved reports.', 'Integer'),
382
('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
381
('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
383
('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff interface search results','YesNo'),
382
('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff interface search results','YesNo'),
384
('numSearchRSSResults','50',NULL,'Specify the maximum number of results to display on a RSS page of results','Integer'),
383
('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 (-2 / +2 lines)
Lines 184-193 function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { Link Here
184
        });
184
        });
185
    }
185
    }
186
186
187
    if ( table_settings.hasOwnProperty('default_display_length') ) {
187
    if ( table_settings.hasOwnProperty('default_display_length') && table_settings['default_display_length'] != null ) {
188
        new_parameters["pageLength"] = table_settings['default_display_length'];
188
        new_parameters["pageLength"] = table_settings['default_display_length'];
189
    }
189
    }
190
    if ( table_settings.hasOwnProperty('default_sort_order') ) {
190
    if ( table_settings.hasOwnProperty('default_sort_order') && table_settings['default_sort_order'] != null ) {
191
        new_parameters["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
191
        new_parameters["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
192
    }
192
    }
193
193
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-52 / +2 lines)
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
- 

Return to bug 29648