Bugzilla – Attachment 134087 Details for
Bug 29648
Make KohaTable tables 'default length' and 'default sort' configurable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29648: Move NumSavedReports to the table settings
Bug-29648-Move-NumSavedReports-to-the-table-settin.patch (text/plain), 8.48 KB, created by
Martin Renvoize (ashimema)
on 2022-04-27 16:08:15 UTC
(
hide
)
Description:
Bug 29648: Move NumSavedReports to the table settings
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-04-27 16:08:15 UTC
Size:
8.48 KB
patch
obsolete
>From 873ebb95728394a4ef67ff988b653f9ef3b393cf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 16 Dec 2021 11:50:58 +0100 >Subject: [PATCH] Bug 29648: Move NumSavedReports to the table settings > >The syspref NumSavedReports can be moved to the table settings config >Test plan: >1. Set the syspref to a given value >2. updatedatabase # execute the atomic update >3. Go to the table settings page and confirm that the syspref's value >has been retrieved >4. Select a specific colonne for the default sort >5. Go to the report list view and confirm that the "Show X entries" has >the correct selected value and that the table is sorted as you expect. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > 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 > >diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml >index 1a91d8c6f5..f6680f92c8 100644 >--- a/admin/columns_settings.yml >+++ b/admin/columns_settings.yml >@@ -1055,6 +1055,8 @@ modules: > > saved-sql: > table_reports: >+ default_display_length: 20 >+ default_sort_order: 0 > columns: > - > columnname: selection >diff --git a/installer/data/mysql/atomicupdate/bug_29648.pl b/installer/data/mysql/atomicupdate/bug_29648.pl >new file mode 100755 >index 0000000000..35358ce795 >--- /dev/null >+++ b/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); >+ } >+ }, >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 1b029aa5ee..c6d0fd49e9 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/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'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >index 4d61b10534..8eca9c2f23 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >+++ b/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' ]]; > } > >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 675a911cfa..5cfbcae66a 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 >@@ -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 <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"); >@@ -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 ){ >-- >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 29648
:
128592
|
128593
|
128594
|
128595
|
128596
|
128597
|
128598
|
128599
|
128600
|
128601
|
128602
|
128603
|
128604
|
128605
|
128606
|
128607
|
128608
|
128609
|
128610
|
128611
|
128612
|
128613
|
128614
|
128615
|
128616
|
128617
|
128618
|
128619
|
128620
|
128621
|
128622
|
128623
|
128624
|
128625
|
128626
|
129084
|
129085
|
129089
|
129352
|
129685
|
129686
|
129770
|
129771
|
129772
|
129773
|
129774
|
129775
|
129776
|
129777
|
129778
|
129779
|
129780
|
129781
|
129782
|
129783
|
129784
|
129785
|
129786
|
129787
|
129788
|
129789
|
129790
|
129791
|
129792
|
129793
|
129794
|
129795
|
129796
|
129797
|
129798
|
129799
|
129800
|
129801
|
129802
|
129803
|
129804
|
129805
|
129806
|
131703
|
131875
|
131876
|
133001
|
133002
|
133003
|
133004
|
133005
|
133006
|
133007
|
133008
|
133009
|
133010
|
133011
|
133012
|
133013
|
133014
|
133015
|
133016
|
133017
|
133018
|
133019
|
133020
|
133021
|
133022
|
133023
|
133024
|
133025
|
133026
|
133027
|
134018
|
134019
|
134020
|
134021
|
134022
|
134023
|
134024
|
134025
|
134026
|
134027
|
134028
|
134029
|
134030
|
134031
|
134032
|
134033
|
134034
|
134035
|
134036
|
134037
|
134038
|
134039
|
134040
|
134041
|
134042
|
134043
|
134044
|
134045
|
134046
|
134047
|
134048
|
134049
|
134050
|
134051
|
134052
|
134053
|
134054
|
134086
|
134087
|
134088
|
134089
|
134090
|
134091
|
134092
|
134093
|
134094
|
134095
|
134096
|
134097
|
134098
|
134099
|
134100
|
134101
|
134102
|
134103
|
134104
|
134105
|
134106
|
134107
|
134108
|
134109
|
134110
|
134111
|
134112
|
134113
|
134114
|
134115
|
134116
|
134117
|
134118
|
134119
|
134120
|
134121
|
134122
|
134123
|
134133
|
134134
|
134135
|
134136
|
134137
|
134138
|
134139
|
134140
|
134141
|
134142
|
134143
|
134144
|
134145
|
134146
|
134147
|
134148
|
134149
|
134150
|
134151
|
134152
|
134153
|
134154
|
134155
|
134156
|
134157
|
134158
|
134159
|
134160
|
134161
|
134162
|
134163
|
134164
|
134165
|
134166
|
134167
|
134168
|
134169
|
134170
|
134171
|
134194