From 2e42ac6e878f1fd4077faef0db55533c92c79982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= Date: Wed, 28 May 2025 11:35:32 +0200 Subject: [PATCH] Bug 40013: Add a way to inject custom filters for OPAC ILL table Test plan: 1. In KTD, go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=master+switch and enable the ILL module 2. Set the following OPACUserJS: document.addEventListener('DOMContentLoaded', function() { const listInfo = document.querySelector('#illrequestlist_info'); if (listInfo) { const statusFilters = document.createElement('div'); listInfo.parentElement.appendChild(statusFilters); const shortcuts = [ ['Show new requests', 'NEW'], ['Show ordered requests', 'ORDERED'], ['Show all requests', ''], ]; for (const [label, status] of shortcuts) { const button = document.createElement('button'); button.textContent = label; button.className = 'btn btn-secondary'; button.onclick = () => { if (status) { opac_illrequests_additional_filters['me.status'] = { '=': status }; } else { delete opac_illrequests_additional_filters['me.status']; } $('#illrequestlist').DataTable().draw(); }; statusFilters.parentElement.appendChild(button); } } }); 2. Run the following in koha-shell to populate the request list for user `koha`: perl -Mt::lib::TestBuilder -e ' my $builder = t::lib::TestBuilder->new; do { $builder->build_sample_ill_request({borrowernumber => 51, status => ($_ > 10 ? "NEW" : "ORDERED")}); } for (1..50); ' 3. Navigate to http://localhost:8080/cgi-bin/koha/opac-illrequests.pl, log in as `koha` as needed 4. Observe the new buttons affecting the requests displayed in the table Sponsored-by: Wiko --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt index 20b8fea762..bcbcf04f25 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -421,6 +421,7 @@ return status_label; } + let opac_illrequests_additional_filters = {}; $("#illrequestlist").kohaTable({ order: [[ 0, "desc" ]], dom: '<"dt-info"i><"top pager"<"table_entries"lp>t<"bottom pager"pi>', @@ -494,7 +495,7 @@ }, } ] - }); + }, undefined, undefined, opac_illrequests_additional_filters); $("#backend-dropdown-options").removeClass("nojs"); [% IF services_json.length > 0 %] var services = [% services_json | $raw %]; -- 2.49.0