From 24eb1470b17cd6661cb70ee834b55ec4f45e7a24 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Fri, 13 Apr 2018 09:22:26 +0100 Subject: [PATCH] Bug 20563: Allow display of requested partners This patch adds the display of requested partner email addresses when an ILL backend provides the ability to send requests to partners. Partner email addresses are displayed in the illlist and illview displays, they are also included in the 'illrequests' API response. * api/v1/swagger/paths/illrequests.json: - Add 'requested_partners' as an 'embed' enum * Koha/Illrequest.pm: - Add 'requested_partners' accessor calling optional backend 'get_requested_partners' method. - Store requested partners upon email send, calling optional backend 'set_requested_partners' method. - Add 'requested_parners' embed to overloaded TO_JSON method. * koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt: - Add 'requested_partners' embed to illrequests API call - Add render function for "Additional status" datatables column - Add display of requested partner email addresses to illlist table - Add display of requested partner email addresses to illview display To test: 1) Enable Interlibrary loans 2) Add a backend that supports sending requests to partners, e.g. FreeForm 3) Set up at least one partner 4) Create an ILL request 5) Send request to partner(s) 6) Observe partner(s) email address(es) are displayed in "View ILL requests" view 7) Observe partner(s) email address(es) are displayed in "Manage ILL request" view Signed-off-by: mmg@interleaf.ie --- Koha/Illrequest.pm | 32 +++++++++++++++++++++- api/v1/swagger/paths/illrequests.json | 3 +- ill/ill-requests.pl | 4 +-- .../prog/en/modules/ill/ill-requests.tt | 26 ++++++++++++++++-- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 99b97bdbe4..adb6b9ee12 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1,6 +1,6 @@ package Koha::Illrequest; -# Copyright PTFS Europe 2016 +# Copyright PTFS Europe 2016,2018 # # This file is part of Koha. # @@ -920,6 +920,13 @@ EOF my $result = sendmail(%mail); if ( $result ) { $self->status("GENREQ")->store; + $self->_backend_capability( + 'set_requested_partners', + { + request => $self, + to => $to + } + ); return { error => 0, status => '', @@ -984,6 +991,23 @@ sub _censor { return $params; } +=head3 requested_partners + + my $partners_string = $illRequest->requested_partners; + +Return the string representing the email addresses of the parters to +whom a request has been sent + +=cut + +sub requested_partners { + my ( $self ) = @_; + return $self->_backend_capability( + 'get_requested_partners', + { request => $self } + ); +} + =head3 TO_JSON $json = $illrequest->TO_JSON @@ -1023,6 +1047,11 @@ sub TO_JSON { $self->branchcode )->TO_JSON; } + # Augment the request response with requested partner details + # if appropriate + if ( $embed->{requested_partners} ) { + $object->{requested_partners} = $self->requested_partners; + } } return $object; @@ -1041,6 +1070,7 @@ sub _type { =head1 AUTHOR Alex Sassmannshausen +Andrew Isherwood =cut diff --git a/api/v1/swagger/paths/illrequests.json b/api/v1/swagger/paths/illrequests.json index 13ec426fce..5f2f020c1f 100644 --- a/api/v1/swagger/paths/illrequests.json +++ b/api/v1/swagger/paths/illrequests.json @@ -17,7 +17,8 @@ "patron", "library", "capabilities", - "metadata" + "metadata", + "requested_partners" ] } }, { diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index 47cfc97050..85e0d834cd 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -200,10 +200,10 @@ if ( $backends_available ) { } catch { my $error; - if ( $_->isa( 'Koha::Exceptions::Ill::NoTargetEmail' ) ) { + if ( ref($_) eq 'Koha::Exceptions::Ill::NoTargetEmail' ) { $error = 'no_target_email'; } - elsif ( $_->isa( 'Koha::Exceptions::Ill::NoLibraryEmail' ) ) { + elsif ( ref($_) eq 'Koha::Exceptions::Ill::NoLibraryEmail' ) { $error = 'no_library_email'; } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 70f31cad16..564e801b3e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -48,6 +48,7 @@ 'biblio_id', 'library', 'status', + 'additional_status', 'updated', 'illrequest_id', 'action' @@ -157,6 +158,18 @@ } }; + // Render function for additional status + var createAdditional = function(data, type, row) { + return ( + row.hasOwnProperty('requested_partners') && + row.requested_partners && + row.requested_partners.length > 0 + ) ? + "Requested from:
" + + row.requested_partners.replace('; ','
') : + ''; + }; + // Render function for creating a row's action link var createActionLink = function(data, type, row) { return ' Status: [% capabilities.$req_status.name %] + [% IF request.requested_partners.length > 0 %] + ([% request.requested_partners %]) + [% END %] +
Last updated: @@ -592,6 +613,7 @@ Biblio ID Library Status + Additional status Updated on Request number -- 2.11.0