From f4c47d623a88ea5d9c46392c5176234aba34858c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 22 Dec 2023 16:14:40 +0000 Subject: [PATCH] Bug 35628: Display status strings instead of codes Signed-off-by: Esther Melander Signed-off-by: Ray Delahunty --- Koha/Ticket.pm | 34 +++++++++++++++++++ Koha/Ticket/Update.pm | 34 +++++++++++++++++++ api/v1/swagger/definitions/ticket.yaml | 5 +++ api/v1/swagger/paths/tickets.yaml | 2 ++ .../prog/en/modules/cataloguing/concerns.tt | 3 +- .../prog/js/modals/display_ticket.js | 9 +++-- 6 files changed, 83 insertions(+), 4 deletions(-) diff --git a/Koha/Ticket.pm b/Koha/Ticket.pm index 83b84bc97e3..ea17e899de4 100644 --- a/Koha/Ticket.pm +++ b/Koha/Ticket.pm @@ -179,6 +179,40 @@ sub to_api_mapping { return { id => 'ticket_id', }; } +=head3 strings_map + +=cut + +sub strings_map { + my ( $self, $params ) = @_; + + my $strings = {}; + + if ( defined $self->status ) { + my $av = Koha::AuthorisedValues->search( + { + category => 'TICKET_STATUS', + authorised_value => $self->status, + } + ); + + my $status_str = + $av->count + ? $params->{public} + ? $av->next->opac_description + : $av->next->lib + : $self->status; + + $strings->{status} = { + category => 'TICKET_STATUS', + str => $status_str, + type => 'av', + }; + } + + return $strings; +} + =head3 _type =cut diff --git a/Koha/Ticket/Update.pm b/Koha/Ticket/Update.pm index f275a32df6f..1ad6b6577a1 100644 --- a/Koha/Ticket/Update.pm +++ b/Koha/Ticket/Update.pm @@ -68,6 +68,40 @@ sub to_api_mapping { return { id => 'update_id', }; } +=head3 strings_map + +=cut + +sub strings_map { + my ( $self, $params ) = @_; + + my $strings = {}; + + if ( defined $self->status ) { + my $av = Koha::AuthorisedValues->search( + { + category => 'TICKET_STATUS', + authorised_value => $self->status, + } + ); + + my $status_str = + $av->count + ? $params->{public} + ? $av->next->opac_description + : $av->next->lib + : $self->status; + + $strings->{status} = { + category => 'TICKET_STATUS', + str => $status_str, + type => 'av', + }; + } + + return $strings; +} + =head3 _type =cut diff --git a/api/v1/swagger/definitions/ticket.yaml b/api/v1/swagger/definitions/ticket.yaml index e588c99515e..8699e455f43 100644 --- a/api/v1/swagger/definitions/ticket.yaml +++ b/api/v1/swagger/definitions/ticket.yaml @@ -64,6 +64,11 @@ properties: - integer - "null" description: Number of updates + _strings: + type: + - object + - "null" + description: A list of stringified coded values additionalProperties: false required: - title diff --git a/api/v1/swagger/paths/tickets.yaml b/api/v1/swagger/paths/tickets.yaml index a0d0e2a7593..b28dc4fca01 100644 --- a/api/v1/swagger/paths/tickets.yaml +++ b/api/v1/swagger/paths/tickets.yaml @@ -28,6 +28,7 @@ - resolver - biblio - updates+count + - +strings collectionFormat: csv responses: "200": @@ -237,6 +238,7 @@ type: string enum: - user + - +strings collectionFormat: csv responses: "200": diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt index 7effa4e819a..914121782ed 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt @@ -102,6 +102,7 @@ "resolver", "biblio", "updates+count", + "+strings" ], 'emptyTable': '
' + _("Congratulations, there are no catalog concerns.") + '
', "columnDefs": [{ @@ -166,7 +167,7 @@ result += '' + $datetime(row.resolved_date) + ''; } else { if (row.status) { - result += row.status; + result += row._strings.status ? escape_str(row._strings.status.str) : ""; } else { result += _("Open"); } diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js index afb0d8909d2..282c2d4fcea 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -32,7 +32,7 @@ $(document).ready(function() { url: "/api/v1/tickets/" + ticket_id + "/updates", method: "GET", headers: { - "x-koha-embed": "user" + "x-koha-embed": [ "user", "+strings" ] }, }).success(function(data) { let updates_display = $('#concern-updates'); @@ -50,10 +50,13 @@ $(document).ready(function() { updates += '' + $patron_to_html(item.user, { display_cardnumber: false, url: true - }) + ' (' + $datetime(item.date) + ')'; + }) + ' (' + $datetime(item.date) + ')'; if ( item.status ) { - updates += '' + item.status + '' + updates += ''; + updates += item._strings.status ? escape_str(item._strings.status.str) : ""; + updates += '' } + updates += ''; updates += ''; }); updates_display.html(updates); -- 2.44.0