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

(-)a/admin/columns_settings.yml (+2 lines)
Lines 1012-1017 modules: Link Here
1012
1012
1013
    saved-sql:
1013
    saved-sql:
1014
      table_reports:
1014
      table_reports:
1015
        default_display_length: 20
1016
        default_sort_order: 0
1015
        columns:
1017
        columns:
1016
            -
1018
            -
1017
              columnname: selection
1019
              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 373-379 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
373
('NovelistSelectView','tab','tab|above|below|right','Where to display Novelist Select content','Choice'),
373
('NovelistSelectView','tab','tab|above|below|right','Where to display Novelist Select content','Choice'),
374
('NumberOfSuggestionDays','',NULL,'Number of days that will be used to determine the MaxTotalSuggestions limit','Free'),
374
('NumberOfSuggestionDays','',NULL,'Number of days that will be used to determine the MaxTotalSuggestions limit','Free'),
375
('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'),
375
('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'),
376
('NumSavedReports', '20', NULL, 'By default, show this number of saved reports.', 'Integer'),
377
('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
376
('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'),
378
('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff interface search results','YesNo'),
377
('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff interface search results','YesNo'),
379
('numSearchRSSResults','50',NULL,'Specify the maximum number of results to display on a RSS page of results','Integer'),
378
('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 1592-1644 Link Here
1592
            }
1592
            }
1593
        }
1593
        }
1594
1594
1595
        /**
1596
         * Process the value of the NumSavedReports system preference for use as
1597
            a DataTable pageLenth option
1598
         * @param {string} pageLength - The value of the NumSavedReports system
1599
            preference, passed via the template during table initiation
1600
         * @return {number} - The number of results to show by default in the
1601
            DataTable (-1 for "all")
1602
         */
1603
        function getPageLength( pageLength ){
1604
            if( pageLength !== "" ){
1605
                if( Number( pageLength ) > 0 ){
1606
                    return Number( pageLength );
1607
                } else {
1608
                    return 20; /* Negative or non-numeric value passed. Use default 20 */
1609
                }
1610
            } else {
1611
                return -1;
1612
            }
1613
        }
1614
1615
        /**
1616
         * Rebuild the DataTable's lengthMenu array, adding the value of the NumSavedReports
1617
            system preference
1618
         * @param {string} pageLength - The value of the NumSavedReports system
1619
            preference, passed via the template during table initiation
1620
         * @return {Array} - An array of two arrays: 1. The numeric values for
1621
            options in the pageLenth <select>; 2. The text values for options in
1622
            the pageLength <select>;
1623
         */
1624
        function buildLengthMenu( num ){
1625
            var lengthMenu = dataTablesDefaults.lengthMenu;
1626
            var pageLength = getPageLength( num );
1627
            if( !lengthMenu[0].includes( pageLength ) ){
1628
                /* extend lengthMenu with custom value */
1629
                lengthMenu.forEach( function( item ){
1630
                    item.pop(); /* Remove the last entry, "all" */
1631
                    item.push( Number( pageLength ) ); /* Add the value from NumSavedReports */
1632
                    item.sort(function( a, b ){ /* Re-sort the values */
1633
                        return a - b;
1634
                    });
1635
                });
1636
                lengthMenu[0].push(-1); /* Add the numeric "all" option */
1637
                lengthMenu[1].push( _("All") ); /* Add the textual "all" option */
1638
            }
1639
            return lengthMenu;
1640
        }
1641
1642
        $(document).ready(function(){
1595
        $(document).ready(function(){
1643
1596
1644
            var activeTab = localStorage.getItem("sql_reports_activetab");
1597
            var activeTab = localStorage.getItem("sql_reports_activetab");
Lines 1763-1769 Link Here
1763
            [% END %]
1716
            [% END %]
1764
1717
1765
            $('[data-toggle="tooltip"]').tooltip();
1718
            $('[data-toggle="tooltip"]').tooltip();
1766
            var columns_settings = [% TablesSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1767
1719
1768
            $('#limit').change(function() {
1720
            $('#limit').change(function() {
1769
                $('#limitselect').submit();
1721
                $('#limitselect').submit();
Lines 1813-1828 Link Here
1813
            });
1765
            });
1814
1766
1815
            [% IF (saved1) %]
1767
            [% IF (saved1) %]
1768
                var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1816
                var rtable = KohaTable("table_reports", {
1769
                var rtable = KohaTable("table_reports", {
1817
                    "pageLength": getPageLength( "[% Koha.Preference('NumSavedReports') | html %]" ),
1818
                    "lengthMenu": buildLengthMenu( "[% Koha.Preference('NumSavedReports') | html %]" ),
1819
                    'bAutoWidth': false,
1770
                    'bAutoWidth': false,
1820
                    'sPaginationType': 'full',
1771
                    'sPaginationType': 'full',
1821
                    'aaSorting': [[ 1, "asc" ]],
1772
                    'aaSorting': [[ 1, "asc" ]],
1822
                    'oLanguage': {
1773
                    'oLanguage': {
1823
                        'sZeroRecords': _("No matching reports found")
1774
                        'sZeroRecords': _("No matching reports found")
1824
                    }
1775
                    }
1825
                }, columns_settings);
1776
                }, table_settings);
1826
1777
1827
                var rtabs = $("#tabs").tabs({
1778
                var rtabs = $("#tabs").tabs({
1828
                    create: function( e, ui ){
1779
                    create: function( e, ui ){
1829
- 

Return to bug 29648