From c17ab9bd75ef6ad4dcb9922546fe3273f59aa5ee 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 Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- 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 | 14 ++++---- 6 files changed, 85 insertions(+), 7 deletions(-) diff --git a/Koha/Ticket.pm b/Koha/Ticket.pm index 83b84bc97e..ea17e899de 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 f275a32df6..1ad6b6577a 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 bfa0e11a46..651a12a6e7 100644 --- a/api/v1/swagger/definitions/ticket.yaml +++ b/api/v1/swagger/definitions/ticket.yaml @@ -68,6 +68,11 @@ properties: - integer - "null" description: Number of updates + _strings: + type: + - object + - "null" + description: A list of stringified coded values additionalProperties: false required: - source diff --git a/api/v1/swagger/paths/tickets.yaml b/api/v1/swagger/paths/tickets.yaml index a0d0e2a759..b28dc4fca0 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 98f638106b..501aef8ed4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt @@ -103,6 +103,7 @@ "resolver", "biblio", "updates+count", + "+strings" ], 'emptyTable': '
' + _("Congratulations, there are no catalog concerns.") + '
', "columnDefs": [{ @@ -167,7 +168,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 e180144267..ae74ffa9a2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -33,7 +33,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) { @@ -65,13 +65,15 @@ $(document).ready(function () { }) + " (" + $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.39.2