Bugzilla – Attachment 184806 Details for
Bug 38259
Adjust DT's lengthMenu option
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38259: lengthMenu
Bug-38259-lengthMenu.patch (text/plain), 10.99 KB, created by
Jonathan Druart
on 2025-07-29 13:39:07 UTC
(
hide
)
Description:
Bug 38259: lengthMenu
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-07-29 13:39:07 UTC
Size:
10.99 KB
patch
obsolete
>From d8adff215cf6263cbccf10a6049883cf4aa01b20 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 28 Jul 2025 16:05:17 +0200 >Subject: [PATCH] Bug 38259: lengthMenu > >Needs DataTables 2.3+ for lengthLabels >--- > .../prog/en/includes/patron-search.inc | 31 +++++-------------- > .../prog/en/modules/acqui/parcel.tt | 5 +-- > .../en/modules/admin/additional-fields.tt | 5 --- > .../prog/en/modules/patroncards/edit-batch.tt | 21 ++++--------- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 8 ++--- > .../ERM/EHoldingsEBSCOPackageTitlesList.vue | 5 +-- > .../ERM/EHoldingsEBSCOPackagesList.vue | 5 +-- > .../ERM/EHoldingsEBSCOTitlePackagesList.vue | 5 +-- > .../ERM/EHoldingsEBSCOTitlesList.vue | 5 +-- > 9 files changed, 22 insertions(+), 68 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 80bd155c189..7665a6bed55 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -350,28 +350,11 @@ > parent_block.find(".info").hide(); > parent_block.find(".error").hide(); > >- // Build the aLengthMenu >- let aLengthMenu = [ >- ...new Set([[% Koha.Preference('PatronsPerPage') | html %], 10, 20, 50, 100, -1]) >- ]; >- aLengthMenu.sort(function( a, b ){ >- // Put "All" at the end >- if ( a == -1 ) { >- return 1; >- } else if ( b == -1 ) { >- return -1; >- } >- return parseInt(a) < parseInt(b) ? -1 : 1;} >- ); >- let aLengthMenuLabel = []; >- $(aLengthMenu).each(function(){ >- if ( this == -1 ) { >- // Label for -1 is "All" >- aLengthMenuLabel.push(_("All")); >- } else { >- aLengthMenuLabel.push(this); >- } >- }); >+ // Build the lengthMenu >+ let lengthMenu = dataTablesDefaults.lengthMenu; >+ let patronsPerPage = [% Koha.Preference('PatronsPerPage') || '20' | html %] >+ // Merge, remove -1, sort, add -1 >+ lengthMenu = [...new Set(lengthMenu.concat(patronsPerPage).filter(v => v !== -1))].sort((a, b) => a - b).concat(-1); > > let additional_filters = { > surname: function(){ >@@ -774,9 +757,9 @@ > 'embed': [% To.json(embed) | $raw %], > "order": [[ [% order_column_index | html %], "asc" ]], > "autoWidth": false, >- 'lengthMenu': [aLengthMenu, aLengthMenuLabel], >+ lengthMenu, >+ pageLength: patronsPerPage, > "pagingType": 'full_numbers', >- "pageLength": [% Koha.Preference('PatronsPerPage') | html %], > [% IF sticky_header %] > "initComplete": function(settings, json) { > $("#[% sticky_header | html %]").show(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index 4dfc2d6ddef..edfccb8fa44 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -372,10 +372,7 @@ > var receivedt = $("#receivedt").kohaTable({ > stateSave: true, // We do not have table settings on this table > pageLength: 10, >- lengthMenu: [ >- [5, 10, 20, 50, 100, -1], >- [5, 10, 20, 50, 100, _("All")], >- ], >+ lengthMenu: [5, 10, 20, 50, 100, -1], > columns: [ > { type: "html" }, > { type: "html" }, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >index e8c76a2f3b2..02eb143b7f7 100755 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >@@ -323,11 +323,6 @@ > autoWidth: false, > dom: 't<"bottom pager"ilpf>', > pagingType: "full", >- lengthMenu: [ >- [10, 20, 50, 100, -1], >- [10, 20, 50, 100, "All"], >- ], >- pageLength: 20, > order: [[0, "asc"]], > }); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >index 1ee578a3b22..0a79bd1eed2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >@@ -289,20 +289,11 @@ > }; > > $(document).ready(function() { >- // Prepare DataTables settings >- var aLengthMenu = [10, 20, 50, 100, -1]; >- var aLengthMenuLabel = [10, 20, 50, 100, _("All")]; >- var patronsPerPage = [% Koha.Preference('PatronsPerPage') | html %]; >- for ( var i = 0; i < aLengthMenu.length; i++ ) { >- if ( aLengthMenu[i] == patronsPerPage ) { >- break; >- } >- if ( aLengthMenu[i] > patronsPerPage || aLengthMenu[i] == -1 ) { >- aLengthMenu.splice(i, 0, patronsPerPage); >- aLengthMenuLabel.splice(i, 0, patronsPerPage); >- break; >- } >- } >+ // Build the lengthMenu >+ let lengthMenu = dataTablesDefaults.lengthMenu; >+ let patronsPerPage = [% Koha.Preference('PatronsPerPage') || '20' | html %] >+ // Merge, remove -1, sort, add -1 >+ lengthMenu = [...new Set(lengthMenu.concat(patronsPerPage).filter(v => v !== -1))].sort((a, b) => a - b).concat(-1); > > [% IF table_loop %] > $("#description").show(); >@@ -312,7 +303,7 @@ > $("#batcht").kohaTable({ > order: [[0, "asc"]], > pagingType: "full", >- lengthMenu: [aLengthMenu, aLengthMenuLabel], >+ lengthMenu, > pageLength: patronsPerPage, > autoWidth: false, > }); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index bdfe317ddaa..4640af6920a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -17,6 +17,9 @@ var dataTablesDefaults = { > infoEmpty: __("No entries to show"), > infoFiltered: __("(filtered from _MAX_ total entries)"), > lengthMenu: __("Show _MENU_ entries"), >+ lengthLabels: { >+ "-1": __("All"), >+ }, > loadingRecords: __("Loading..."), > processing: __("Processing..."), > search: __("Search:"), >@@ -60,10 +63,7 @@ var dataTablesDefaults = { > }, > }, > ], >- lengthMenu: [ >- [10, 20, 50, 100, -1], >- [10, 20, 50, 100, __("All")], >- ], >+ lengthMenu: [10, 20, 50, 100, -1], > pageLength: 20, > fixedHeader: true, > initComplete: function (settings) { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageTitlesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageTitlesList.vue >index e6a20358208..9b0aba6f8f5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageTitlesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageTitlesList.vue >@@ -103,10 +103,7 @@ export default { > embed: "title", > ordering: false, > dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', >- lengthMenu: [ >- [10, 20, 50, 100], >- [10, 20, 50, 100], >- ], >+ lengthMenu: [10, 20, 50, 100], > }, > filters_options: { > 1: () => >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >index c17c2d88c8f..fb46ba79bf4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >@@ -107,10 +107,7 @@ export default { > embed: "resources+count,vendor.name", > ordering: false, > dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', >- lengthMenu: [ >- [10, 20, 50, 100], >- [10, 20, 50, 100], >- ], >+ lengthMenu: [10, 20, 50, 100], > }, > table_settings: this.eholdings_titles_table_settings, > actions: { 0: ["show"] }, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue >index b8536d245f7..5c8bc338b84 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue >@@ -94,10 +94,7 @@ export default { > embed: ["package.name"], > ordering: false, > dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', >- lengthMenu: [ >- [10, 20, 50, 100], >- [10, 20, 50, 100], >- ], >+ lengthMenu: [10, 20, 50, 100], > autoWidth: false, > columns: [ > { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue >index 60c4a0a1978..015409638ac 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue >@@ -113,10 +113,7 @@ export default { > options: { > ordering: false, > dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', >- lengthMenu: [ >- [10, 20, 50, 100], >- [10, 20, 50, 100], >- ], >+ lengthMenu: [10, 20, 50, 100], > }, > filters_options: { > 1: () => >-- >2.34.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 38259
: 184806