From be96cd3100f1fea0eec85c64aa21b1f9457eb737 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 3 Oct 2024 13:34:34 +0000 Subject: [PATCH] Bug 38074: Add HoldingsTableDefaultLength system preference This patch adds anew preference to allow determining the default number of items shown on the details page. To test: 1 - Add 100 items to a bib record 2 - View the holdings tab on the details page 3 - NOte default of 20 shown 4 - Apply patch, update database 5 - Reload the page (clear cache), no change 6 - Set new system preference HoldingsTableDefaultLength to 32 7 - Reload page, note 32 items loaded, dropdown of results per page includes 32 8 - Set pref to 50 9 - Reload page, 50 items displayed, dropdown set to 50 10 - Set pref to -1 11 - Reload page, all items displayed 12 - Set pref to 100 13 - Reload page, 100 items displayed, no page dropdown (This is a bug but seems to be present before this patch as well) --- installer/data/mysql/mandatory/sysprefs.sql | 1 + .../html_helpers/tables/items/catalogue_detail.inc | 11 +++++++++++ .../en/modules/admin/preferences/staff_interface.pref | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 66c7b008f21..8df74885a1e 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -297,6 +297,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), ('HidePersonalPatronDetailOnCirculation', 0, '', 'Hide patrons phone number, email address, street address and city in the circulation page','YesNo'), ('HoldFeeMode','not_always','any_time_is_placed|not_always|any_time_is_collected','Set the hold fee mode','Choice'), +('HoldingsTableDefaultLength','0','','Default page length for the holdings table on the details page','Integer'), ('HoldRatioDefault','3','','Default value for the hold ratio report','Integer'), ('HoldsAutoFill','0',NULL,'If on, librarian will not be asked if hold should be filled, it will be filled automatically','YesNo'), ('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 099cfdd6fd1..02f95f1b19d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -281,9 +281,20 @@ [offset+2] : () => all_libraries, }; + [% IF Koha.Preference('HoldingsTableDefaultLength') %] + table_page_length = [% Koha.Preference('HoldingsTableDefaultLength') | html %]; + items_table_settings[tab_id].default_display_length = table_page_length; + let page_size_dropdown = { 10: "10", 20: "20", 50: "50", 100: "100", "-1": "All" }; + if( table_page_length != -1 ){ + page_size_dropdown[table_page_length] = table_page_length; + } + [% END %] var items_table = $("#" + tab_id + '_table').kohaTable({ ajax: { url: item_table_url }, order: [], + [% IF Koha.Preference('HoldingsTableDefaultLength') %] + lengthMenu: [Object.keys(page_size_dropdown),Object.values(page_size_dropdown)], + [% END %] embed, autoWidth: false, bKohaColumnsUseNames: true, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref index d4a5c401708..7b919abe4ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref @@ -132,6 +132,12 @@ Staff interface: 1: Allow 0: "Do not allow" - Open Document Spreadsheet (ODS) as download format in reports. + - + - Show + - pref: HoldingsTableDefaultLength + class: integer + - items by default on the holdings tab of the details page. + - 0 will disable this and use default of 20, -1 will default to 'All'. Options: - -- 2.39.5