From dee86df99022bd341e630687de34c481f7272d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= Date: Fri, 7 Mar 2025 12:12:45 +0100 Subject: [PATCH] Bug 39610: Make ILL request metadata fields shown in OPAC table configurable 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. Run the following script to populate the request list for user `koha`: use strict; use warnings; use Koha::ILL::Request; my $backend = 'Standard'; my $branchcode = 'CPL'; for my $n (1..100) { my $req = Koha::ILL::Request->new->load_backend($backend); my $fields = $req->_backend->_get_core_fields(); my @extended_attributes = map { +{ type => $_, value => "$_ for $n" } } keys %$fields; $req->_backend->create_api({ backend => $backend, branchcode => $branchcode, borrowernumber => 51, type => 'book', extended_attributes => \@extended_attributes, }, $req); } 3. Navigate to http://localhost:8080/cgi-bin/koha/opac-illrequests.pl, log in as `koha` as needed 4. Observe only the default Author and Title being displayed 5. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ILLOpacMetadataFields and set `author|article_author(Article Author)` as the new value 6. On http://localhost:8080/cgi-bin/koha/opac-illrequests.pl, observe how the configured metadata values are now shown, with configured names Sponsored-by: Wiko (https://www.wiko-berlin.de/) --- .../admin/preferences/interlibrary_loans.pref | 6 ++++++ .../bootstrap/en/modules/opac-illrequests.tt | 18 +++++++----------- opac/opac-illrequests.pl | 9 ++++++++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref index 44d8a9e83a..99440ca740 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref @@ -48,6 +48,12 @@ Interlibrary loans: - pref: ILLOpacbackends class: multi - (separated with |). If left empty, all installed backends will be enabled. + - + - "ILL request metadata displayed in the OPAC request table:" + - pref: ILLOpacMetadataFields + class: multi + - (separated with |). Defaults to "author|title". + - 'Customize the displayed name by putting its display name in brackets, like: "part_title(Chapter/Article title)".' Workflow: - - pref: ILLCheckAvailability 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 96ce9bc5cb..27e729daaa 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -135,8 +135,9 @@ Request ID - Author - Title + [% FOR field IN metadata_fields %] + [% field.name | html %] + [% END %] Requested from Request type Status @@ -346,20 +347,15 @@ return data; }, }, + [% FOR field IN metadata_fields %] { - data: 'author', + data: '[% field.key | html %]', sortable: false, render: (data, type, row, meta) => { - return display_extended_attribute(row, 'author'); - }, - }, - { - data: 'title', - sortable: false, - render: (data, type, row, meta) => { - return display_extended_attribute(row, 'title'); + return display_extended_attribute(row, '[% field.key | html %]'); }, }, + [% END %] { data: 'ill_backend_id', sortable: true, diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index 89f38b56da..b546f2639c 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -83,7 +83,14 @@ if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$can } if ( $op eq 'list' ) { - $template->param( backends => $backends ); + my @metadata_fields = + map { / ^ ( [^\(]+ ) \( ([^\)]+) \) $ /x ? { key => $1, name => $2 } : { key => $_, name => ucfirst $_ } } + split /\|/, ( C4::Context->preference('ILLOpacMetadataFields') || 'author|title' ); + + $template->param( + backends => $backends, + metadata_fields => \@metadata_fields, + ); } elsif ( $op eq 'view' ) { $template->param( request => $request ); } elsif ( $op eq 'cud-update' ) { -- 2.47.2