Bugzilla – Attachment 127965 Details for
Bug 29530
When NumSavedReports is set, show value in pull down of entries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29530: Fix handling of NumSavedReports preference in reports table
Bug-29530-Fix-handling-of-NumSavedReports-preferen.patch (text/plain), 5.56 KB, created by
Owen Leonard
on 2021-11-23 18:58:32 UTC
(
hide
)
Description:
Bug 29530: Fix handling of NumSavedReports preference in reports table
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2021-11-23 18:58:32 UTC
Size:
5.56 KB
patch
obsolete
>From 53df0e27de20a6e5930353e79a369107c2ec0acf Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 23 Nov 2021 18:27:21 +0000 >Subject: [PATCH] Bug 29530: Fix handling of NumSavedReports preference in > reports table > >This patch updates the way the NumSavedReports preference value is used >on the saved reports page so that the setting is correctly incorporated >into the DataTable. > >The patch also expands the description of the NumSavedReports preference >in order to clarify the expected behavior when no value is saved. > >To test, apply the patch and go to Administration -> System >preferences and note the value of NumSavedReports. > > - Go to Reports -> Use saved. > - Confirm that the first page of saved reports shows the number > specified in NumSavedReports. > - In the "Show" dropdown menu, confirm that the number from > NumSavedReports is preselected by default. > - Expand the dropdown menu to confirm that the NumSavedReports number > is positioned sequentially with the default values. For example, if > NumSavedReports = "78," the menu options should be > "10, 20, 50, 78, 100, All". > - Test with various values of NumSavedReports. A blank value should > result in the "All" option being selected. A non-numeric or > non-positive value should result in the default set of options being > used ("10, 20, 50, 100, All"). >--- > .../en/modules/admin/preferences/tools.pref | 2 +- > .../modules/reports/guided_reports_start.tt | 52 ++++++++++++++++++- > 2 files changed, 51 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref >index 4a569b4cae..c77d6b06d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref >@@ -55,4 +55,4 @@ Tools: > - By default, show > - pref: NumSavedReports > class: integer >- - reports on the saved reports page. >+ - reports on the saved reports page. A value of 20 is recommended. If empty, all reports will be shown. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index 46e2bd4e07..99c1284894 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -1592,6 +1592,53 @@ > } > } > >+ /** >+ * 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 <select>; 2. The text values for options in >+ the pageLength <select>; >+ */ >+ 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"); >@@ -1767,13 +1814,14 @@ > > [% IF (saved1) %] > var rtable = KohaTable("table_reports", { >- 'iDisplayLength': [% Koha.Preference('NumSavedReports') | html %], >+ "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); > > var rtabs = $("#tabs").tabs({ >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29530
:
127965
|
128016
|
128172
|
128644