From 46b555e4d7113bf749b447bd0e0542e76a3525ef Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Tue, 17 Apr 2018 12:00:15 +0100 Subject: [PATCH] Bug 20581: API provide status_alias embed - This patch provides the illrequests API route with an additional embed, called 'status_alias'. Requesting this embed returns an object for the request's status_alias authorised value, or null if one is not set. - This patch also adds the new status_alias as a default embed on the API call made by the illlist view Signed-off-by: Niamh.Walker-Headon@it-tallaght.ie --- Koha/Illrequest.pm | 5 +++++ api/v1/swagger/paths/illrequests.json | 1 + koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index d2c70ba64a..62b3b8e783 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1030,6 +1030,11 @@ sub TO_JSON { $object->{id_prefix} = $self->id_prefix; if ( scalar (keys %$embed) ) { + # Augment the request response with statusalias details if + # appropriate + if ( $embed->{status_alias}) { + $object->{status_alias} = $self->statusalias; + } # Augment the request response with patron details if appropriate if ( $embed->{patron} ) { my $patron = $self->patron; diff --git a/api/v1/swagger/paths/illrequests.json b/api/v1/swagger/paths/illrequests.json index 13ec426fce..73cf46862f 100644 --- a/api/v1/swagger/paths/illrequests.json +++ b/api/v1/swagger/paths/illrequests.json @@ -14,6 +14,7 @@ "items": { "type": "string", "enum": [ + "status_alias", "patron", "library", "capabilities", 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 8bc9268364..40151ce65b 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 @@ -220,7 +220,7 @@ // Get our data from the API and process it prior to passing // it to datatables var ajax = $.ajax( - '/api/v1/illrequests?embed=metadata,patron,capabilities,library' + '/api/v1/illrequests?embed=metadata,patron,capabilities,library,status_alias' ).done(function() { var data = JSON.parse(ajax.responseText); // Make a copy, we'll be removing columns next and need -- 2.11.0