From 0c7d9e4cc884f60af39859dcd674688d98cf3fae 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 https://bugs.koha-community.org/show_bug.cgi?id=20653 Bug 20563: (follow-up) Fix requested partners As per: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20563#c10 Thanks for the suggestion on merging the "Status" and "Additional status" columns, looks much better! Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- Koha/Illrequest.pm | 27 ++++++++++++++++++- Koha/REST/V1/Illrequests.pm | 3 +++ api/v1/swagger/paths/illrequests.json | 3 ++- .../prog/en/modules/ill/ill-requests.tt | 17 +++++++++--- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 19efa85764..57e47260dd 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. # @@ -1119,6 +1119,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 => '', @@ -1205,6 +1212,23 @@ sub store { return $ret; } +=head3 requested_partners + + my $partners_string = $illRequest->requested_partners; + +Return the string representing the email addresses of the partners 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 @@ -1239,6 +1263,7 @@ sub _type { =head1 AUTHOR Alex Sassmannshausen +Andrew Isherwood =cut diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index f8385a7fd2..a5ec780d2e 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -161,6 +161,9 @@ sub list { if ($embed{status_alias}) { $to_push->{status_alias} = $req->statusalias; } + if ($embed{requested_partners}) { + $to_push->{requested_partners} = $req->requested_partners; + } push @output, $to_push; } diff --git a/api/v1/swagger/paths/illrequests.json b/api/v1/swagger/paths/illrequests.json index 99ec0dd95b..0fc13e9007 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/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 63514107d0..833d93cd74 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 @@ -363,6 +363,9 @@ [% request.statusalias.lib | html %] [% ELSE %] [% request.capabilities.$req_status.name | html%] + [% IF request.requested_partners.length > 0 %] + ([% request.requested_partners | html %]) + [% END %] [% END %]
  • @@ -787,21 +790,29 @@ var status_name = meta.settings.oInit.originalData[0].capabilities[ row.status ].name; - return getStatusName(status_name); + return getStatusName(status_name, row); } else { return ''; } } }; - var getStatusName = function(origName) { + var getStatusName = function(origName, row) { switch( origName ) { case "New request": return _("New request"); case "Requested": return _("Requested"); case "Requested from partners": - return _("Requested from partners"); + var statStr = _("Requested from partners"); + if ( + row.hasOwnProperty('requested_partners') && + row.requested_partners && + row.requested_partners.length > 0 + ) { + statStr += ' (' + row.requested_partners + ')'; + } + return statStr; case "Request reverted": return _("Request reverted"); case "Queued request": -- 2.39.5