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

(-)a/admin/columns_settings.yml (+2 lines)
Lines 1027-1032 modules: Link Here
1027
1027
1028
    saved-sql:
1028
    saved-sql:
1029
      table_reports:
1029
      table_reports:
1030
        default_display_length: 20
1031
        default_sort_order: 0
1030
        columns:
1032
        columns:
1031
            -
1033
            -
1032
              columnname: selection
1034
              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 374-380 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
374
('NovelistSelectView','tab','tab|above|below|right','Where to display Novelist Select content','Choice'),
374
('NovelistSelectView','tab','tab|above|below|right','Where to display Novelist Select content','Choice'),
375
('NumberOfSuggestionDays','',NULL,'Number of days that will be used to determine the MaxTotalSuggestions limit','Free'),
375
('NumberOfSuggestionDays','',NULL,'Number of days that will be used to determine the MaxTotalSuggestions limit','Free'),
376
('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'),
376
('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'),
377
('NumSavedReports', '20', NULL, 'By default, show this number of saved reports.', 'Integer'),
378
('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
377
('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
379
('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff interface search results','YesNo'),
378
('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff interface search results','YesNo'),
380
('numSearchRSSResults','50',NULL,'Specify the maximum number of results to display on a RSS page of results','Integer'),
379
('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 146-155 function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { Link Here
146
        });
146
        });
147
    }
147
    }
148
148
149
    if ( table_settings.hasOwnProperty('default_display_length') ) {
149
    if ( table_settings.hasOwnProperty('default_display_length') && table_settings['default_display_length'] != null ) {
150
        new_parameters["pageLength"] = table_settings['default_display_length'];
150
        new_parameters["pageLength"] = table_settings['default_display_length'];
151
    }
151
    }
152
    if ( table_settings.hasOwnProperty('default_sort_order') ) {
152
    if ( table_settings.hasOwnProperty('default_sort_order') && table_settings['default_sort_order'] != null ) {
153
        new_parameters["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
153
        new_parameters["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
154
    }
154
    }
155
155
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-52 / +2 lines)
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
- 

Return to bug 29648